problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum,
BlockDriverState **file)
{
IscsiLun *iscsilun = bs->opaque;
struct scsi_get_lba_status *lbas = NULL;
struct scsi_lba_status_descriptor *lbasd = NULL;
struct IscsiTask iTask;
int64_t ret;
iscsi_co_init_iscsitask(iscsilun, &iTask);
if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
ret = -EINVAL;
goto out;
}
ret = BDRV_BLOCK_DATA;
ret |= (sector_num << BDRV_SECTOR_BITS) | BDRV_BLOCK_OFFSET_VALID;
*pnum = nb_sectors;
if (!iscsilun->lbpme) {
goto out;
}
retry:
if (iscsi_get_lba_status_task(iscsilun->iscsi, iscsilun->lun,
sector_qemu2lun(sector_num, iscsilun),
8 + 16, iscsi_co_generic_cb,
&iTask) == NULL) {
ret = -ENOMEM;
goto out;
}
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.do_retry) {
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
iTask.complete = 0;
goto retry;
}
if (iTask.status != SCSI_STATUS_GOOD) {
goto out;
}
lbas = scsi_datain_unmarshall(iTask.task);
if (lbas == NULL) {
ret = -EIO;
goto out;
}
lbasd = &lbas->descriptors[0];
if (sector_qemu2lun(sector_num, iscsilun) != lbasd->lba) {
ret = -EIO;
goto out;
}
*pnum = sector_lun2qemu(lbasd->num_blocks, iscsilun);
if (lbasd->provisioning == SCSI_PROVISIONING_TYPE_DEALLOCATED ||
lbasd->provisioning == SCSI_PROVISIONING_TYPE_ANCHORED) {
ret &= ~BDRV_BLOCK_DATA;
if (iscsilun->lbprz) {
ret |= BDRV_BLOCK_ZERO;
}
}
if (ret & BDRV_BLOCK_ZERO) {
iscsi_allocationmap_clear(iscsilun, sector_num, *pnum);
} else {
iscsi_allocationmap_set(iscsilun, sector_num, *pnum);
}
if (*pnum > nb_sectors) {
*pnum = nb_sectors;
}
out:
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
}
if (ret > 0 && ret & BDRV_BLOCK_OFFSET_VALID) {
*file = bs;
}
return ret;
}
| 1threat |
Why is a closing brace showing no code coverage? : <p>I've got a Swift function for which Xcode is showing 0 passes in code coverage. The line is a closing brace (highlighted in red below).</p>
<p>Is this a bug in Xcode? If not, what condition do I need to hit to run that line? I thought I was covering all paths through this method.</p>
<p><a href="https://i.stack.imgur.com/mD5TY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mD5TY.png" alt="Code with un-covered line"></a></p>
| 0debug |
How to find min and max in Two Dimensional array . Java : public class Average {
static Integer[][] myDouble = new Integer[10][12];
static int x = 0, y = 0;
static int strDouble;
public Average() {
try {
BufferedReader in = new BufferedReader(new FileReader("StudentIdAverage.txt"));
String line;
while ((line = in.readLine()) != null) {
String[] values = line.split("\\s+");
for (String str : values) {
strDouble = Integer.parseInt(str);
myDouble[x][y] = strDouble;
y = y + 1;
}
x = x + 1;
y = 0;
}
in.close();
} catch (IOException ioException) {
}
}
public static void main(String[] args) {
Average arr = new Average();
for (int k = 0; k < myDouble.length; ++k) {
int count = 0; // count the values used to calculate sum
int sum = 0;
int average = 0;
for (int j = 0; j < myDouble[k].length; ++j) {
if (myDouble[k][j] == null) //skip the null values
{
continue;
}
sum += myDouble[k][j];
count++;
System.out.print(Average.myDouble[k][j] + " ");
}
average = (sum / count); //use count instead of lenght
System.out.println(" ");
}
}
}
/*
input txt file
45 72 90 50 67 63 81 71 55 56 80 74/n 55 54 79 72 75 68/n 51 88 79 72/n 98 52 52 53 50 92 67 99 92 50 61 91/n 94 48 53 92 97/n 97 69 77 74 68 54 87 74 54 83 58 69/n 75 49 87 61 66 53 79 48 96 60/n 58 71 51 73 53 75 93 81 45 69 78 65/n 50 88 78 81 99 61 97 70 87 80 69/n 91 89 97 80 93 82 92 49 52 69 96 61
*/
| 0debug |
void qemu_peer_using_vnet_hdr(NetClientState *nc, bool enable)
{
if (!nc->peer || !nc->peer->info->using_vnet_hdr) {
return;
}
nc->peer->info->using_vnet_hdr(nc->peer, enable);
}
| 1threat |
Snackbar is not dismissing on swipe : <p>i have a snackbar in my appcompat activity. It has a button OK which dismiss the snackbar.It is working perfact. but i can't dismiss the snackbar on swipe(left to right).</p>
<p>Following is my code for snackbar....</p>
<pre><code>final Snackbar snackbar = Snackbar
.make(view, "Error Message", Snackbar.LENGTH_INDEFINITE);
snackbar.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) {
snackbar.dismiss();
}
});
snackbar.show();
</code></pre>
<p><strong>Edit 1</strong></p>
<p>I have Relative layout as parent layout in my activity's XML layout.</p>
| 0debug |
static int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16],
uint8_t probs[8][3][NUM_DCT_TOKENS-1],
int i, int zero_nhood, int16_t qmul[2])
{
uint8_t *token_prob;
int nonzero = 0;
int coeff;
do {
token_prob = probs[vp8_coeff_band[i]][zero_nhood];
if (!vp56_rac_get_prob_branchy(c, token_prob[0]))
return nonzero;
skip_eob:
if (!vp56_rac_get_prob_branchy(c, token_prob[1])) {
zero_nhood = 0;
token_prob = probs[vp8_coeff_band[++i]][0];
if (i < 16)
goto skip_eob;
return nonzero;
}
if (!vp56_rac_get_prob_branchy(c, token_prob[2])) {
coeff = 1;
zero_nhood = 1;
} else {
zero_nhood = 2;
if (!vp56_rac_get_prob_branchy(c, token_prob[3])) {
coeff = vp56_rac_get_prob(c, token_prob[4]);
if (coeff)
coeff += vp56_rac_get_prob(c, token_prob[5]);
coeff += 2;
} else {
if (!vp56_rac_get_prob_branchy(c, token_prob[6])) {
if (!vp56_rac_get_prob_branchy(c, token_prob[7])) {
coeff = 5 + vp56_rac_get_prob(c, vp8_dct_cat1_prob[0]);
} else {
coeff = 7;
coeff += vp56_rac_get_prob(c, vp8_dct_cat2_prob[0]) << 1;
coeff += vp56_rac_get_prob(c, vp8_dct_cat2_prob[1]);
}
} else {
int a = vp56_rac_get_prob(c, token_prob[8]);
int b = vp56_rac_get_prob(c, token_prob[9+a]);
int cat = (a<<1) + b;
coeff = 3 + (8<<cat);
coeff += vp8_rac_get_coeff(c, vp8_dct_cat_prob[cat]);
}
}
}
block[zigzag_scan[i]] = (vp8_rac_get(c) ? -coeff : coeff) * qmul[!!i];
nonzero = ++i;
} while (i < 16);
return nonzero;
}
| 1threat |
VB.NET Creating multiple FileSystemWatcher dynamically : I'm trying to solve a very similar problem to this question:
http://stackoverflow.com/questions/30807006/multiple-configurable-filesystemwatcher-methods
The answer provided is in C# and I'm working in VB.NET and failing to translate the example despite trying for a couple of hours - I just can't get it due to my lack of experience, can anyone please help me with a VB.NET equivalent? | 0debug |
static void check_mct(uint8_t *ref0, uint8_t *ref1, uint8_t *ref2,
uint8_t *new0, uint8_t *new1, uint8_t *new2) {
declare_func(void, void *src0, void *src1, void *src2, int csize);
randomize_buffers();
call_ref(ref0, ref1, ref2, BUF_SIZE / sizeof(int32_t));
call_new(new0, new1, new2, BUF_SIZE / sizeof(int32_t));
if (memcmp(ref0, new0, BUF_SIZE) || memcmp(ref1, new1, BUF_SIZE) ||
memcmp(ref2, new2, BUF_SIZE))
fail();
bench_new(new0, new1, new2, BUF_SIZE / sizeof(int32_t));
}
| 1threat |
Where should Full stack JS beginner start? : <p>So I won't say I'm a complete beginner, as I know the very basics and have a CS degree(that I'm very rusty at) but I have gone back through and refreshed myself with the CS50 Harvard course.</p>
<p>The last project is to build something, and I've gotten more into learning JS for unit testing at work and while we mostly use rails...I'm interested in learning the new emergent stuff.</p>
<p>I've heard the 70/30 rule applies to full stack devs, and I can't imagine if ever be good with front end stuff so I'd imagine that would be my "30". However with ES6 out and all these new conventions and frameworks I'm a bit lost where I should start?</p>
<p>There is a highly rated JS and Jquery book on Amazon I've been eyeing, but it's quite old. And I wonder about backend frameworks too.</p>
<p>My ideal learning "stack" would be node/react and mongo (with express for node) but it seems like a bad idea to learn them all at once. If I'm interested in backend should I just stick with learning node/express first? </p>
<p>Do I need to worry about ES6 as a beginner? I guess I'm just stuck where to start and in general which path I should take. I've done some dabbling in express but it seems like getting at least decent with JS and Jquery makes sense first?</p>
<p>Thanks</p>
| 0debug |
After we split a String via regex, how could us get the length of new String? : public class TestString {
public static void main(String[] args) {
String str = "AaaaABBBBcc&^%adfsfdCCOOkk99876 _haHA";
String[] upStr = str.split("[a-z0-9&^% _]");
System.out.println("Printout uppercase");
for (String outUp : upStr){
System.out.print(outUp);
}
System.out.println("\n" + upStr.length);
//the "length" is wrong, so, where is the value comes from?
//How could we get real length?
System.out.println("\n Printout lowercase");
String[] lowStr = str.split("[A-Z0-9&^% _]");
for (String outLow : lowStr){
System.out.print(outLow);
}
System.out.println("\n" + lowStr.length);
System.out.println("\n non-English");
String[] nonEng = str.split("[A-Za-z]");
for (String outNonEng : nonEng){
System.out.print(outNonEng);
}
System.out.println("\n" + nonEng.length);
}
}
so my question is:
1. The value of the length is incorrect, but where is is comes from?
2. How could I get correct length of String[]? | 0debug |
Flutter - Listview.builder inside another Listview : <p>I want my screen to be scrollable so I put everything in a Listview.</p>
<p>Now I want to show another Listview inside to show details of a List. When I try this an error is thrown - " Expanded widgets must be placed inside Flex widgets." </p>
<p><a href="https://i.stack.imgur.com/opZ7y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/opZ7y.png" alt="enter image description here"></a></p>
| 0debug |
Adding bitwise operations and conversion-to-bool to scoped enums - a Christmastide exploration : <p>Let's say that I'm crazy and decided to create the following monstrosity:</p>
<pre><code>#include <type_traits>
#include <iostream>
// Utility proxy type - convertible back to E but also permits bool conversion
// for use in conditions.
//
// e.g.
// Foo f = Foo::Bar & Foo::Baz;
// if (f & Foo::Baz) { /* ... */ }
//
template <typename E, typename = std::enable_if_t<std::is_enum_v<E>, void>>
struct EnumToBoolProxy
{
operator E() const
{
return _val;
}
explicit operator bool()
{
using UT = std::underlying_type_t<E>;
return static_cast<UT>(_val) != 0;
}
private:
const E _val;
EnumToBoolProxy(const E val) : _val(val) {}
friend EnumToBoolProxy operator&(const E, const E);
friend EnumToBoolProxy operator|(const E, const E);
};
enum class Foo
{
Bar = 1, Baz = 2, Boi = 4
};
EnumToBoolProxy<Foo> operator&(const Foo lhs, const Foo rhs)
{
using UT = std::underlying_type_t<Foo>;
return static_cast<Foo>(static_cast<UT>(lhs) & static_cast<UT>(rhs));
}
EnumToBoolProxy<Foo> operator|(const Foo lhs, const Foo rhs)
{
using UT = std::underlying_type_t<Foo>;
return static_cast<Foo>(static_cast<UT>(lhs) | static_cast<UT>(rhs));
}
int main()
{
// Good
if ((Foo::Bar | Foo::Baz) & Foo::Baz)
std::cout << "Yay\n";
// Fine
const bool isFlagSet((Foo::Bar | Foo::Baz) & Foo::Baz);
std::cout << isFlagSet << '\n';
// Meh
auto proxyThing = (Foo::Bar | Foo::Baz) & Foo::Baz;
}
</code></pre>
<p>The goal is to:</p>
<ol>
<li>Have a scoped enum such that values are <code>Foo::x</code> and are of type <code>Foo</code> (symmetry!)</li>
<li>Be able to do some "bitwise" arithmetic on them and get a <code>Foo</code> back</li>
<li>Be able to check the result for zero-ness</li>
<li>But not let people generally use the enum as an arithmetic type</li>
</ol>
<p>For fun, I'm trying to avoid:</p>
<ol>
<li>Using a bog-standard enum</li>
<li>Doing this instead with free functions <code>IsFlagSet</code></li>
</ol>
<p>Ignoring for a second the incongruity of not being able to do the zero-ness check without a prior <code>&</code>- or <code>|</code>-operation…</p>
<p>It seems like a shame that my users can still "get" a <code>EnumToBoolProxy</code> (i.e. <code>proxyThing</code>). But, since it is not possible to add any members to <code>Foo</code>, and since <code>operator bool</code> must be a member, I can't seem to find any other way to go about this.</p>
<p>Granted that's not a real problem as they can't do much with the <code>EnumToBoolProxy</code>. But it still feels like an abstraction leak, so I'm curious: am I right in saying that this is just inherently impossible? That there's no way to "pick and choose" a scoped-enum's opacity like this? Or is there some way to hide this proxy type while still using as a conversion-to-bool facility to check the "result" of the <code>&</code>/<code>|</code> operations? How would you do it?</p>
| 0debug |
JavaScript Regular Expression Find and Replace : <p>I need to check if a string contains the following string, "Password:". If so I want to replace the word immediately following the ':'. For example, I have a string that has "Password:Test". I would like "Test" removed and replaced with "Removed".</p>
| 0debug |
The report definition has an invalid target namespace rsInvalidReportDefinition : <p>I have created a ReportProject with Visual Studio data tools 2015. When I create a report.rdl file using the report wizard, the rdl file has schema for 2016. My reporting server is of version 12.0.4213.0. </p>
<p>How can I create a report.rdl which is compatible with my reporting server. I tried changing the TargetServerVersion by right clicking the project -> properties and changing the targetserverversion to "Sql server 2008 R2, 2012 or 2014". But this doesn't work either.</p>
| 0debug |
how to display div id value in form input : i am trying to show JavaScript output value in form input. bellow my div which output the value.
<div id="geo" class="geolocation_data"></div>
but i want to show in input box. i tried bellow code but not showing any
<input type="text" placeholder="Please type a location" class="form-control input-lg noredius geolocation_data" value="" id="geo"> | 0debug |
int ff_wmv2_decode_picture_header(MpegEncContext * s)
{
Wmv2Context * const w= (Wmv2Context*)s;
int code;
#if 0
{
int i;
for(i=0; i<s->gb.size*8; i++)
printf("%d", get_bits1(&s->gb));
printf("END\n");
return -1;
}
#endif
if(s->picture_number==0)
decode_ext_header(w);
s->pict_type = get_bits1(&s->gb) + 1;
if(s->pict_type == I_TYPE){
code = get_bits(&s->gb, 7);
av_log(s->avctx, AV_LOG_DEBUG, "I7:%X/\n", code);
}
s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
if(s->qscale < 0)
return -1;
return 0;
}
| 1threat |
SUM TWO TEXT BOX VALUE AND GET GRADE LETTER IN THIRD TEXTBOX : i have an html form with three textboxes i want to sum the automatically using juery at the same time i want to use if else statement to check if the result is greater than 100 the value in next text box should be A
see the code below
<script>`
$('.number').keyup(function()
{
var sum = 0;
$('.number').each(function()
{
sum += Number($(this).val());
});
$('#total').val(sum);
if($('#total').val(sum) > 1)
{
form.total2.value="A";
}
});
}
});
</script>
</body>
</html> | 0debug |
static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
int64_t pos)
{
BDRVQcow2State *s = bs->opaque;
bool zero_beyond_eof = bs->zero_beyond_eof;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
bs->zero_beyond_eof = false;
ret = bdrv_preadv(bs, qcow2_vm_state_offset(s) + pos, qiov);
bs->zero_beyond_eof = zero_beyond_eof;
return ret;
}
| 1threat |
Incorrect syntax near ','. : I have been running into this error for a while now, and still haven't been able to solve it. I am trying to Update the data in my database, with a button press in a windows form.
I am using SQL 2011.
private void btnEdit_Click_1(object sender, EventArgs e)
{
MainMenu mainmenu = new MainMenu();
SqlCommand cmd = new SqlCommand("Update PresentationSpec SET Pres_name = @Pres_name, Prestor_name = @Prestor_name, Pres_Summary = @Pres_Summary, Est_Length = @Est_Length, Date_Presented = @Date_Presented WHERE Id=" + mainmenu.tbxSelected);
cmd.Connection=connection;
connection.Open();
cmd.Parameters.AddWithValue("@Pres_name", tbxpresName.Text);
cmd.Parameters.AddWithValue("@Prestor_name", tbxprstorName.Text);
cmd.Parameters.AddWithValue("@Pres_Summary", rtbSummary.Text);
cmd.Parameters.AddWithValue("@Est_Length", tbxLength.Text);
cmd.Parameters.AddWithValue("@Date_Presented", tbxDate.Text);
cmd.ExecuteNonQuery();
this.Close();
Form2 editscreen = new Form2();
Refresh();
}
If anyone knows what's wrong, please tell me. | 0debug |
static int local_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)
{
const char *sec_model = qemu_opt_get(opts, "security_model");
const char *path = qemu_opt_get(opts, "path");
if (!sec_model) {
fprintf(stderr, "security model not specified, "
"local fs needs security model\nvalid options are:"
"\tsecurity_model=[passthrough|mapped|none]\n");
return -1;
}
if (!strcmp(sec_model, "passthrough")) {
fse->export_flags |= V9FS_SM_PASSTHROUGH;
} else if (!strcmp(sec_model, "mapped")) {
fse->export_flags |= V9FS_SM_MAPPED;
} else if (!strcmp(sec_model, "none")) {
fse->export_flags |= V9FS_SM_NONE;
} else {
fprintf(stderr, "Invalid security model %s specified, valid options are"
"\n\t [passthrough|mapped|none]\n", sec_model);
return -1;
}
if (!path) {
fprintf(stderr, "fsdev: No path specified.\n");
return -1;
}
fse->path = g_strdup(path);
return 0;
}
| 1threat |
static void ich9_cc_write(void *opaque, hwaddr addr,
uint64_t val, unsigned len)
{
ICH9LPCState *lpc = (ICH9LPCState *)opaque;
ich9_cc_addr_len(&addr, &len);
memcpy(lpc->chip_config + addr, &val, len);
pci_bus_fire_intx_routing_notifier(lpc->d.bus);
ich9_cc_update(lpc);
}
| 1threat |
static int encode_picture_lossless(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
MpegEncContext * const s = avctx->priv_data;
MJpegContext * const m = s->mjpeg_ctx;
const int width= s->width;
const int height= s->height;
AVFrame * const p = &s->current_picture.f;
const int predictor= avctx->prediction_method+1;
const int mb_width = (width + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0];
const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0];
int ret, max_pkt_size = FF_MIN_BUFFER_SIZE;
if (avctx->pix_fmt == AV_PIX_FMT_BGRA)
max_pkt_size += width * height * 3 * 4;
else {
max_pkt_size += mb_width * mb_height * 3 * 4
* s->mjpeg_hsample[0] * s->mjpeg_vsample[0];
if ((ret = ff_alloc_packet2(avctx, pkt, max_pkt_size)) < 0)
init_put_bits(&s->pb, pkt->data, pkt->size);
*p = *pict;
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
ff_mjpeg_encode_picture_header(s);
s->header_bits= put_bits_count(&s->pb);
if(avctx->pix_fmt == AV_PIX_FMT_BGR0
|| avctx->pix_fmt == AV_PIX_FMT_BGRA
|| avctx->pix_fmt == AV_PIX_FMT_BGR24){
int x, y, i;
const int linesize= p->linesize[0];
uint16_t (*buffer)[4]= (void *) s->rd_scratchpad;
int left[3], top[3], topleft[3];
for(i=0; i<3; i++){
buffer[0][i]= 1 << (9 - 1);
for(y = 0; y < height; y++) {
const int modified_predictor= y ? predictor : 1;
uint8_t *ptr = p->data[0] + (linesize * y);
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < width*3*4){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
for(i=0; i<3; i++){
top[i]= left[i]= topleft[i]= buffer[0][i];
for(x = 0; x < width; x++) {
if(avctx->pix_fmt == AV_PIX_FMT_BGR24){
buffer[x][1] = ptr[3*x+0] - ptr[3*x+1] + 0x100;
buffer[x][2] = ptr[3*x+2] - ptr[3*x+1] + 0x100;
buffer[x][0] = (ptr[3*x+0] + 2*ptr[3*x+1] + ptr[3*x+2])>>2;
}else{
buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100;
buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100;
buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2;
for(i=0;i<3;i++) {
int pred, diff;
PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
topleft[i]= top[i];
top[i]= buffer[x+1][i];
left[i]= buffer[x][i];
diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100;
if(i==0)
ff_mjpeg_encode_dc(s, diff, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
else
ff_mjpeg_encode_dc(s, diff, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
}else{
int mb_x, mb_y, i;
for(mb_y = 0; mb_y < mb_height; mb_y++) {
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < mb_width * 4 * 3 * s->mjpeg_hsample[0] * s->mjpeg_vsample[0]){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
for(mb_x = 0; mb_x < mb_width; mb_x++) {
if(mb_x==0 || mb_y==0){
for(i=0;i<3;i++) {
uint8_t *ptr;
int x, y, h, v, linesize;
h = s->mjpeg_hsample[i];
v = s->mjpeg_vsample[i];
linesize= p->linesize[i];
for(y=0; y<v; y++){
for(x=0; x<h; x++){
int pred;
ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x);
if(y==0 && mb_y==0){
if(x==0 && mb_x==0){
pred= 128;
}else{
pred= ptr[-1];
}else{
if(x==0 && mb_x==0){
pred= ptr[-linesize];
}else{
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
if(i==0)
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
else
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
}else{
for(i=0;i<3;i++) {
uint8_t *ptr;
int x, y, h, v, linesize;
h = s->mjpeg_hsample[i];
v = s->mjpeg_vsample[i];
linesize= p->linesize[i];
for(y=0; y<v; y++){
for(x=0; x<h; x++){
int pred;
ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x);
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
if(i==0)
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
else
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
emms_c();
av_assert0(s->esc_pos == s->header_bits >> 3);
ff_mjpeg_encode_stuffing(s);
ff_mjpeg_encode_picture_trailer(s);
s->picture_number++;
flush_put_bits(&s->pb);
pkt->size = put_bits_ptr(&s->pb) - s->pb.buf;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
| 1threat |
"Empty collection literal requires an explicit type" error on Swift3 : <p>I have a variable on my class:</p>
<pre><code>var list = []
</code></pre>
<p>and I use it on a function of my class:</p>
<pre><code>func chargeData (data: NSArray){
list = data
}
</code></pre>
<p>It worked well on my project in <code>Swift 2.3</code> but when I have updated it to <code>XCode8</code> and <code>Swift3</code> it gives to me the following error:</p>
<blockquote>
<p>Empty collection literal requires an explicit type</p>
</blockquote>
<p>so I have added a typecast to my list variable:</p>
<pre><code>var list = [] as! NSArray
</code></pre>
<p>but it gives to me the following alert:</p>
<blockquote>
<p>Forced cast of 'NSArray' to same type has no effect</p>
</blockquote>
<p>I know that an alert does not broke the application but I would like to solve this error in a proper way.</p>
<p>Did someone got the same error and solved it properly?</p>
<p>Thanks in advance!</p>
| 0debug |
what do i have 2 do now? : ok i got the same problem as this guy who asked this..
I want to code some basic stuff for a little minesweeper-game, that we do in university. Now I have the problem that my code
`enter code here`public class Minesweeper1 {
public static int[][] makeRandomBoard(int s, int z, int n){
int feld[][] = new int [s][z];
for(int i = 0; i < s; i++){
for(int j = 0; j < z; j++){
feld[i][j] = 0;}}
for(int i = 0; i < n; i++){
selectRandomPosition(s, z);
feld[randomHeight][randomWidth] = 1;
}
}
so it starts the selectRandomPosition code:
public static int[] selectRandomPosition(int maxWidth, int maxHeight) {
int randomHeight = StdRandom.uniform(0, maxHeight);
int randomWidth = StdRandom.uniform(0, maxWidth);
return new int[]{randomHeight, randomWidth};
Here I am not allowed to change anything, but it returns a new array. Now is my question how I can use the new array in my makeRandomBoard-method, since I do not know any name of the array. When I use "feld[randomHeight][randomWidth] = 1;" it says, that it does not know these variables.
And he did get the answer:
Call the method, and assign its return value to a variable. Now you have a name for the array:
`enter code here`// Make a call
int[] randomArray = selectRandomPosition(maxW, maxH);
// Access the width
int randomW = randomArray[0];
// Access the height
int randomH = randomArray[1];
but what do i have to write now?
i tried it with:
feld[randomW][randomH] = 1;
but it seems like it doesnt work,also i need a return statement.. can anyone help me out pls ? :( | 0debug |
static inline void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
{
int addr_reg, data_reg, data_reg2, bswap;
#ifdef CONFIG_SOFTMMU
int mem_index, s_bits;
# if TARGET_LONG_BITS == 64
int addr_reg2;
# endif
uint32_t *label_ptr;
#endif
#ifdef TARGET_WORDS_BIGENDIAN
bswap = 1;
#else
bswap = 0;
#endif
data_reg = *args++;
if (opc == 3)
data_reg2 = *args++;
else
data_reg2 = 0;
addr_reg = *args++;
#ifdef CONFIG_SOFTMMU
# if TARGET_LONG_BITS == 64
addr_reg2 = *args++;
# endif
mem_index = *args;
s_bits = opc & 3;
# if CPU_TLB_BITS > 8
# error
# endif
tcg_out_dat_reg(s, COND_AL, ARITH_MOV, TCG_REG_R8,
0, addr_reg, SHIFT_IMM_LSR(TARGET_PAGE_BITS));
tcg_out_dat_imm(s, COND_AL, ARITH_AND,
TCG_REG_R0, TCG_REG_R8, CPU_TLB_SIZE - 1);
tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_R0, TCG_AREG0,
TCG_REG_R0, SHIFT_IMM_LSL(CPU_TLB_ENTRY_BITS));
if (mem_index)
tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R0, TCG_REG_R0,
(mem_index << (TLB_SHIFT & 1)) |
((16 - (TLB_SHIFT >> 1)) << 8));
tcg_out_ld32_12(s, COND_AL, TCG_REG_R1, TCG_REG_R0,
offsetof(CPUState, tlb_table[0][0].addr_read));
tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, TCG_REG_R1,
TCG_REG_R8, SHIFT_IMM_LSL(TARGET_PAGE_BITS));
if (s_bits)
tcg_out_dat_imm(s, COND_EQ, ARITH_TST,
0, addr_reg, (1 << s_bits) - 1);
# if TARGET_LONG_BITS == 64
tcg_out_ld32_12(s, COND_EQ, TCG_REG_R1, TCG_REG_R0,
offsetof(CPUState, tlb_table[0][0].addr_read) + 4);
tcg_out_dat_reg(s, COND_EQ, ARITH_CMP, 0,
TCG_REG_R1, addr_reg2, SHIFT_IMM_LSL(0));
# endif
tcg_out_ld32_12(s, COND_EQ, TCG_REG_R1, TCG_REG_R0,
offsetof(CPUState, tlb_table[0][0].addend));
switch (opc) {
case 0:
tcg_out_ld8_r(s, COND_EQ, data_reg, addr_reg, TCG_REG_R1);
break;
case 0 | 4:
tcg_out_ld8s_r(s, COND_EQ, data_reg, addr_reg, TCG_REG_R1);
break;
case 1:
tcg_out_ld16u_r(s, COND_EQ, data_reg, addr_reg, TCG_REG_R1);
if (bswap) {
tcg_out_bswap16(s, COND_EQ, data_reg, data_reg);
}
break;
case 1 | 4:
if (bswap) {
tcg_out_ld16u_r(s, COND_EQ, data_reg, addr_reg, TCG_REG_R1);
tcg_out_bswap16s(s, COND_EQ, data_reg, data_reg);
} else {
tcg_out_ld16s_r(s, COND_EQ, data_reg, addr_reg, TCG_REG_R1);
}
break;
case 2:
default:
tcg_out_ld32_r(s, COND_EQ, data_reg, addr_reg, TCG_REG_R1);
if (bswap) {
tcg_out_bswap32(s, COND_EQ, data_reg, data_reg);
}
break;
case 3:
if (bswap) {
tcg_out_ld32_rwb(s, COND_EQ, data_reg2, TCG_REG_R1, addr_reg);
tcg_out_ld32_12(s, COND_EQ, data_reg, TCG_REG_R1, 4);
tcg_out_bswap32(s, COND_EQ, data_reg2, data_reg2);
tcg_out_bswap32(s, COND_EQ, data_reg, data_reg);
} else {
tcg_out_ld32_rwb(s, COND_EQ, data_reg, TCG_REG_R1, addr_reg);
tcg_out_ld32_12(s, COND_EQ, data_reg2, TCG_REG_R1, 4);
}
break;
}
label_ptr = (void *) s->code_ptr;
tcg_out_b(s, COND_EQ, 8);
if (addr_reg != TCG_REG_R0) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R0, 0, addr_reg, SHIFT_IMM_LSL(0));
}
# if TARGET_LONG_BITS == 32
tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R1, 0, mem_index);
# else
if (addr_reg2 != TCG_REG_R1) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R1, 0, addr_reg2, SHIFT_IMM_LSL(0));
}
tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R2, 0, mem_index);
# endif
tcg_out_bl(s, COND_AL, (tcg_target_long) qemu_ld_helpers[s_bits] -
(tcg_target_long) s->code_ptr);
switch (opc) {
case 0 | 4:
tcg_out_ext8s(s, COND_AL, data_reg, TCG_REG_R0);
break;
case 1 | 4:
tcg_out_ext16s(s, COND_AL, data_reg, TCG_REG_R0);
break;
case 0:
case 1:
case 2:
default:
if (data_reg != TCG_REG_R0) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
data_reg, 0, TCG_REG_R0, SHIFT_IMM_LSL(0));
}
break;
case 3:
if (data_reg != TCG_REG_R0) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
data_reg, 0, TCG_REG_R0, SHIFT_IMM_LSL(0));
}
if (data_reg2 != TCG_REG_R1) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
data_reg2, 0, TCG_REG_R1, SHIFT_IMM_LSL(0));
}
break;
}
*label_ptr += ((void *) s->code_ptr - (void *) label_ptr - 8) >> 2;
#else
if (GUEST_BASE) {
uint32_t offset = GUEST_BASE;
int i;
int rot;
while (offset) {
i = ctz32(offset) & ~1;
rot = ((32 - i) << 7) & 0xf00;
tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R8, addr_reg,
((offset >> i) & 0xff) | rot);
addr_reg = TCG_REG_R8;
offset &= ~(0xff << i);
}
}
switch (opc) {
case 0:
tcg_out_ld8_12(s, COND_AL, data_reg, addr_reg, 0);
break;
case 0 | 4:
tcg_out_ld8s_8(s, COND_AL, data_reg, addr_reg, 0);
break;
case 1:
tcg_out_ld16u_8(s, COND_AL, data_reg, addr_reg, 0);
if (bswap) {
tcg_out_bswap16(s, COND_AL, data_reg, data_reg);
}
break;
case 1 | 4:
if (bswap) {
tcg_out_ld16u_8(s, COND_AL, data_reg, addr_reg, 0);
tcg_out_bswap16s(s, COND_AL, data_reg, data_reg);
} else {
tcg_out_ld16s_8(s, COND_AL, data_reg, addr_reg, 0);
}
break;
case 2:
default:
tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, 0);
if (bswap) {
tcg_out_bswap32(s, COND_AL, data_reg, data_reg);
}
break;
case 3:
if (data_reg == addr_reg) {
tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, bswap ? 0 : 4);
tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, bswap ? 4 : 0);
} else {
tcg_out_ld32_12(s, COND_AL, data_reg, addr_reg, bswap ? 4 : 0);
tcg_out_ld32_12(s, COND_AL, data_reg2, addr_reg, bswap ? 0 : 4);
}
if (bswap) {
tcg_out_bswap32(s, COND_AL, data_reg, data_reg);
tcg_out_bswap32(s, COND_AL, data_reg2, data_reg2);
}
break;
}
#endif
}
| 1threat |
Disable Angular 5 Input fields correct way : <p>I have a FormGroup that was created like that:</p>
<pre><code>form: FormGroup;
constructor(private _formBuilder: FormBuilder) { }
this.form = this._formBuilder.group({
name: ['', Validators.required],
email: ['', Validators.required, Validators.email]
});
</code></pre>
<p>When an event occurs I want to disable those inputs, so, in the HTML I added:</p>
<pre><code><input class="form-control" placeholder="Name" name="name" formControlName="name" [(ngModel)]="name" autocomplete="off" [disabled]="isDisabled" required>
<input class="form-control" placeholder="Email" name="email" formControlName="email" [(ngModel)]="email" email="true" autocomplete="off" [disabled]="isDisabled" required>
</code></pre>
<p>Where <code>isDisabled</code> is a variable I toggle to <code>true</code> when the said event happens.<br><br>
As you can imagine, I get the message:</p>
<blockquote>
<p>It looks like you're using the disabled attribute with a reactive form
directive. If you set disabled to true
when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
you. We recommend using this approach to avoid 'changed after checked' errors.</p>
<pre><code> Example:
form = new FormGroup({
first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
last: new FormControl('Drew', Validators.required)
});
</code></pre>
</blockquote>
<p>So, with the example this warning shows and with a little search I found that I should declare my controls like:</p>
<pre><code>name: [{ value: '', disabled: this.isDisabled }, Validators.required]
</code></pre>
<p>The problem is: <strong>It is not toggling between disabled/enabled when the variable changes between <code>true</code>/<code>false</code></strong><br><br>
How is the correct way of having a variable controlling if an input is enabled or disabled?</p>
<p>I don't want to do it manually (ex: <code>this.form.controls['name'].disable()</code>) because it doesn't seems a very reactive way, I would have to call it inside a good amount of methods. Probably not a good practice.</p>
<p>Thx</p>
| 0debug |
Spring Boot Localization issue - Accept-Language header : <p>We are using Spring Boot for the application. In ApplicationConfig.java I have the below code</p>
<pre><code> @Bean
public LocaleResolver localeResolver() {
return new SmartLocaleResolver();
}
</code></pre>
<p>and the SmartLocaleResolver.java is below</p>
<pre><code>public class SmartLocaleResolver extends SessionLocaleResolver {
@Override
public Locale resolveLocale(HttpServletRequest request) {
final String acceptLanguage = request.getHeader("Accept-Language");
if (acceptLanguage.contains(",")) {
String[] aheader = acceptLanguage.split(",[ ]*");
for (String locale : aheader) {
if (ApplicationConstants.LOCALE.contains(locale)) {
locale.trim();
return Locale.forLanguageTag(locale);
}
}
} else if (!acceptLanguage.contains(",") && !acceptLanguage.isEmpty()) {
if (ApplicationConstants.LOCALE.contains(acceptLanguage)) {
return Locale.forLanguageTag(acceptLanguage);
}
}
return request.getLocale();
}
}
</code></pre>
<p>and I have in my constants class the below to compare the value from header Accept-Language.</p>
<p>public static final List LOCALE = Collections
.unmodifiableList(Arrays.asList("en", "es"));</p>
<p>I know in actual scenario the header will be like
Accept-Language : fr,es;q=0.8,en-us;q=0.6 but for testing purpose i'm passing it as below.</p>
<p>Accept-language : fr,es,en</p>
<p>The code is not complete yet, but i'm just testing from postman to see if the code picks up "es" as the locale and gives me the localized result.</p>
<p>I don't have messages_fr.properties file but I have messages_es.properties so I expect if the application sets the locale from the below code, it would pick Locale as 'es' and give the values I want in Spanish. What changes I need to make here for the code to work? </p>
| 0debug |
Switch between vertical and horizontal stepper material : <p>How to switch between <strong>mat-vertical-stepper</strong> and <strong>mat-horizontal-stepper</strong> from angular component with same stepper steps?</p>
| 0debug |
static void FUNC(transquant_bypass32x32)(uint8_t *_dst, int16_t *coeffs,
ptrdiff_t stride)
{
int x, y;
pixel *dst = (pixel *)_dst;
stride /= sizeof(pixel);
for (y = 0; y < 32; y++) {
for (x = 0; x < 32; x++) {
dst[x] += *coeffs;
coeffs++;
}
dst += stride;
}
}
| 1threat |
Take ownership of parameter by rvalue-reference : <p>I want to make clear that the constructor of my class <code>A</code> will take ownership of the passed <code>Data</code> parameter. The obvious thing to do is take a <code>unique_ptr</code> by value:</p>
<pre><code>class A
{
public:
A(std::unique_ptr<Data> data) : _data(std::move(data)) { }
std::unique_ptr<Data> _data;
};
</code></pre>
<p>However, for my use-case, there is no reason why <code>Data</code> should be a pointer, since a value type would suffice. The only remaining option that I could think of to make really clear that <code>Data</code> will be owned by <code>A</code> is pass by rvalue-reference:</p>
<pre><code>class A
{
public:
A(Data&& data) : _data(std::move(data)) { }
Data _data;
};
</code></pre>
<p>Is this a valid way to signal ownership or are there better options to do this without using <code>unique_ptr</code>?</p>
| 0debug |
computer cannot be accessed after connecting Junos Pulse VPN : <p>I have 2 machines in LAN, one is desktop, the other is a laptop. Before I connecting vpn on laptop, the laptop IP is 192.168.1.104 and the desktop is 192.168.1.107, I can ping the laptop from my desktop. After I connecting Junos Pulse vpn, I saw the following with ipconfig /all:
10.148.184.192 (this is IP of VPN connection)
192.168.1.104 (this is IP of my LAN).
After the VPN is connected, I found I cannot ping or tracert my laptop (192.168.1.104) from my desktop (192.168.1.107). </p>
<p>Btw, the 2 machines have windows 7 installed.</p>
<p>Does anybody know why this could happen ? Is there any approach to connect my laptop from the desktop with the VPN connected ?</p>
<p>Below is my route table:</p>
<pre><code> **0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.104 27
0.0.0.0 0.0.0.0 在链路上 10.148.184.192 6**
10.148.184.192 255.255.255.255 在链路上 10.148.184.192 261
65.44.121.0 255.255.255.0 192.168.1.1 192.168.1.104 27
65.54.6.128 255.255.255.192 192.168.1.1 192.168.1.104 27
65.54.6.192 255.255.255.224 192.168.1.1 192.168.1.104 27
65.54.11.128 255.255.255.192 192.168.1.1 192.168.1.104 27
</code></pre>
| 0debug |
ASP.NET Core 2.0 disable automatic challenge : <p>After upgrading my ASP.NET Core project to 2.0, attempts to access protected endpoints no longer returns 401, but redirects to an (non-existing) endpoint in an attempt to let the user authenticate.</p>
<p>The desired behaviour is for the application simply to return a 401. Previously I would set <code>AutomaticChallenge = false</code> when configuring authentication, but according to <a href="https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?tabs=aspnetcore2x" rel="noreferrer">this article</a> the setting is no longer relevant (in fact it doesn't exist anymore).</p>
<p>My authentication is configured like this:</p>
<p>Startup.cs.ConfigureServices():</p>
<pre><code>services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(o =>
{
o.Cookie.Name = options.CookieName;
o.Cookie.Domain = options.CookieDomain;
o.SlidingExpiration = true;
o.ExpireTimeSpan = options.CookieLifetime;
o.TicketDataFormat = ticketFormat;
o.CookieManager = new CustomChunkingCookieManager();
});
</code></pre>
<p>Configure():</p>
<pre><code>app.UseAuthentication();
</code></pre>
<p>How can I disable automatic challenge, so that the application returns 401 when the user is not authenticated?</p>
| 0debug |
static void cpu_common_parse_features(const char *typename, char *features,
Error **errp)
{
char *featurestr;
char *val;
static bool cpu_globals_initialized;
if (cpu_globals_initialized) {
return;
}
cpu_globals_initialized = true;
featurestr = features ? strtok(features, ",") : NULL;
while (featurestr) {
val = strchr(featurestr, '=');
if (val) {
GlobalProperty *prop = g_new0(typeof(*prop), 1);
*val = 0;
val++;
prop->driver = typename;
prop->property = g_strdup(featurestr);
prop->value = g_strdup(val);
prop->errp = &error_fatal;
qdev_prop_register_global(prop);
} else {
error_setg(errp, "Expected key=value format, found %s.",
featurestr);
return;
}
featurestr = strtok(NULL, ",");
}
}
| 1threat |
All about Context: How to Use context? : <p>As a newbie I am trying to make an app thorough watching some tutorials. I am approaching further and getting more and more confused about "Context". About its definition as well as its contribution. Most puzzling part is when to put the "context" as a parameter.</p>
<p>Which types of classes take "context" as parameter?
What can/should I suppose to do with it?</p>
| 0debug |
Getting the next number in php : <p>I'm not sure what the easiest way to go about this is, I just want one button on a page called assign.</p>
<p>When you visit the page, it says 001, once you click assign, the page refreshes and it says 002 and so on. Do I need a DB to keep track of the current number? </p>
<p>Is there an easier way to do this with javascript that does not need a DB?</p>
| 0debug |
Selenium, combining css issue : <p>I'm having an issue with css ( cannot find the proper way how to write it)</p>
<pre><code><div class="d-flex flex-row align-items-center justify-content-end col-6">
<button disabled="" class="btn btn-primary disabled">'Text 1'</button>
<button disabled="" class="btn btn-primary disabled">'Text 2'</button>
<button disabled="" class="btn btn-primary disabled">'Text 3'</button>
<button disabled="" class="btn btn-primary disabled">'Text 4'</button>
<button disabled="" class="btn btn-primary disabled">'Text 5'</button>
<button disabled="" class="btn btn-primary disabled">'Text 6'</button>
</div>
</code></pre>
<p>How can I write it down if I want to select 'Text #3' for example?
And one more, how can I write down smth like <code>parrent[class='smth'] child['Text 3']</code></p>
| 0debug |
angular2 @input - change detection : <p>Is there a way to listen for @Input change?</p>
<p>In following example, I would like to be informed whenever 'inputData' value is changed.</p>
<pre><code>@Input() inputData: InputData;
</code></pre>
| 0debug |
Testing Google Cloud PubSub push endpoints locally : <p>Trying to figure out the best way to test PubSub push endpoints locally. We tried with ngrok.io, but you must own the domain in order to whitelist (the tool for doing so is also broken… resulting in an infinite redirect loop). We also tried emulating PubSub locally. I am able to publish and pull, but I cannot get the push subscriptions working. We are using a local Flask webserver like so:</p>
<pre><code>@app.route('/_ah/push-handlers/events', methods=['POST'])
def handle_message():
print request.json
return jsonify({'ok': 1}), 200
</code></pre>
<p>The following produces no result:</p>
<pre><code>client = pubsub.Client()
topic = client('events')
topic.create()
subscription = topic.subscription('test_push', push_endpoint='http://localhost:5000/_ah/push-handlers/events')
subscription.create()
topic.publish('{"test": 123}')
</code></pre>
<p>It does yell at us when we attempt to create a subscription to an HTTP endpoint (whereas live PubSub will if you do not use HTTPS). Perhaps this is by design? Pull works just fine… Any ideas on how to best develop PubSub push endpoints locally?</p>
| 0debug |
C++ - Convert Hex to DIN-Code : so first of all, I wanted to thank this Community. This Forum helped me a lot over years. Now it was time to register. So I need help.
I want convert a HEX-Code to a DIN-Code. The calculation is in the picture below.
The Hex-Code gets converted to Binary-Code. After that, it will get reversed bytewise and converted to DEC halfbyte-wise.
I have problems here. Eventhough I would have done a solution to this, it still would be really inefficent. So please support me. Maybe you can give me hints, on which functions too look at.
Thank you so much!
[Image - HEX to DIN][1]
[1]: http://i.stack.imgur.com/azUTp.jpg | 0debug |
static int init_tiles(Jpeg2000EncoderContext *s)
{
int tileno, tilex, tiley, compno;
Jpeg2000CodingStyle *codsty = &s->codsty;
Jpeg2000QuantStyle *qntsty = &s->qntsty;
s->numXtiles = ff_jpeg2000_ceildiv(s->width, s->tile_width);
s->numYtiles = ff_jpeg2000_ceildiv(s->height, s->tile_height);
s->tile = av_malloc_array(s->numXtiles, s->numYtiles * sizeof(Jpeg2000Tile));
if (!s->tile)
return AVERROR(ENOMEM);
for (tileno = 0, tiley = 0; tiley < s->numYtiles; tiley++)
for (tilex = 0; tilex < s->numXtiles; tilex++, tileno++){
Jpeg2000Tile *tile = s->tile + tileno;
tile->comp = av_mallocz_array(s->ncomponents, sizeof(Jpeg2000Component));
if (!tile->comp)
return AVERROR(ENOMEM);
for (compno = 0; compno < s->ncomponents; compno++){
Jpeg2000Component *comp = tile->comp + compno;
int ret, i, j;
comp->coord[0][0] = comp->coord_o[0][0] = tilex * s->tile_width;
comp->coord[0][1] = comp->coord_o[0][1] = FFMIN((tilex+1)*s->tile_width, s->width);
comp->coord[1][0] = comp->coord_o[1][0] = tiley * s->tile_height;
comp->coord[1][1] = comp->coord_o[1][1] = FFMIN((tiley+1)*s->tile_height, s->height);
if (compno > 0)
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
comp->coord[i][j] = comp->coord_o[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j], s->chroma_shift[i]);
if (ret = ff_jpeg2000_init_component(comp,
codsty,
qntsty,
s->cbps[compno],
compno?1<<s->chroma_shift[0]:1,
compno?1<<s->chroma_shift[1]:1,
s->avctx
))
return ret;
}
}
return 0;
}
| 1threat |
java.lang.NoClassDefFoundError: com/ibm/as400/access/AS400 : <p>[9/7/18 10:38:02:453 EDT] 000000b3 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service Uncaught service() exception thrown by servlet action: java.lang.NoClassDefFoundError: com/ibm/as400/access/AS400
at com.bb.sweb.actions.Authenticate.execute(Authenticate.java:37)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1238)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:782)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:481)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1114)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4028)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1016)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:287)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)</p>
| 0debug |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
invalid syntax for from import random WHY : when i try to run this module
from import random
def guessnum():
randomnum = random.randint(1,6)
awnser = input ("what do you think the number is? ")
if awnser==randomnum:
print ("good job. you are correct. ")
else:
print ("incorrect. better luck next time. ")
restart = input ("would you like to try again? ")
if restart = Yes or y:
guessnum()
else:
end()
i get invalid syntax highlighting the import. why is this.
i have already tried `import random` but it doesn't seem to want to work | 0debug |
static int64_t mmsh_seek(URLContext *h, int64_t pos, int whence)
{
MMSHContext *mmsh = h->priv_data;
MMSContext *mms = &mmsh->mms;
if(pos == 0 && whence == SEEK_CUR)
return mms->asf_header_read_size + mms->remaining_in_len + mmsh->chunk_seq * mms->asf_packet_len;
return AVERROR(ENOSYS);
}
| 1threat |
How can I get `sed`-like behavior from within python when running windows? : The beginnings of a solution are shown below. If someone would complete it and get it working, I would be eternally grateful.
import subprocess
import os
import sys
def sed(stryng, istream=None, ostream=None):
if sys.platform == "linux":
subprocess.run(["sed", stryng])
subprocess.call(['sed', 's/\"//g', inp], stdout=out_file)
elif os.name == 'nt':
# if running Windows
lead_up = "@ powershell - Command get-content somefile.txt | %{{$_ -replace "
expression = ""
replacement = ""
subprocess.run(lead_up + f"\"\"{expression}\",\"{replacement}\"}}")
else:
raise NotImplementedError()
Usage:
in_file = open("report_new.txt", "r")
out_file = open("report_new.txt", "w")
sed("'s/Nick/John/g'", in_file, out_file)
out_file.close()
in_file.close() | 0debug |
PgAdmin 4: Cannot edit rows from one table : <p>Something strange is happening with my new created tables in Postgres, I can add data to them, but I cannot use PgAdmin to edit the any row.</p>
<p>This is my table columns description:</p>
<p><a href="https://i.stack.imgur.com/SsbdF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SsbdF.png" alt="Table columns"></a></p>
<p>After executing the query to view all table rows this is what I can see:</p>
<p><a href="https://i.stack.imgur.com/NlF9M.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NlF9M.png" alt="Right click at the table"></a></p>
<p><a href="https://i.stack.imgur.com/ixqzq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ixqzq.png" alt="At the Data Output"></a></p>
<p>Save button is disabled to update my table rows. But this is happening only with my new created tables, as you can see, I have other tables where I'm able to edit rows, for example at this table of Users:</p>
<p><a href="https://i.stack.imgur.com/SJFOr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SJFOr.png" alt="Other table that is able to edit data"></a></p>
| 0debug |
static void net_socket_receive_dgram(void *opaque, const uint8_t *buf, size_t size)
{
NetSocketState *s = opaque;
sendto(s->fd, buf, size, 0,
(struct sockaddr *)&s->dgram_dst, sizeof(s->dgram_dst));
}
| 1threat |
void colo_do_failover(MigrationState *s)
{
if (!colo_runstate_is_stopped()) {
vm_stop_force_state(RUN_STATE_COLO);
}
if (get_colo_mode() == COLO_MODE_PRIMARY) {
primary_vm_do_failover();
}
} | 1threat |
Recursive Bool Function "skipping" return : <p>I've been breaking off the rust with C coding, and have been working on an exercise in sorting and searching; in particular, binary searching using recursion. I am getting unexpected results, as when my binary search function does find the value it's looking for, it "should" return true, but instead skips to the final possible "return false" instruction. In the below, I've shared the code, as well as printed output to demonstrate how a particular value in a sorted array is identified, yet still resulting in a 'false' being returned.</p>
<p>There is one exception to all this... If the searched for value happens to be the midpoint value contained in the middle element of the entire, original array, such that its found during the very first execution of the binSearch function, it returns true as expected. It is only when subsequent recursive calls are made that a successful find still results in a return false to the function that calls the binary search function.</p>
<p>Code as follows;passed array is already sorted least to greatest:</p>
<pre><code>bool binSearch(int value, int values[], int up, int down)
{
int midElement = (up-down)/2 + down;
int midValue = values[midElement];
printf("Midvalue now equals: %i\n", midValue);
if(up >= down)
{
if(value == midValue)
{
printf("Found '%i' at element '%i': ", midValue, midElement);
return true; //This gets skipped, even when printf shows the find
}
else if(value > midValue)
binSearch(value, values, up, midElement+1);
else if(value < midValue)
binSearch(value, values, midElement-1, down);
}
return false;
}
</code></pre>
<p>Sample Output -- Note that "Didn't find the value" is what the function that calls binSearch will printout if its receives a false.</p>
<pre><code>Current Value: 1222
Current Value: 9601
Current Value: 46592
Current Value: 64187
Current Value: 64657
Midvalue now equals: 46592
Midvalue now equals: 1222
Midvalue now equals: 9601
Found '9601' at element '1'
Didn't find the value.
</code></pre>
<p>Sample output when the searched for value is in the middle of the entire array -- This is the one exception where true is returned as expected.</p>
<pre><code>Current Value: 1222
Current Value: 9601
Current Value: 46592
Current Value: 64187
Current Value: 64657
Midvalue now equals: 46592
Found '46592' at element '2':
Found the value.
</code></pre>
<p>I'm theorizing that there must be some problem with how results from 2nd generation onward recursive function calls are getting passed to the original caller (or rather, not getting passed back at all)...</p>
<p>Thank you for any insights into what might be happening here.</p>
| 0debug |
Visual Studio 2017 15.7 New Chrome Window when debugging : <p>Just updated to 15.7 and now when I begin debugging Chrome opens in new window.</p>
<p>My JS debugging is off (tried turning it on and back off) and unlike when it's on the new window is under my standard Chrome profile. However If I snap the chrome window into my other window debugging ends immediately.</p>
<p>Any ideas on how to correct this?</p>
| 0debug |
Why would webpack 4 generate files named 0.js, 1.js 2.js? : <p>In my attempts to switch from webpack 3 to 4, I use a configuration that simplified looks like the following extract.
The build is successful but generates some chunks that have only a number a filename and I cannot seem to understand why?</p>
<pre><code>0.css 12.5 KiB 0 [emitted]
0.js 312 KiB 0 [emitted]
1.js 90.3 KiB 1 [emitted]
2.js 109 KiB 2 [emitted]
3.js 647 KiB 3 [emitted]
4.js 1.14 MiB 4 [emitted]
5.css 33.5 KiB 5 [emitted]
5.js 1.56 MiB 5 [emitted]
6.css 602 bytes 6 [emitted]
6.js 92.8 KiB 6 [emitted]
</code></pre>
<p>configuration:</p>
<pre><code>const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = function (env, options) {
const PRODUCTION = options.mode === 'production';
return {
entry: {
common: ['libA', 'libB', './common/A.js', './common/A.js', /* ... */],
pageA: ['./src/pageA/file1.js', './src/pageA/file2.js', /* ... */],
pageB: ['./src/pageB/file1.js', './src/pageB/file2.js', /* ... */],
/* ... */
},
output: {
path: path.resolve('./dist'),
filename: `[name]${PRODUCTION ? '.min' : ''}.js`,
chunkFilename: `[name]${PRODUCTION ? '.min' : ''}.js`,
libraryTarget: 'var'
},
module: {
rules: [
{
test: /\.js$/i,
include: /src/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/i,
include: /src/,
exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: false,
importLoaders: 1
}
}
]
},
/* ... */
]
},
plugins: [
new MiniCssExtractPlugin({
filename: `[name].${PRODUCTION ? 'min.css' : 'css'}`,
chunkFilename: `[name].${PRODUCTION ? 'min.css' : 'css'}`
})
],
optimization: {
splitChunks: {
chunks: 'initial',
name: false,
cacheGroups: {
common: {
test: true,
name: 'common',
chunks: 'initial',
minSize: 0,
minChunks: 10,
reuseExistingChunk: true,
enforce: true
}
}
}
}
};
};
</code></pre>
| 0debug |
void palette8tobgr15(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
{
long i;
for(i=0; i<num_pixels; i++)
((uint16_t *)dst)[i] = bswap_16(((uint16_t *)palette)[ src[i] ]);
}
| 1threat |
get error code 400 when send request on stripe for get token : This is My Object for get bank account token
this.myObject= {
country: 'US',
currency: 'usd',
routing_number: '110000000',
account_number: '000123456789',
account_holder_name: 'Jenny Rosen',
account_holder_type: 'individual',
};
This is my function to get the token from stripe...
How can i get bank account token from stripe
`getTokenOFBankAccount(myObject: any): Observable<any> {
this.spinner.show();
const headers = {
headers: new HttpHeaders({Authorization: "Bearer "+
environment.stripeToken,
"Content-Type": "application/x-www-form-urlencoded"})
}
return this.http
.post<any>("https://api.stripe.com/v1/tokens", myObject, headers)
.pipe(
tap(response => {
debugger;
this.spinner.hide();
if (response["status"] === "successful") {
} else {
}
})
);
}`
How can i get Bank account token from Stripe. what is the best way to get
Bank account token from Stripe. How can i get Bank account token from
Stripe. what is the best way to get
Bank account token from Stripe.
| 0debug |
Multiple Slick Sliders Issue : <p>I am using Slick.js plugin with its Slider Syncing feature. The issue I am having is that if I use multiple sliders on a single page, by clicking next or prev buttons plugin performs the action for all sliders on page. I wonder is there anything I could do with JQuery to have the next and prev work for each slider on page not for all? Thanks in advance. </p>
<p>HTML</p>
<pre><code><div class="slider">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>
<div class="slider-nav">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>
</code></pre>
<p>SLICK RUN SCRIPT</p>
<pre><code>$('.slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
fade: true,
asNavFor: '.slider-nav'
});
$('.slider-nav').slick({
slidesToShow: 4,
slidesToScroll: 1,
asNavFor: '.slider',
dots: true,
arrows: true,
centerMode: false,
focusOnSelect: true
});
</code></pre>
| 0debug |
void mips_r4k_init (ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
char *filename;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios;
MemoryRegion *iomem = g_new(MemoryRegion, 1);
int bios_size;
CPUState *env;
ResetData *reset_info;
int i;
qemu_irq *i8259;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *dinfo;
int be;
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "R4000";
#else
cpu_model = "24Kf";
#endif
}
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
reset_info = g_malloc0(sizeof(ResetData));
reset_info->env = env;
reset_info->vector = env->active_tc.PC;
qemu_register_reset(main_cpu_reset, reset_info);
if (ram_size > (256 << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_init_ram(ram, NULL, "mips_r4k.ram", ram_size);
memory_region_add_subregion(address_space_mem, 0, ram);
memory_region_init_io(iomem, &mips_qemu_ops, NULL, "mips-qemu", 0x10000);
memory_region_add_subregion(address_space_mem, 0x1fbf0000, iomem);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = get_image_size(filename);
} else {
bios_size = -1;
}
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) {
bios = g_new(MemoryRegion, 1);
memory_region_init_ram(bios, NULL, "mips_r4k.bios", BIOS_SIZE);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(get_system_memory(), 0x1fc00000, bios);
load_image_targphys(filename, 0x1fc00000, BIOS_SIZE);
} else if ((dinfo = drive_get(IF_PFLASH, 0, 0)) != NULL) {
uint32_t mips_rom = 0x00400000;
if (!pflash_cfi01_register(0x1fc00000, NULL, "mips_r4k.bios", mips_rom,
dinfo->bdrv, sector_len,
mips_rom / sector_len,
4, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
}
}
else {
fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n",
bios_name);
}
if (filename) {
g_free(filename);
}
if (kernel_filename) {
loaderparams.ram_size = ram_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
reset_info->vector = load_kernel();
}
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
i8259 = i8259_init(env->irq[2]);
isa_bus_new(NULL, get_system_io());
isa_bus_irqs(i8259);
rtc_init(2000, NULL);
isa_mmio_init(0x14000000, 0x00010000);
isa_mem_base = 0x10000000;
pit = pit_init(0x40, 0);
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
serial_isa_init(i, serial_hds[i]);
}
}
isa_vga_init();
if (nd_table[0].vlan)
isa_ne2000_init(0x300, 9, &nd_table[0]);
ide_drive_get(hd, MAX_IDE_BUS);
for(i = 0; i < MAX_IDE_BUS; i++)
isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[MAX_IDE_DEVS * i],
hd[MAX_IDE_DEVS * i + 1]);
isa_create_simple("i8042");
}
| 1threat |
How to write JSON inside of java : <p>i have a JSON string and i want to write it as a JSON file(.json) inside of java. because my final application needs to import .json file not a string. (i am using spring to create a web app)</p>
<p>this is my json string:</p>
<pre><code>String str = "{"polygons": {"landuse": ["__any__"],"building": ["__any__"],"shop": ["__any__"]}}";
</code></pre>
<p>and i want a file (str.json) inside of my java webapp not saving to pc and then importing.</p>
<p>do you have solution for this task? </p>
<p>thanks </p>
| 0debug |
Add Facebook like button after all image in string : <p>How can I add facebook like button, after all image in string.</p>
<p>For example:</p>
<pre><code><p>This is some text. This is some text. This is image: <img src='url'/>. This is some tekst. This is new image: <img src='url'></p>
</code></pre>
<p>I want change to this:</p>
<pre><code><p>This is some text. This is some text. This is image: <img src='url'/><facebook like buuton>. This is some tekst. This is new image: <img src='url'> <facebook like button></p>
</code></pre>
| 0debug |
int s390_cpu_restart(S390CPU *cpu)
{
if (kvm_enabled()) {
return kvm_s390_cpu_restart(cpu);
}
return -ENOSYS;
}
| 1threat |
static inline void gen_evmergehilo(DisasContext *ctx)
{
if (unlikely(!ctx->spe_enabled)) {
gen_exception(ctx, POWERPC_EXCP_APU);
return;
}
#if defined(TARGET_PPC64)
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
tcg_gen_ext32u_tl(t0, cpu_gpr[rB(ctx->opcode)]);
tcg_gen_andi_tl(t1, cpu_gpr[rA(ctx->opcode)], 0xFFFFFFFF0000000ULL);
tcg_gen_or_tl(cpu_gpr[rD(ctx->opcode)], t0, t1);
tcg_temp_free(t0);
tcg_temp_free(t1);
#else
tcg_gen_mov_i32(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
tcg_gen_mov_i32(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]);
#endif
}
| 1threat |
static int32_t read_s32(uint8_t *data, size_t offset)
{
return (int32_t)((data[offset] << 24) | (data[offset + 1] << 16) |
(data[offset + 2] << 8) | data[offset + 3]);
}
| 1threat |
Mapstruct - How can I inject a spring dependency in the Generated Mapper class : <p>I need to inject a spring service class in the generated mapper implementation, so that I can use it via </p>
<pre><code> @Mapping(target="x", expression="java(myservice.findById(id))")"
</code></pre>
<p>Is this applicable in Mapstruct-1.0?</p>
| 0debug |
I am a beginner in programming and currently learning Ruby. Can't figure this out. Could someone solve? : You are given a string S Count the number of occurrences of all the digits in the string S.
Input:
First line contains string S
Output:
Count the number of occurences of 1 in the entered number and print the output.
I tried to attempt the given problem like this:
number=$stdin.gets.chomp
number.split('').map(&:to_i)
number.each do |numbers|
i==0
while numbers===1
i+=1
end
end
puts i
But, its not executing.
Can someone please suggest how to do it? | 0debug |
static int decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src){
H264Context *h= dst->priv_data, *h1= src->priv_data;
MpegEncContext * const s = &h->s, * const s1 = &h1->s;
int inited = s->context_initialized, err;
int i;
if(dst == src || !s1->context_initialized) return 0;
err = ff_mpeg_update_thread_context(dst, src);
if(err) return err;
if(!inited){
for(i = 0; i < MAX_SPS_COUNT; i++)
av_freep(h->sps_buffers + i);
for(i = 0; i < MAX_PPS_COUNT; i++)
av_freep(h->pps_buffers + i);
memcpy(&h->s + 1, &h1->s + 1, sizeof(H264Context) - sizeof(MpegEncContext));
memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
if (ff_h264_alloc_tables(h) < 0) {
av_log(dst, AV_LOG_ERROR, "Could not allocate memory for h264\n");
return AVERROR(ENOMEM);
}
context_init(h);
for(i=0; i<2; i++){
h->rbsp_buffer[i] = NULL;
h->rbsp_buffer_size[i] = 0;
}
h->thread_context[0] = h;
h->s.obmc_scratchpad = av_malloc(16*6*s->linesize);
s->dsp.clear_blocks(h->mb);
s->dsp.clear_blocks(h->mb+(24*16<<h->pixel_shift));
}
h->is_avc = h1->is_avc;
copy_parameter_set((void**)h->sps_buffers, (void**)h1->sps_buffers, MAX_SPS_COUNT, sizeof(SPS));
h->sps = h1->sps;
copy_parameter_set((void**)h->pps_buffers, (void**)h1->pps_buffers, MAX_PPS_COUNT, sizeof(PPS));
h->pps = h1->pps;
copy_fields(h, h1, dequant4_buffer, dequant4_coeff);
for(i=0; i<6; i++)
h->dequant4_coeff[i] = h->dequant4_buffer[0] + (h1->dequant4_coeff[i] - h1->dequant4_buffer[0]);
for(i=0; i<6; i++)
h->dequant8_coeff[i] = h->dequant8_buffer[0] + (h1->dequant8_coeff[i] - h1->dequant8_buffer[0]);
h->dequant_coeff_pps = h1->dequant_coeff_pps;
copy_fields(h, h1, poc_lsb, redundant_pic_count);
copy_fields(h, h1, ref_count, list_count);
copy_fields(h, h1, ref_list, intra_gb);
copy_fields(h, h1, short_ref, cabac_init_idc);
copy_picture_range(h->short_ref, h1->short_ref, 32, s, s1);
copy_picture_range(h->long_ref, h1->long_ref, 32, s, s1);
copy_picture_range(h->delayed_pic, h1->delayed_pic, MAX_DELAYED_PIC_COUNT+2, s, s1);
h->last_slice_type = h1->last_slice_type;
h->sync = h1->sync;
if(!s->current_picture_ptr) return 0;
if(!s->dropable) {
err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
h->prev_poc_msb = h->poc_msb;
h->prev_poc_lsb = h->poc_lsb;
}
h->prev_frame_num_offset= h->frame_num_offset;
h->prev_frame_num = h->frame_num;
h->outputed_poc = h->next_outputed_poc;
return err;
}
| 1threat |
How to implement a single item for a linked list class? C++ homework : I'm extremely new to C++, so I wanted to get some help on a homework problem that I've been working on for the past few hours. The criteria of the problem is this:
In the problems below, we will be implementing a list of "items." In this problem, we will create an Item class for this purpose.
To make things a little interesting, we will have two components to our Item: (1) an integer key and (2) a literal string value.
Your class must include:
[2.5 pts] Private member variables for the key (int) and value (const char *). Don't allocate space for the string -- just keep a pointer.
[2.5 pts] A public constructor that initializes the key and value. Again, don't copy the string that is passed in -- just save the pointer.
[2.5 pts] Public methods to read the key and value -- e.g., getKey(), getValue().
[2.5 pts] A public copy constructor.
I'm extremely confused on how to implement the third and the fourth bullet point. I'll attach my code below, if any of you guys could tell me what I'm doing wrong or how I go about implementing these parts that would be awesome. The reason I'm confused is because I'm not exactly sure what they are designed to do.
class Item {
Private:
int key;
const char* point;
Public:
Item(int key, char* point); //I'm not sure when to put brackets after a constructor? The examples given are usually pretty vague.
getKey(key); //What do these do? We never went over these in class? What is the point?
getValue(point);
Item(const Item &new) {
key = new.key;
value = new.imaginary;
}
};
Like I said, I am very, very new to C++, so any pointers would be helpful. Thank you so much!
| 0debug |
static void ide_set_signature(IDEState *s)
{
s->select &= 0xf0;
s->nsector = 1;
s->sector = 1;
if (s->drive_kind == IDE_CD) {
s->lcyl = 0x14;
s->hcyl = 0xeb;
} else if (s->bs) {
s->lcyl = 0;
s->hcyl = 0;
} else {
s->lcyl = 0xff;
s->hcyl = 0xff;
}
}
| 1threat |
js pass object to callback function : <p>I would like to reference the item object in the geocoder callback function.
Item always refers to the state of the last $each iteration, if I use the code below. I assume this is because the callback is run after the $each loop finishes. I would therefore need to pass the item object to the geocoder. How can I do that?</p>
<pre><code> $.each(results.data, function(index) {
var item = results.data[index];
geocoder.geocode( { 'address': address}, function(results, status) {
item.lat = results[0].geometry.location.lat();
item.lng = results[0].geometry.location.lng();
});
});
</code></pre>
| 0debug |
Command prompt to check TLS version required by a host : <p>Is there a command to check the TLS version reuired by a host site. Right now, the only way I know to check is by adjusting the max TLS version of my browser and checking if I can still access the site. However, I suspect there is a more sophisticated way to do this.</p>
| 0debug |
Convert Hex to Hex with base 2 python : <p>How i convert number HEX with base 1 (0x1) to base 2 (0x01).</p>
<p>Hex_B1 = 0x1
Hex_B2 = 0x01</p>
<p>hex(int('110', 2)) = 0x06</p>
| 0debug |
static void s390_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
S390CPU *cpu = S390_CPU(obj);
CPUS390XState *env = &cpu->env;
static bool inited;
static int cpu_num = 0;
#if !defined(CONFIG_USER_ONLY)
struct tm tm;
#endif
cs->env_ptr = env;
cpu_exec_init(env);
#if !defined(CONFIG_USER_ONLY)
qemu_register_reset(s390_cpu_machine_reset_cb, cpu);
qemu_get_timedate(&tm, 0);
env->tod_offset = TOD_UNIX_EPOCH +
(time2tod(mktimegm(&tm)) * 1000000000ULL);
env->tod_basetime = 0;
env->tod_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_tod_timer, cpu);
env->cpu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu);
s390_cpu_set_state(CPU_STATE_STOPPED, cpu);
#endif
env->cpu_num = cpu_num++;
env->ext_index = -1;
if (tcg_enabled() && !inited) {
inited = true;
s390x_translate_init();
}
}
| 1threat |
static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name,
int flags, FsCred *credp, V9fsFidOpenState *fs)
{
char *path;
int fd = -1;
int err = -1;
int serrno = 0;
V9fsString fullname;
char buffer[PATH_MAX];
flags |= O_NOFOLLOW;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
path = fullname.data;
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
fd = open(rpath(fs_ctx, path, buffer), flags, SM_LOCAL_MODE_BITS);
if (fd == -1) {
err = fd;
goto out;
}
credp->fc_mode = credp->fc_mode|S_IFREG;
err = local_set_xattr(rpath(fs_ctx, path, buffer), credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
fd = open(rpath(fs_ctx, path, buffer), flags, SM_LOCAL_MODE_BITS);
if (fd == -1) {
err = fd;
goto out;
}
credp->fc_mode = credp->fc_mode|S_IFREG;
err = local_set_mapped_file_attr(fs_ctx, path, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
(fs_ctx->export_flags & V9FS_SM_NONE)) {
fd = open(rpath(fs_ctx, path, buffer), flags, credp->fc_mode);
if (fd == -1) {
err = fd;
goto out;
}
err = local_post_create_passthrough(fs_ctx, path, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
}
err = fd;
fs->fd = fd;
goto out;
err_end:
close(fd);
remove(rpath(fs_ctx, path, buffer));
errno = serrno;
out:
v9fs_string_free(&fullname);
return err;
}
| 1threat |
static uint64_t pxa2xx_fir_read(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxFIrState *s = (PXA2xxFIrState *) opaque;
uint8_t ret;
switch (addr) {
case ICCR0:
return s->control[0];
case ICCR1:
return s->control[1];
case ICCR2:
return s->control[2];
case ICDR:
s->status[0] &= ~0x01;
s->status[1] &= ~0x72;
if (s->rx_len) {
s->rx_len --;
ret = s->rx_fifo[s->rx_start ++];
s->rx_start &= 63;
pxa2xx_fir_update(s);
return ret;
}
printf("%s: Rx FIFO underrun.\n", __FUNCTION__);
break;
case ICSR0:
return s->status[0];
case ICSR1:
return s->status[1] | (1 << 3);
case ICFOR:
return s->rx_len;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| 1threat |
static DWORD WINAPI do_suspend(LPVOID opaque)
{
GuestSuspendMode *mode = opaque;
DWORD ret = 0;
if (!SetSuspendState(*mode == GUEST_SUSPEND_MODE_DISK, TRUE, TRUE)) {
slog("failed to suspend guest, %s", GetLastError());
ret = -1;
}
g_free(mode);
return ret;
}
| 1threat |
static char *qemu_rbd_parse_clientname(const char *conf, char *clientname)
{
const char *p = conf;
while (*p) {
int len;
const char *end = strchr(p, ':');
if (end) {
len = end - p;
} else {
len = strlen(p);
}
if (strncmp(p, "id=", 3) == 0) {
len -= 3;
strncpy(clientname, p + 3, len);
clientname[len] = '\0';
return clientname;
}
if (end == NULL) {
break;
}
p = end + 1;
}
return NULL;
}
| 1threat |
Play local Video in webview : <p>I want to play local videos in crosswalk webview. I'm getting the video path from an intent opening my activity, so it could be stored internally or on sd card. </p>
<p>Using this url <code>file:///storage/emulated/0/Download/movies/movie.mp4</code> i get <code>Failed to load resource: net::ERR_ACCESS_DENIED</code>.</p>
<p>Using input file dialog with <code>URL.createObjectURL(file);</code> it works. But because i know the path, i dont want to select it again manually. Setting the value of input file is forbidden.</p>
<p>Creating a url using the path is also not possible, because it needs file or blob.</p>
<p>Because of possible big filesize its not possible to temporarily copy it to sd card.</p>
<p>This gives me file not found error:</p>
<pre><code>@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view,
String url) {
if(url.contains("file:///storage")){
try {
return new WebResourceResponse("video/*", "UTF-8", new FileInputStream(url));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
return super.shouldInterceptLoadRequest(view, url);
}
</code></pre>
<p>also i have defined <code><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /></code></p>
<p>other questions on stackoverflow asking for accessing assets, so i created this new question</p>
| 0debug |
static void dec_mul(DisasContext *dc)
{
TCGv d[2];
unsigned int subcode;
if ((dc->tb_flags & MSR_EE_FLAG)
&& !(dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
&& !(dc->env->pvr.regs[0] & PVR0_USE_HW_MUL_MASK)) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);
t_gen_raise_exception(dc, EXCP_HW_EXCP);
return;
}
subcode = dc->imm & 3;
d[0] = tcg_temp_new();
d[1] = tcg_temp_new();
if (dc->type_b) {
LOG_DIS("muli r%d r%d %x\n", dc->rd, dc->ra, dc->imm);
t_gen_mulu(cpu_R[dc->rd], d[1], cpu_R[dc->ra], *(dec_alu_op_b(dc)));
goto done;
}
if (subcode >= 1 && subcode <= 3
&& !((dc->env->pvr.regs[2] & PVR2_USE_MUL64_MASK))) {
}
switch (subcode) {
case 0:
LOG_DIS("mul r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_mulu(cpu_R[dc->rd], d[1], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 1:
LOG_DIS("mulh r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_muls(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 2:
LOG_DIS("mulhsu r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_muls(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 3:
LOG_DIS("mulhu r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_mulu(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
default:
cpu_abort(dc->env, "unknown MUL insn %x\n", subcode);
break;
}
done:
tcg_temp_free(d[0]);
tcg_temp_free(d[1]);
}
| 1threat |
Can you set rounded pixel corners in Photoshop? : <p>I'm making a pixel art that's why my canvas is only 30x60 pixels, and I don't think using a rectangle shape will work because the canvas is just too small and I only need one pixel to have a rounded corner.</p>
| 0debug |
Testing post method of java web service : <p>Please anyone give me a clear understanding of why web service with post request cannot be run by putting the url in the browser unlike get method.
I tried running the url in the browser for post method,but it didn't display anything.But when i tried it on SoapUI, I got my desired result.
Any help would be appreciable.</p>
| 0debug |
def check_k_elements(test_list, K):
res = True
for tup in test_list:
for ele in tup:
if ele != K:
res = False
return (res) | 0debug |
static int sd_create(const char *filename, QemuOpts *opts,
Error **errp)
{
int ret = 0;
uint32_t vid = 0;
char *backing_file = NULL;
char *buf = NULL;
BDRVSheepdogState *s;
char tag[SD_MAX_VDI_TAG_LEN];
uint32_t snapid;
bool prealloc = false;
s = g_malloc0(sizeof(BDRVSheepdogState));
memset(tag, 0, sizeof(tag));
if (strstr(filename, ":
ret = sd_parse_uri(s, filename, s->name, &snapid, tag);
} else {
ret = parse_vdiname(s, filename, s->name, &snapid, tag);
}
if (ret < 0) {
error_setg(errp, "Can't parse filename");
goto out;
}
s->inode.vdi_size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
if (!buf || !strcmp(buf, "off")) {
prealloc = false;
} else if (!strcmp(buf, "full")) {
prealloc = true;
} else {
error_setg(errp, "Invalid preallocation mode: '%s'", buf);
ret = -EINVAL;
goto out;
}
g_free(buf);
buf = qemu_opt_get_del(opts, BLOCK_OPT_REDUNDANCY);
if (buf) {
ret = parse_redundancy(s, buf);
if (ret < 0) {
error_setg(errp, "Invalid redundancy mode: '%s'", buf);
goto out;
}
}
if (s->inode.vdi_size > SD_MAX_VDI_SIZE) {
error_setg(errp, "too big image size");
ret = -EINVAL;
goto out;
}
if (backing_file) {
BlockDriverState *bs;
BDRVSheepdogState *base;
BlockDriver *drv;
drv = bdrv_find_protocol(backing_file, true);
if (!drv || strcmp(drv->protocol_name, "sheepdog") != 0) {
error_setg(errp, "backing_file must be a sheepdog image");
ret = -EINVAL;
goto out;
}
bs = NULL;
ret = bdrv_open(&bs, backing_file, NULL, NULL, BDRV_O_PROTOCOL, NULL,
errp);
if (ret < 0) {
goto out;
}
base = bs->opaque;
if (!is_snapshot(&base->inode)) {
error_setg(errp, "cannot clone from a non snapshot vdi");
bdrv_unref(bs);
ret = -EINVAL;
goto out;
}
s->inode.vdi_id = base->inode.vdi_id;
bdrv_unref(bs);
}
s->aio_context = qemu_get_aio_context();
ret = do_sd_create(s, &vid, 0, errp);
if (ret) {
goto out;
}
if (prealloc) {
ret = sd_prealloc(filename, errp);
}
out:
g_free(backing_file);
g_free(buf);
g_free(s);
return ret;
}
| 1threat |
Mousedown on appended items : <p>The function below toggles the highlight on a cell when a user clicks the cell.</p>
<p>It works well if the cells are there when the document loads. However, it does not work on newly appended cells.</p>
<p>What could I change to make it work for new cells?</p>
<pre><code> $(function () {
var isMouseDown = false,
isHighlighted;
$("#tablegrid td.nohighlight")
.mousedown(function () {
isMouseDown = true;
$(this).toggleClass("highlighted");
isHighlighted = $(this).hasClass("highlighted");
return false; // prevent text selection
})
.mouseover(function () {
if (isMouseDown) {
$(this).toggleClass("highlighted", isHighlighted);
}
})
.bind("selectstart", function () {
return false;
})
$(document)
.mouseup(function () {
isMouseDown = false;
});
});
</code></pre>
| 0debug |
static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUMBState *env)
{
struct target_signal_frame *frame;
abi_ulong frame_addr;
int err = 0;
int i;
frame_addr = get_sigframe(ka, env, sizeof *frame);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto badframe;
__put_user(set->sig[0], &frame->uc.tuc_mcontext.oldmask);
if (err)
goto badframe;
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__put_user(set->sig[i], &frame->extramask[i - 1]))
goto badframe;
}
setup_sigcontext(&frame->uc.tuc_mcontext, env);
if (ka->sa_flags & TARGET_SA_RESTORER) {
env->regs[15] = ((unsigned long)ka->sa_restorer)-8;
} else {
uint32_t t;
t = 0x31800000UL | TARGET_NR_sigreturn;
__put_user(t, frame->tramp + 0);
t = 0xb9cc0008UL;
__put_user(t, frame->tramp + 1);
env->regs[15] = ((unsigned long)frame->tramp) - 8;
}
if (err)
goto badframe;
env->regs[1] = frame_addr;
env->regs[5] = sig;
env->regs[6] = 0;
env->regs[7] = frame_addr += offsetof(typeof(*frame), uc);
env->sregs[SR_PC] = (unsigned long)ka->_sa_handler;
unlock_user_struct(frame, frame_addr, 1);
return;
badframe:
unlock_user_struct(frame, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| 1threat |
Laravel check if relation is empty : <p>I have an object with some relationships and I need to check if these relations are empty or not, I'm trying to check with is_null, isset, != undefined, etc but nothing works, here is the relationship I get when it's empty :</p>
<pre><code>object(Illuminate\Database\Eloquent\Collection)#197 (1) {
["items":protected]=>
array(0) {
}
}
</code></pre>
<p>Is there a way to check this easily ?
Thanks.</p>
| 0debug |
How can I read in a specific number of characters from a line? (C++) : <p>I am working on a homework assignment where I need to error check the first line of a .txt file. In this case, the first line of the text file should read "Number of samples: ", followed by an unspecified number. If the line DOES NOT start with "Number of samples: ", I need to terminate the program after displaying an error message. Assuming that the line DOES start with the proper string, I need to read in the number as an unsigned integer. </p>
<p>In summary, I need to read in 19 characters from a .txt file line. How do I go about doing that, while still being able to read in the rest of the line to store it as a variable?</p>
<p>The libraries I'm using are iostream, string, ofstream, and ifstream if that matters.</p>
| 0debug |
What does the statement Object[][[] data = new Object [][] mean in Java? : int [ ] [ ] data = new int [ ] [ ] means An array of Integers.
char [ ] [ ] data = new char [ ] [ ] means An array of Characters.
String [ ] [ ] data = new String[ ] [ ] means An array of Strings.
Then...
What does the statement
**Object[][[] data = new Object [][]**
mean in Java?
| 0debug |
document.getElementById('input').innerHTML = user_input; | 1threat |
Multiple Regression Line Using R : I have a regression model analysis for a set of data. I am trying to determine a regression line from this set of data, it is multiple regression. I am having trouble determining the line of regression. I have attached a picture of of my regression analysis.[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/LePas.png | 0debug |
How can I Draw rectangle in programmatically : <p>How can I draw rectangle(Oblique projection view) in programmatically(python) by giving height, width and depth.</p>
| 0debug |
Convert csv rows into columns in python : <p>i have CSV file like:
<a href="https://i.stack.imgur.com/9oBYs.png" rel="nofollow noreferrer">CSV DATA</a></p>
<p>want to convert into single list like:
253,514,517,6514,6518,407,865</p>
<p>reading data row wise while neglecting 0 and duplications</p>
| 0debug |
int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
{
MultiwriteCB *mcb;
int i;
if (bs->drv == NULL) {
for (i = 0; i < num_reqs; i++) {
reqs[i].error = -ENOMEDIUM;
}
return -1;
}
if (num_reqs == 0) {
return 0;
}
mcb = g_malloc0(sizeof(*mcb) + num_reqs * sizeof(*mcb->callbacks));
mcb->num_requests = 0;
mcb->num_callbacks = num_reqs;
for (i = 0; i < num_reqs; i++) {
mcb->callbacks[i].cb = reqs[i].cb;
mcb->callbacks[i].opaque = reqs[i].opaque;
}
num_reqs = multiwrite_merge(bs, reqs, num_reqs, mcb);
trace_bdrv_aio_multiwrite(mcb, mcb->num_callbacks, num_reqs);
mcb->num_requests = num_reqs;
for (i = 0; i < num_reqs; i++) {
bdrv_co_aio_rw_vector(bs, reqs[i].sector, reqs[i].qiov,
reqs[i].nb_sectors, reqs[i].flags,
multiwrite_cb, mcb,
true);
}
return 0;
}
| 1threat |
def replace_list(list1,list2):
list1[-1:] = list2
replace_list=list1
return replace_list
| 0debug |
static void term_insert_char(int ch)
{
if (term_cmd_buf_index < TERM_CMD_BUF_SIZE) {
memmove(term_cmd_buf + term_cmd_buf_index + 1,
term_cmd_buf + term_cmd_buf_index,
term_cmd_buf_size - term_cmd_buf_index);
term_cmd_buf[term_cmd_buf_index] = ch;
term_cmd_buf_size++;
term_cmd_buf_index++;
}
}
| 1threat |
static CharDriverState *qemu_chr_open_ringbuf(ChardevRingbuf *opts,
Error **errp)
{
CharDriverState *chr;
RingBufCharDriver *d;
chr = g_malloc0(sizeof(CharDriverState));
d = g_malloc(sizeof(*d));
d->size = opts->has_size ? opts->size : 65536;
if (d->size & (d->size - 1)) {
error_setg(errp, "size of ringbuf chardev must be power of two");
goto fail;
}
d->prod = 0;
d->cons = 0;
d->cbuf = g_malloc0(d->size);
chr->opaque = d;
chr->chr_write = ringbuf_chr_write;
chr->chr_close = ringbuf_chr_close;
return chr;
fail:
g_free(d);
g_free(chr);
return NULL;
}
| 1threat |
static void set_sensor_type(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMISensor *sens;
IPMI_CHECK_CMD_LEN(5);
if ((cmd[2] > MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return;
}
sens = ibs->sensors + cmd[2];
sens->sensor_type = cmd[3];
sens->evt_reading_type_code = cmd[4] & 0x7f;
}
| 1threat |
I have this code in CSS: : figure > figcaption::before{
> content: "*\002607\0000a0caption\A*";
white-space: pre;
font-style: italic;*emphasized text*
font-variant: small-caps;
font-size: 0.5em;
}
What does the marked part mean? | 0debug |
Using cmake to create main and sub-projects, and be able to compile them individually : <p><strong>DISCLAIMER:</strong> I am new to CMakeLists.txt, I have a working implementation and would like to improve and enhance it, problem described below:</p>
<p>If I want <code>root/sub-directories/</code> as separate sub-projects that can be compiled using the individual <code>CMakeLists.txts</code> in their folders I find myself literally copy pasting almost the entire root file <code>CMakeLists.txt</code> per sub-directory.</p>
<p>I was wondering if there is a better way to have a main project and then sub-projects that get the shared dependencies from main project and can be compiled without <code>cmake</code>-ing the root <code>CMakeLists.txt</code>. My directory structure is;</p>
<p>CMakeLists.txt (root project)<br>
| __ sub_dir-1<br>
| __ | __ CMakeLists.txt (sub-project)<br>
| __ sub_dir-2<br>
| __ | __ CMakeLists.txt (sub-project)<br>
| __ sub_dir-3<br>
| __ | __ CMakeLists.txt (sub-project)<br>
...<br></p>
<p>Essentially, I want to be able to:</p>
<ol>
<li><code>cmake root/CMakeLists.txt</code>, which creates an entire project that includes the sub-projects (I already have this implemented using individual CMakeLists.txts inside sub-directories.</li>
<li><p><code>cmake root/sub-dir/CMakeLists.txt</code> and <strong>only</strong> compile the sub-project, which essentially also finds the necessary dependencies and includes them from maybe <code>.cmake</code> includes or <code>root/CMakeLists.txt</code>. What is the best way to approach this structure;</p>
<ul>
<li>while retaining the first bullet point of having the ability to compile it as an entire project.</li>
<li>And also not <em>crowding</em> the <code>sub-dir/CMakeLists.txt</code> too much with redundant code? </li>
</ul></li>
</ol>
<p>Appreciate any suggestions! Thank you.</p>
| 0debug |
static void avc_h_loop_filter_luma_mbaff_intra_msa(uint8_t *src,
int32_t stride,
int32_t alpha_in,
int32_t beta_in)
{
uint64_t load0, load1;
uint32_t out0, out2;
uint16_t out1, out3;
v8u16 src0_r, src1_r, src2_r, src3_r, src4_r, src5_r, src6_r, src7_r;
v8u16 dst0_r, dst1_r, dst4_r, dst5_r;
v8u16 dst2_x_r, dst2_y_r, dst3_x_r, dst3_y_r;
v16u8 dst0, dst1, dst4, dst5, dst2_x, dst2_y, dst3_x, dst3_y;
v8i16 tmp0, tmp1, tmp2, tmp3;
v16u8 alpha, beta;
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, p2_asub_p0, q2_asub_q0;
v16u8 is_less_than, is_less_than_alpha, is_less_than_beta;
v16u8 is_less_than_beta1, is_less_than_beta2;
v16i8 src0 = { 0 };
v16i8 src1 = { 0 };
v16i8 src2 = { 0 };
v16i8 src3 = { 0 };
v16i8 src4 = { 0 };
v16i8 src5 = { 0 };
v16i8 src6 = { 0 };
v16i8 src7 = { 0 };
v16i8 zeros = { 0 };
load0 = LOAD_DWORD(src - 4);
load1 = LOAD_DWORD(src + stride - 4);
src0 = (v16i8) __msa_insert_d((v2i64) src0, 0, load0);
src1 = (v16i8) __msa_insert_d((v2i64) src1, 0, load1);
load0 = LOAD_DWORD(src + (2 * stride) - 4);
load1 = LOAD_DWORD(src + (3 * stride) - 4);
src2 = (v16i8) __msa_insert_d((v2i64) src2, 0, load0);
src3 = (v16i8) __msa_insert_d((v2i64) src3, 0, load1);
load0 = LOAD_DWORD(src + (4 * stride) - 4);
load1 = LOAD_DWORD(src + (5 * stride) - 4);
src4 = (v16i8) __msa_insert_d((v2i64) src4, 0, load0);
src5 = (v16i8) __msa_insert_d((v2i64) src5, 0, load1);
load0 = LOAD_DWORD(src + (6 * stride) - 4);
load1 = LOAD_DWORD(src + (7 * stride) - 4);
src6 = (v16i8) __msa_insert_d((v2i64) src6, 0, load0);
src7 = (v16i8) __msa_insert_d((v2i64) src7, 0, load1);
src0 = __msa_ilvr_b(src1, src0);
src1 = __msa_ilvr_b(src3, src2);
src2 = __msa_ilvr_b(src5, src4);
src3 = __msa_ilvr_b(src7, src6);
tmp0 = __msa_ilvr_h((v8i16) src1, (v8i16) src0);
tmp1 = __msa_ilvl_h((v8i16) src1, (v8i16) src0);
tmp2 = __msa_ilvr_h((v8i16) src3, (v8i16) src2);
tmp3 = __msa_ilvl_h((v8i16) src3, (v8i16) src2);
src6 = (v16i8) __msa_ilvr_w((v4i32) tmp2, (v4i32) tmp0);
src0 = __msa_sldi_b(zeros, src6, 8);
src1 = (v16i8) __msa_ilvl_w((v4i32) tmp2, (v4i32) tmp0);
src2 = __msa_sldi_b(zeros, src1, 8);
src3 = (v16i8) __msa_ilvr_w((v4i32) tmp3, (v4i32) tmp1);
src4 = __msa_sldi_b(zeros, src3, 8);
src5 = (v16i8) __msa_ilvl_w((v4i32) tmp3, (v4i32) tmp1);
src7 = __msa_sldi_b(zeros, src5, 8);
p0_asub_q0 = __msa_asub_u_b((v16u8) src2, (v16u8) src3);
p1_asub_p0 = __msa_asub_u_b((v16u8) src1, (v16u8) src2);
q1_asub_q0 = __msa_asub_u_b((v16u8) src4, (v16u8) src3);
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_alpha & is_less_than_beta;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than & is_less_than_beta;
alpha >>= 2;
alpha += 2;
is_less_than_alpha = (p0_asub_q0 < alpha);
p2_asub_p0 = __msa_asub_u_b((v16u8) src0, (v16u8) src2);
is_less_than_beta1 = (p2_asub_p0 < beta);
q2_asub_q0 = __msa_asub_u_b((v16u8) src5, (v16u8) src3);
is_less_than_beta2 = (q2_asub_q0 < beta);
src0_r = (v8u16) __msa_ilvr_b(zeros, src0);
src1_r = (v8u16) __msa_ilvr_b(zeros, src1);
src2_r = (v8u16) __msa_ilvr_b(zeros, src2);
src3_r = (v8u16) __msa_ilvr_b(zeros, src3);
src4_r = (v8u16) __msa_ilvr_b(zeros, src4);
src5_r = (v8u16) __msa_ilvr_b(zeros, src5);
src6_r = (v8u16) __msa_ilvr_b(zeros, src6);
src7_r = (v8u16) __msa_ilvr_b(zeros, src7);
dst2_x_r = src1_r + src2_r + src3_r;
dst2_x_r = src0_r + (2 * (dst2_x_r)) + src4_r;
dst2_x_r = (v8u16) __msa_srari_h((v8i16) dst2_x_r, 3);
dst1_r = src0_r + src1_r + src2_r + src3_r;
dst1_r = (v8u16) __msa_srari_h((v8i16) dst1_r, 2);
dst0_r = (2 * src6_r) + (3 * src0_r);
dst0_r += src1_r + src2_r + src3_r;
dst0_r = (v8u16) __msa_srari_h((v8i16) dst0_r, 3);
dst2_y_r = (2 * src1_r) + src2_r + src4_r;
dst2_y_r = (v8u16) __msa_srari_h((v8i16) dst2_y_r, 2);
dst2_x = (v16u8) __msa_pckev_b((v16i8) dst2_x_r, (v16i8) dst2_x_r);
dst2_y = (v16u8) __msa_pckev_b((v16i8) dst2_y_r, (v16i8) dst2_y_r);
dst2_x = __msa_bmnz_v(dst2_y, dst2_x, is_less_than_beta1);
dst3_x_r = src2_r + src3_r + src4_r;
dst3_x_r = src1_r + (2 * dst3_x_r) + src5_r;
dst3_x_r = (v8u16) __msa_srari_h((v8i16) dst3_x_r, 3);
dst4_r = src2_r + src3_r + src4_r + src5_r;
dst4_r = (v8u16) __msa_srari_h((v8i16) dst4_r, 2);
dst5_r = (2 * src7_r) + (3 * src5_r);
dst5_r += src4_r + src3_r + src2_r;
dst5_r = (v8u16) __msa_srari_h((v8i16) dst5_r, 3);
dst3_y_r = (2 * src4_r) + src3_r + src1_r;
dst3_y_r = (v8u16) __msa_srari_h((v8i16) dst3_y_r, 2);
dst3_x = (v16u8) __msa_pckev_b((v16i8) dst3_x_r, (v16i8) dst3_x_r);
dst3_y = (v16u8) __msa_pckev_b((v16i8) dst3_y_r, (v16i8) dst3_y_r);
dst3_x = __msa_bmnz_v(dst3_y, dst3_x, is_less_than_beta2);
dst2_y_r = (2 * src1_r) + src2_r + src4_r;
dst2_y_r = (v8u16) __msa_srari_h((v8i16) dst2_y_r, 2);
dst3_y_r = (2 * src4_r) + src3_r + src1_r;
dst3_y_r = (v8u16) __msa_srari_h((v8i16) dst3_y_r, 2);
dst2_y = (v16u8) __msa_pckev_b((v16i8) dst2_y_r, (v16i8) dst2_y_r);
dst3_y = (v16u8) __msa_pckev_b((v16i8) dst3_y_r, (v16i8) dst3_y_r);
dst2_x = __msa_bmnz_v(dst2_y, dst2_x, is_less_than_alpha);
dst3_x = __msa_bmnz_v(dst3_y, dst3_x, is_less_than_alpha);
dst2_x = __msa_bmnz_v((v16u8) src2, dst2_x, is_less_than);
dst3_x = __msa_bmnz_v((v16u8) src3, dst3_x, is_less_than);
is_less_than = is_less_than_alpha & is_less_than;
dst1 = (v16u8) __msa_pckev_b((v16i8) dst1_r, (v16i8) dst1_r);
is_less_than_beta1 = is_less_than_beta1 & is_less_than;
dst1 = __msa_bmnz_v((v16u8) src1, dst1, is_less_than_beta1);
dst0 = (v16u8) __msa_pckev_b((v16i8) dst0_r, (v16i8) dst0_r);
dst0 = __msa_bmnz_v((v16u8) src0, dst0, is_less_than_beta1);
dst4 = (v16u8) __msa_pckev_b((v16i8) dst4_r, (v16i8) dst4_r);
is_less_than_beta2 = is_less_than_beta2 & is_less_than;
dst4 = __msa_bmnz_v((v16u8) src4, dst4, is_less_than_beta2);
dst5 = (v16u8) __msa_pckev_b((v16i8) dst5_r, (v16i8) dst5_r);
dst5 = __msa_bmnz_v((v16u8) src5, dst5, is_less_than_beta2);
dst0 = (v16u8) __msa_ilvr_b((v16i8) dst1, (v16i8) dst0);
dst1 = (v16u8) __msa_ilvr_b((v16i8) dst3_x, (v16i8) dst2_x);
dst2_x = (v16u8) __msa_ilvr_b((v16i8) dst5, (v16i8) dst4);
tmp0 = __msa_ilvr_h((v8i16) dst1, (v8i16) dst0);
tmp1 = __msa_ilvl_h((v8i16) dst1, (v8i16) dst0);
tmp2 = __msa_ilvr_h((v8i16) zeros, (v8i16) dst2_x);
tmp3 = __msa_ilvl_h((v8i16) zeros, (v8i16) dst2_x);
dst0 = (v16u8) __msa_ilvr_w((v4i32) tmp2, (v4i32) tmp0);
dst1 = (v16u8) __msa_sldi_b(zeros, (v16i8) dst0, 8);
dst2_x = (v16u8) __msa_ilvl_w((v4i32) tmp2, (v4i32) tmp0);
dst3_x = (v16u8) __msa_sldi_b(zeros, (v16i8) dst2_x, 8);
dst4 = (v16u8) __msa_ilvr_w((v4i32) tmp3, (v4i32) tmp1);
dst5 = (v16u8) __msa_sldi_b(zeros, (v16i8) dst4, 8);
dst2_y = (v16u8) __msa_ilvl_w((v4i32) tmp3, (v4i32) tmp1);
dst3_y = (v16u8) __msa_sldi_b(zeros, (v16i8) dst2_y, 8);
out0 = __msa_copy_u_w((v4i32) dst0, 0);
out1 = __msa_copy_u_h((v8i16) dst0, 2);
out2 = __msa_copy_u_w((v4i32) dst1, 0);
out3 = __msa_copy_u_h((v8i16) dst1, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
src += stride;
out0 = __msa_copy_u_w((v4i32) dst2_x, 0);
out1 = __msa_copy_u_h((v8i16) dst2_x, 2);
out2 = __msa_copy_u_w((v4i32) dst3_x, 0);
out3 = __msa_copy_u_h((v8i16) dst3_x, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
src += stride;
out0 = __msa_copy_u_w((v4i32) dst4, 0);
out1 = __msa_copy_u_h((v8i16) dst4, 2);
out2 = __msa_copy_u_w((v4i32) dst5, 0);
out3 = __msa_copy_u_h((v8i16) dst5, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
src += stride;
out0 = __msa_copy_u_w((v4i32) dst2_y, 0);
out1 = __msa_copy_u_h((v8i16) dst2_y, 2);
out2 = __msa_copy_u_w((v4i32) dst3_y, 0);
out3 = __msa_copy_u_h((v8i16) dst3_y, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
}
| 1threat |
static int wma_decode_superframe(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
WMACodecContext *s = avctx->priv_data;
int nb_frames, bit_offset, i, pos, len, ret;
uint8_t *q;
int16_t *samples;
tprintf(avctx, "***decode_superframe:\n");
if(buf_size==0){
s->last_superframe_len = 0;
return 0;
}
if (buf_size < s->block_align)
return 0;
buf_size = s->block_align;
init_get_bits(&s->gb, buf, buf_size*8);
if (s->use_bit_reservoir) {
skip_bits(&s->gb, 4);
nb_frames = get_bits(&s->gb, 4) - (s->last_superframe_len <= 0);
} else {
nb_frames = 1;
}
s->frame.nb_samples = nb_frames * s->frame_len;
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
samples = (int16_t *)s->frame.data[0];
if (s->use_bit_reservoir) {
bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3);
if (s->last_superframe_len > 0) {
if ((s->last_superframe_len + ((bit_offset + 7) >> 3)) >
MAX_CODED_SUPERFRAME_SIZE)
goto fail;
q = s->last_superframe + s->last_superframe_len;
len = bit_offset;
while (len > 7) {
*q++ = (get_bits)(&s->gb, 8);
len -= 8;
}
if (len > 0) {
*q++ = (get_bits)(&s->gb, len) << (8 - len);
}
init_get_bits(&s->gb, s->last_superframe, MAX_CODED_SUPERFRAME_SIZE*8);
if (s->last_bitoffset > 0)
skip_bits(&s->gb, s->last_bitoffset);
if (wma_decode_frame(s, samples) < 0)
goto fail;
samples += s->nb_channels * s->frame_len;
nb_frames--;
}
pos = bit_offset + 4 + 4 + s->byte_offset_bits + 3;
init_get_bits(&s->gb, buf + (pos >> 3), (MAX_CODED_SUPERFRAME_SIZE - (pos >> 3))*8);
len = pos & 7;
if (len > 0)
skip_bits(&s->gb, len);
s->reset_block_lengths = 1;
for(i=0;i<nb_frames;i++) {
if (wma_decode_frame(s, samples) < 0)
goto fail;
samples += s->nb_channels * s->frame_len;
}
pos = get_bits_count(&s->gb) + ((bit_offset + 4 + 4 + s->byte_offset_bits + 3) & ~7);
s->last_bitoffset = pos & 7;
pos >>= 3;
len = buf_size - pos;
if (len > MAX_CODED_SUPERFRAME_SIZE || len < 0) {
av_log(s->avctx, AV_LOG_ERROR, "len %d invalid\n", len);
goto fail;
}
s->last_superframe_len = len;
memcpy(s->last_superframe, buf + pos, len);
} else {
if (wma_decode_frame(s, samples) < 0)
goto fail;
samples += s->nb_channels * s->frame_len;
}
*got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
return s->block_align;
fail:
s->last_superframe_len = 0;
return -1;
} | 1threat |
getenv + string in c and converting types : <p>I want to add /home/username + "/path.png?5667!http-get:*:image/png:!!!!!" just as in Java. but in C</p>
<p><code>name = malloc(strlen(hm)+strlen("/path.png?5667!http-get:*:image/png:!!!!!") + 2);</code></p>
<pre><code>#include <stdlib.h>
#include<stdlib.h>
#include<string.h>
char *hm;
char *full;
hm = getenv("HOME");
full = malloc(strlen(hm)+strlen("/path.png?5667!http-get:*:image/png:!!!!!") + 2);
printf("name = %s\n",name);
</code></pre>
<p>I expect: <code>/home/username/path.png?5667!http-get:*:image/png:!!!!!"</code></p>
| 0debug |
how to avoid parameter missing when using printf? : #include<stdio.h>
void main()
{
int a = 1;
printf("%d:this is for test:%s",a);
}
there is missing parameter for function printf, no warning when compiling, but fatal at run.
| 0debug |
import re
def change_date_format(dt):
return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt) | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.