problem
stringlengths
26
131k
labels
class label
2 classes
iscsi_inquiry_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { struct IscsiTask *itask = opaque; struct scsi_task *task = command_data; struct scsi_inquiry_standard *inq; if (status != 0) { itask->status = 1; itask->complete = 1; scsi_free_scsi_task(task); return; } inq = scsi_datain_unmarshall(task); if (inq == NULL) { error_report("iSCSI: Failed to unmarshall inquiry data."); itask->status = 1; itask->complete = 1; scsi_free_scsi_task(task); return; } itask->iscsilun->type = inq->periperal_device_type; scsi_free_scsi_task(task); switch (itask->iscsilun->type) { case TYPE_DISK: task = iscsi_readcapacity16_task(iscsi, itask->iscsilun->lun, iscsi_readcapacity16_cb, opaque); if (task == NULL) { error_report("iSCSI: failed to send readcapacity16 command."); itask->status = 1; itask->complete = 1; return; } break; case TYPE_ROM: task = iscsi_readcapacity10_task(iscsi, itask->iscsilun->lun, 0, 0, iscsi_readcapacity10_cb, opaque); if (task == NULL) { error_report("iSCSI: failed to send readcapacity16 command."); itask->status = 1; itask->complete = 1; return; } break; default: itask->status = 0; itask->complete = 1; } }
1threat
static void print_all_libs_info(int flags, int level) { PRINT_LIB_INFO(avutil, AVUTIL, flags, level); PRINT_LIB_INFO(avcodec, AVCODEC, flags, level); PRINT_LIB_INFO(avformat, AVFORMAT, flags, level); PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level); PRINT_LIB_INFO(avfilter, AVFILTER, flags, level); PRINT_LIB_INFO(avresample, AVRESAMPLE, flags, level); PRINT_LIB_INFO(swscale, SWSCALE, flags, level); PRINT_LIB_INFO(swresample,SWRESAMPLE, flags, level); #if CONFIG_POSTPROC PRINT_LIB_INFO(postproc, POSTPROC, flags, level); #endif }
1threat
static int bamboo_load_device_tree(hwaddr addr, uint32_t ramsize, hwaddr initrd_base, hwaddr initrd_size, const char *kernel_cmdline) { int ret = -1; uint32_t mem_reg_property[] = { 0, 0, cpu_to_be32(ramsize) }; char *filename; int fdt_size; void *fdt; uint32_t tb_freq = 400000000; uint32_t clock_freq = 400000000; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE); if (!filename) { goto out; } fdt = load_device_tree(filename, &fdt_size); g_free(filename); if (fdt == NULL) { goto out; } ret = qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property, sizeof(mem_reg_property)); if (ret < 0) fprintf(stderr, "couldn't set /memory/reg\n"); ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start", initrd_base); if (ret < 0) fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n"); ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end", (initrd_base + initrd_size)); if (ret < 0) fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); ret = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs", kernel_cmdline); if (ret < 0) fprintf(stderr, "couldn't set /chosen/bootargs\n"); if (kvm_enabled()) { tb_freq = kvmppc_get_tbfreq(); clock_freq = kvmppc_get_clockfreq(); } qemu_devtree_setprop_cell(fdt, "/cpus/cpu@0", "clock-frequency", clock_freq); qemu_devtree_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency", tb_freq); ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); g_free(fdt); out: return ret; }
1threat
How to add drag n drop functionality in rails : <p>I want to add drag n drop functionality in my app like <a href="http://draw.io" rel="nofollow">Draw.io</a> and like trello. Meanz I need fast drag n drop in my app page. But I know how to do it?</p> <p>Please give me some guidelines?</p>
0debug
How to resolve undefined Input Angular? : <p>There is input data in component:</p> <pre><code> @Input() pupil: Pupil; </code></pre> <p>Before rendering this data in template I need to map it:</p> <pre><code> ngOnChanges() { this.pupil.photo = Helper.getPhoto(this.pupil); } </code></pre> <p>But I get error cause <code>this.pupil</code> in undefined, but after I can see filled object.</p> <p>How to await result from Input?</p> <p>In template I have <code>*ngIf="pupil"</code></p>
0debug
static int init_opencl_env(GPUEnv *gpu_env, AVOpenCLExternalEnv *ext_opencl_env) { size_t device_length; cl_int status; cl_uint num_platforms, num_devices; cl_platform_id *platform_ids = NULL; cl_context_properties cps[3]; char platform_name[100]; int i, ret = 0; cl_device_type device_type[] = {CL_DEVICE_TYPE_GPU, CL_DEVICE_TYPE_CPU, CL_DEVICE_TYPE_DEFAULT}; if (ext_opencl_env) { if (gpu_env->is_user_created) return 0; gpu_env->platform_id = ext_opencl_env->platform_id; gpu_env->is_user_created = 1; gpu_env->command_queue = ext_opencl_env->command_queue; gpu_env->context = ext_opencl_env->context; gpu_env->device_ids = ext_opencl_env->device_ids; gpu_env->device_id = ext_opencl_env->device_id; gpu_env->device_type = ext_opencl_env->device_type; } else { if (!gpu_env->is_user_created) { status = clGetPlatformIDs(0, NULL, &num_platforms); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL platform ids: %s\n", opencl_errstr(status)); return AVERROR_EXTERNAL; } if (gpu_env->usr_spec_dev_info.platform_idx >= 0) { if (num_platforms < gpu_env->usr_spec_dev_info.platform_idx + 1) { av_log(&openclutils, AV_LOG_ERROR, "User set platform index not exist\n"); return AVERROR(EINVAL); } } if (num_platforms > 0) { platform_ids = av_mallocz(num_platforms * sizeof(cl_platform_id)); if (!platform_ids) { ret = AVERROR(ENOMEM); goto end; } status = clGetPlatformIDs(num_platforms, platform_ids, NULL); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL platform ids: %s\n", opencl_errstr(status)); ret = AVERROR_EXTERNAL; goto end; } i = 0; if (gpu_env->usr_spec_dev_info.platform_idx >= 0) { i = gpu_env->usr_spec_dev_info.platform_idx; } while (i < num_platforms) { status = clGetPlatformInfo(platform_ids[i], CL_PLATFORM_VENDOR, sizeof(platform_name), platform_name, NULL); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL platform info: %s\n", opencl_errstr(status)); ret = AVERROR_EXTERNAL; goto end; } gpu_env->platform_id = platform_ids[i]; status = clGetDeviceIDs(gpu_env->platform_id, CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL device number:%s\n", opencl_errstr(status)); ret = AVERROR_EXTERNAL; goto end; } if (num_devices == 0) { status = clGetDeviceIDs(gpu_env->platform_id, CL_DEVICE_TYPE_CPU, 0, NULL, &num_devices); } if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL device ids: %s\n", opencl_errstr(status)); ret = AVERROR(EINVAL); goto end; } if (num_devices) break; if (gpu_env->usr_spec_dev_info.platform_idx >= 0) { av_log(&openclutils, AV_LOG_ERROR, "Device number of user set platform is 0\n"); ret = AVERROR_EXTERNAL; goto end; } i++; } } if (!gpu_env->platform_id) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL platforms\n"); ret = AVERROR_EXTERNAL; goto end; } if (gpu_env->usr_spec_dev_info.dev_idx >= 0) { if (num_devices < gpu_env->usr_spec_dev_info.dev_idx + 1) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL device idx in the user set platform\n"); ret = AVERROR(EINVAL); goto end; } } av_log(&openclutils, AV_LOG_VERBOSE, "Platform Name: %s\n", platform_name); cps[0] = CL_CONTEXT_PLATFORM; cps[1] = (cl_context_properties)gpu_env->platform_id; cps[2] = 0; for (i = 0; i < sizeof(device_type); i++) { gpu_env->device_type = device_type[i]; gpu_env->context = clCreateContextFromType(cps, gpu_env->device_type, NULL, NULL, &status); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL context from device type: %s\n", opencl_errstr(status)); ret = AVERROR_EXTERNAL; goto end; } if (gpu_env->context) break; } if (!gpu_env->context) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL context from device type\n"); ret = AVERROR_EXTERNAL; goto end; } status = clGetContextInfo(gpu_env->context, CL_CONTEXT_DEVICES, 0, NULL, &device_length); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL device length: %s\n", opencl_errstr(status)); ret = AVERROR_EXTERNAL; goto end; } if (device_length == 0) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL device length\n"); ret = AVERROR_EXTERNAL; goto end; } gpu_env->device_ids = av_mallocz(device_length); if (!gpu_env->device_ids) { ret = AVERROR(ENOMEM); goto end; } status = clGetContextInfo(gpu_env->context, CL_CONTEXT_DEVICES, device_length, gpu_env->device_ids, NULL); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not get OpenCL context info: %s\n", opencl_errstr(status)); ret = AVERROR_EXTERNAL; goto end; } i = 0; if (gpu_env->usr_spec_dev_info.dev_idx >= 0) { i = gpu_env->usr_spec_dev_info.dev_idx; } gpu_env->command_queue = clCreateCommandQueue(gpu_env->context, gpu_env->device_ids[i], 0, &status); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not create OpenCL command queue: %s\n", opencl_errstr(status)); ret = AVERROR_EXTERNAL; goto end; } } } end: av_free(platform_ids); return ret; }
1threat
static void do_multiwrite(BlockDriverState *bs, BlockRequest *blkreq, int num_writes) { int i, ret; ret = bdrv_aio_multiwrite(bs, blkreq, num_writes); if (ret != 0) { for (i = 0; i < num_writes; i++) { if (blkreq[i].error) { virtio_blk_rw_complete(blkreq[i].opaque, -EIO); } } } }
1threat
What is the minimum configuration(include haxm) to run android studio on computer smoothly ?? please help me : I'm interested in developing android apps.But I struggled a lot to install the android studio on my computer.I end up with an error that my windows can't find haxm. Please help me what I need to do?? My RAM is just 2GB.Is there any need to extend my RAM?? [enter image description here][1] [1]: http://i.stack.imgur.com/0DypJ.png
0debug
Electron - Not allowed to load local resource : <p>Evening,<br> I'm looking into using <a href="http://electron.atom.io/" rel="noreferrer">electron</a> to package an existing angular2 build. I thought I had a dry run working but the actual packaging seems to be failing (see final step below) and I want to understand why. Here's what I'm doing...</p> <p><strong>Create Project</strong><br> Use <a href="https://cli.angular.io/" rel="noreferrer">angular-cli</a> to start a new project <code>ng new electron-ng2-cli --style=scss</code></p> <p>Install electron and <a href="https://github.com/electron-userland/electron-builder" rel="noreferrer">electron-builder</a></p> <p><strong>Edit package.json</strong><br>Make the following additions...<br> <code>"main": "main.js"</code></p> <pre><code>"build": { "appId": "com.electrontest.testapp", "mac": { "category": "your.app.category.type" } } </code></pre> <p>and add the following to the <code>scripts</code>...</p> <pre><code>"pack": "build --dir", "dist": "build", "electron": "electron main.js", "postinstall": "install-app-deps" </code></pre> <p><strong>Create main.js</strong><br>I just copied the code from the <a href="https://github.com/electron/electron-quick-start/blob/master/main.js" rel="noreferrer">electron quick start</a>. The only change I make is to the location of <code>index.html</code> which I set to <code>/dist/index.html</code></p> <p><strong>Amend base</strong><br>In <code>index.html</code> change <code>&lt;base="/"&gt;</code> to <code>&lt;base="./"&gt;</code> </p> <p><strong>Pack code</strong><br>Run <code>ng build</code>. This puts all the packaged code in <code>/dist</code></p> <p><strong>Test Run</strong><br>Run <code>npm run electron</code>. This works fine. An Electron app fires up and I see the angular stuff running within it.</p> <p><strong>Create App For Distribution</strong><br>Run <code>npm run pack</code> to create a packaged app. The packaging seems to go ok - I get a warning about a missing icon and a warning that my code is unsigned but I'm guessing they shouldn't be fatal?<br> The problem is that when I now run the app by double clicking in <code>Finder</code> I get an error in the console saying: <code>Not allowed to load local resource: file:///Users/&lt;username&gt;/Documents/development/electron-ng2-cli/dist/mac/electron-ng2-cli.app/Contents/Resources/app.asar/dist/index.html</code> <hr> So, can anyone explain what is different between the packaged app that fails and the one that runs ok when I use <code>npm run electron</code>?</p> <p>What can I do to fix this issue and get the app running correctly?</p> <p>Thank you for making it to the end. This got longer than I wanted but I hope I explained myself ok. If you can help or give any pointers that would be great - many good vibes will be thought in your general direction :)</p> <p>Cheers all</p>
0debug
Hi, I have a text file of a grid that has x y z coordinates and varying lengths of the sides of the cells(sx, sy and sz). : I have a text file of a grid that has x y z coordinates (of cell centers and are in UTM) and varying lengths of the sides of the cells(sx, sy and sz). The points are random points. I would like to plot this in python. Can anyone offer any suggestions? x y z sx sy sz 584597 1848923 210 143 53 143 584885 1848927 210 143 62 143 585173 1853185 210 143 224 143
0debug
how to use sharedpreferences in my project android : hey guys how to use sharedpreferences in my project. I have a floating button in my mainactivity and secondactivity when i click the floating button the compass will be disabled then when i go in the secondactivity the compass is enabled which is disabled instead.How to resolve this problem? here is my code FloatingActionButton compass1 = (FloatingActionButton)findViewById(R.id.comp); compass1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(findViewById(R.id.relativeLayout1).getVisibility()==View.VISIBLE){ findViewById(R.id.relativeLayout1).setVisibility(View.GONE); Toast.makeText(getApplicationContext(),"Compass Has Been Disabled",Toast.LENGTH_SHORT).show(); } else{ findViewById(R.id.relativeLayout1).setVisibility(View.VISIBLE); Toast.makeText(getApplicationContext(),"Compass Has Been Enabled",Toast.LENGTH_SHORT).show(); } } });
0debug
Spring tutorial : <p>I am looking for a comprehensive tutorial for developing a web application with the Spring Framework. <a href="https://docs.spring.io/docs/Spring-MVC-step-by-step/overview.html" rel="nofollow">This</a> looks good, but seems a bit dated and uses Ant. Is there a more recent tutorial out there using Gradle or Maven?</p>
0debug
void bios_linker_loader_add_checksum(GArray *linker, const char *file, void *table, void *start, unsigned size, uint8_t *checksum) { BiosLinkerLoaderEntry entry; memset(&entry, 0, sizeof entry); strncpy(entry.cksum.file, file, sizeof entry.cksum.file - 1); entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM); entry.cksum.offset = cpu_to_le32(checksum - (uint8_t *)table); entry.cksum.start = cpu_to_le32((uint8_t *)start - (uint8_t *)table); entry.cksum.length = cpu_to_le32(size); g_array_append_val(linker, entry); }
1threat
static int check_bits_for_superframe(GetBitContext *orig_gb, WMAVoiceContext *s) { GetBitContext s_gb, *gb = &s_gb; int n, need_bits, bd_idx; const struct frame_type_desc *frame_desc; init_get_bits(gb, orig_gb->buffer, orig_gb->size_in_bits); skip_bits_long(gb, get_bits_count(orig_gb)); av_assert1(get_bits_left(gb) == get_bits_left(orig_gb)); if (get_bits_left(gb) < 14) return 1; if (!get_bits1(gb)) return AVERROR(ENOSYS); if (get_bits1(gb)) skip_bits(gb, 12); if (s->has_residual_lsps) { if (get_bits_left(gb) < s->sframe_lsp_bitsize) return 1; skip_bits_long(gb, s->sframe_lsp_bitsize); } for (n = 0; n < MAX_FRAMES; n++) { int aw_idx_is_ext = 0; if (!s->has_residual_lsps) { if (get_bits_left(gb) < s->frame_lsp_bitsize) return 1; skip_bits_long(gb, s->frame_lsp_bitsize); } bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)]; if (bd_idx < 0) return AVERROR_INVALIDDATA; frame_desc = &frame_descs[bd_idx]; if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) { if (get_bits_left(gb) < s->pitch_nbits) return 1; skip_bits_long(gb, s->pitch_nbits); } if (frame_desc->fcb_type == FCB_TYPE_SILENCE) { skip_bits(gb, 8); } else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) { int tmp = get_bits(gb, 6); if (tmp >= 0x36) { skip_bits(gb, 2); aw_idx_is_ext = 1; } } if (frame_desc->acb_type == ACB_TYPE_HAMMING) { need_bits = s->block_pitch_nbits + (frame_desc->n_blocks - 1) * s->block_delta_pitch_nbits; } else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) { need_bits = 2 * !aw_idx_is_ext; } else need_bits = 0; need_bits += frame_desc->frame_size; if (get_bits_left(gb) < need_bits) return 1; skip_bits_long(gb, need_bits); } return 0; }
1threat
Flutter: How to read preferences at Widget startup? : <p>I have been trying to read preferences at Widget startup but have been unable to find a solution. I wish to show the users name in a TextField (which they can change) and store it in preferences so that it is shown as soon as they go back to the page.</p> <pre><code>class _MyHomePageState extends State&lt;MyHomePage&gt; { TextEditingController _controller; : : Future&lt;Null&gt; storeName(String name) async { SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString("name", name); } @override initState() async { super.initState(); SharedPreferences prefs = await SharedPreferences.getInstance(); _controller = new TextEditingController(text: prefs.getString("name")); } @override Widget build(BuildContext context) { : : return new TextField( decoration: new InputDecoration( hintText: "Name (optional)", ), onChanged: (String str) { setState(() { _name = str; storeName(str); }); }, controller: _controller, ) } } </code></pre> <p>I got the idea for using async on initState() from :<br/> <a href="https://stackoverflow.com/questions/45107702/flutter-timing-problems-on-stateful-widget-after-api-call">flutter timing problems on stateful widget after API call</a> <br/> But the async seems to cause this error on startup :</p> <pre><code>'package:flutter/src/widgets/framework.dart': Failed assertion: line 967 pos 12: '_debugLifecycleState == _StateLifecycle.created': is not true. </code></pre> <p>I looked for examples of FutureBuilder but cannot seem to find any which are similar to what I am trying to do.</p>
0debug
void av_thread_message_flush(AVThreadMessageQueue *mq) { #if HAVE_THREADS int used, off; void *free_func = mq->free_func; pthread_mutex_lock(&mq->lock); used = av_fifo_size(mq->fifo); if (free_func) for (off = 0; off < used; off += mq->elsize) av_fifo_generic_peek_at(mq->fifo, mq, off, mq->elsize, free_func_wrap); av_fifo_drain(mq->fifo, used); pthread_cond_broadcast(&mq->cond); pthread_mutex_unlock(&mq->lock); #endif }
1threat
static av_cold void h264dsp_init_neon(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { if (bit_depth == 8) { c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon; c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon; c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon; c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon; c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon; c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon; c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_4_neon; c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16_neon; c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_8_neon; c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_4_neon; c->h264_idct_add = ff_h264_idct_add_neon; c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; c->h264_idct_add16 = ff_h264_idct_add16_neon; c->h264_idct_add16intra = ff_h264_idct_add16intra_neon; if (chroma_format_idc == 1) c->h264_idct_add8 = ff_h264_idct_add8_neon; c->h264_idct8_add = ff_h264_idct8_add_neon; c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; c->h264_idct8_add4 = ff_h264_idct8_add4_neon; } }
1threat
int ff_rtsp_connect(AVFormatContext *s) { RTSPState *rt = s->priv_data; char host[1024], path[1024], tcpname[1024], cmd[2048], auth[128]; char *option_list, *option, *filename; URLContext *rtsp_hd, *rtsp_hd_out; int port, err, tcp_fd; RTSPMessageHeader reply1 = {}, *reply = &reply1; int lower_transport_mask = 0; char real_challenge[64]; struct sockaddr_storage peer; socklen_t peer_len = sizeof(peer); if (!ff_network_init()) return AVERROR(EIO); redirect: rt->control_transport = RTSP_MODE_PLAIN; ff_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), &port, path, sizeof(path), s->filename); if (*auth) { av_strlcpy(rt->auth, auth, sizeof(rt->auth)); } if (port < 0) port = RTSP_DEFAULT_PORT; option_list = strrchr(path, '?'); if (option_list) { filename = option_list; while (option_list) { option = ++option_list; option_list = strchr(option_list, '&'); if (option_list) *option_list = 0; if (!strcmp(option, "udp")) { lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_UDP); } else if (!strcmp(option, "multicast")) { lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_UDP_MULTICAST); } else if (!strcmp(option, "tcp")) { lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP); } else if(!strcmp(option, "http")) { lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP); rt->control_transport = RTSP_MODE_TUNNEL; } else { int len = strlen(option); memmove(++filename, option, len); filename += len; if (option_list) *filename = '&'; } } *filename = 0; } if (!lower_transport_mask) lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_NB) - 1; if (s->oformat) { lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_UDP) | (1 << RTSP_LOWER_TRANSPORT_TCP); if (!lower_transport_mask || rt->control_transport == RTSP_MODE_TUNNEL) { av_log(s, AV_LOG_ERROR, "Unsupported lower transport method, " "only UDP and TCP are supported for output.\n"); err = AVERROR(EINVAL); goto fail; } } ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL, host, port, "%s", path); if (rt->control_transport == RTSP_MODE_TUNNEL) { char httpname[1024]; char sessioncookie[17]; char headers[1024]; ff_url_join(httpname, sizeof(httpname), "http", NULL, host, port, "%s", path); snprintf(sessioncookie, sizeof(sessioncookie), "%08x%08x", av_get_random_seed(), av_get_random_seed()); if (url_open(&rtsp_hd, httpname, URL_RDONLY) < 0) { err = AVERROR(EIO); goto fail; } snprintf(headers, sizeof(headers), "x-sessioncookie: %s\r\n" "Accept: application/x-rtsp-tunnelled\r\n" "Pragma: no-cache\r\n" "Cache-Control: no-cache\r\n", sessioncookie); ff_http_set_headers(rtsp_hd, headers); if (url_read(rtsp_hd, NULL, 0)) { err = AVERROR(EIO); goto fail; } if (url_open(&rtsp_hd_out, httpname, URL_WRONLY) < 0 ) { err = AVERROR(EIO); goto fail; } snprintf(headers, sizeof(headers), "x-sessioncookie: %s\r\n" "Content-Type: application/x-rtsp-tunnelled\r\n" "Pragma: no-cache\r\n" "Cache-Control: no-cache\r\n" "Content-Length: 32767\r\n" "Expires: Sun, 9 Jan 1972 00:00:00 GMT\r\n", sessioncookie); ff_http_set_headers(rtsp_hd_out, headers); ff_http_set_chunked_transfer_encoding(rtsp_hd_out, 0); } else { ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL); if (url_open(&rtsp_hd, tcpname, URL_RDWR) < 0) { err = AVERROR(EIO); goto fail; } rtsp_hd_out = rtsp_hd; } rt->rtsp_hd = rtsp_hd; rt->rtsp_hd_out = rtsp_hd_out; rt->seq = 0; tcp_fd = url_get_file_handle(rtsp_hd); if (!getpeername(tcp_fd, (struct sockaddr*) &peer, &peer_len)) { getnameinfo((struct sockaddr*) &peer, peer_len, host, sizeof(host), NULL, 0, NI_NUMERICHOST); } for (rt->server_type = RTSP_SERVER_RTP;;) { cmd[0] = 0; if (rt->server_type == RTSP_SERVER_REAL) av_strlcat(cmd, "ClientChallenge: 9e26d33f2984236010ef6253fb1887f7\r\n" "PlayerStarttime: [28/03/2003:22:50:23 00:00]\r\n" "CompanyID: KnKV4M4I/B2FjJ1TToLycw==\r\n" "GUID: 00000000-0000-0000-0000-000000000000\r\n", sizeof(cmd)); ff_rtsp_send_cmd(s, "OPTIONS", rt->control_uri, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) { err = AVERROR_INVALIDDATA; goto fail; } if (rt->server_type != RTSP_SERVER_REAL && reply->real_challenge[0]) { rt->server_type = RTSP_SERVER_REAL; continue; } else if (!strncasecmp(reply->server, "WMServer/", 9)) { rt->server_type = RTSP_SERVER_WMS; } else if (rt->server_type == RTSP_SERVER_REAL) strcpy(real_challenge, reply->real_challenge); break; } if (s->iformat) err = rtsp_setup_input_streams(s, reply); else err = rtsp_setup_output_streams(s, host); if (err) goto fail; do { int lower_transport = ff_log2_tab[lower_transport_mask & ~(lower_transport_mask - 1)]; err = make_setup_request(s, host, port, lower_transport, rt->server_type == RTSP_SERVER_REAL ? real_challenge : NULL); if (err < 0) goto fail; lower_transport_mask &= ~(1 << lower_transport); if (lower_transport_mask == 0 && err == 1) { err = FF_NETERROR(EPROTONOSUPPORT); goto fail; } } while (err); rt->state = RTSP_STATE_IDLE; rt->seek_timestamp = 0; return 0; fail: ff_rtsp_close_streams(s); ff_rtsp_close_connections(s); if (reply->status_code >=300 && reply->status_code < 400 && s->iformat) { av_strlcpy(s->filename, reply->location, sizeof(s->filename)); av_log(s, AV_LOG_INFO, "Status %d: Redirecting to %s\n", reply->status_code, s->filename); goto redirect; } ff_network_close(); return err; }
1threat
void kvm_init_irq_routing(KVMState *s) { int gsi_count, i; gsi_count = kvm_check_extension(s, KVM_CAP_IRQ_ROUTING); if (gsi_count > 0) { unsigned int gsi_bits, i; gsi_bits = ALIGN(gsi_count, 32); s->used_gsi_bitmap = g_malloc0(gsi_bits / 8); s->gsi_count = gsi_count; for (i = gsi_count; i < gsi_bits; i++) { set_gsi(s, i); } } s->irq_routes = g_malloc0(sizeof(*s->irq_routes)); s->nr_allocated_irq_routes = 0; if (!s->direct_msi) { for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) { QTAILQ_INIT(&s->msi_hashtab[i]); } } kvm_arch_init_irq_routing(s); }
1threat
void qmp_guest_set_user_password(const char *username, const char *password, bool crypted, Error **errp) { NET_API_STATUS nas; char *rawpasswddata = NULL; size_t rawpasswdlen; wchar_t *user, *wpass; USER_INFO_1003 pi1003 = { 0, }; if (crypted) { error_setg(errp, QERR_UNSUPPORTED); return; } rawpasswddata = (char *)g_base64_decode(password, &rawpasswdlen); rawpasswddata = g_renew(char, rawpasswddata, rawpasswdlen + 1); rawpasswddata[rawpasswdlen] = '\0'; user = g_utf8_to_utf16(username, -1, NULL, NULL, NULL); wpass = g_utf8_to_utf16(rawpasswddata, -1, NULL, NULL, NULL); pi1003.usri1003_password = wpass; nas = NetUserSetInfo(NULL, user, 1003, (LPBYTE)&pi1003, NULL); if (nas != NERR_Success) { gchar *msg = get_net_error_message(nas); error_setg(errp, "failed to set password: %s", msg); g_free(msg); } g_free(user); g_free(wpass); g_free(rawpasswddata); }
1threat
Sentence boundary detection across many languages : <p>I'm looking for a framework like below that can be used with swift. What do you recommend?</p> <p><a href="https://github.com/diasks2/pragmatic_segmenter" rel="nofollow noreferrer">https://github.com/diasks2/pragmatic_segmenter</a></p> <p>Thank you.</p>
0debug
def set_left_most_unset_bit(n): if not (n & (n + 1)): return n pos, temp, count = 0, n, 0 while temp: if not (temp & 1): pos = count count += 1; temp>>=1 return (n | (1 << (pos)))
0debug
Use multi-stage docker files for outputting multiple images : <p>A new docker feature is to do something like this in the dockerfile</p> <pre><code>FROM php7-fpm as build ... FROM build AS test ... FROM test AS staging ... </code></pre> <p>As far as i know, the last FROM statement marks the final output image. How is it possible to have two final images from one intermdiate image?</p> <p>Like</p> <pre><code>... FROM build AS test ... FROM test AS staging ... FROM test AS prod </code></pre> <p>Test, staging and prod should not be discarded. I want to check in them into the repository.</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
To Indians: need function to convert amount into Indian words (Crores, Lakhs, Thousands ...) in R language : I need a function in R language to convert amount into Indian words in crore, lakh, thousand etc... For example: function(3257) should generate: Three Thousand Two Hundred and Fifty Seven; function(473257) should generate: Four Lakh Seventy Three Thousand Two Hundred and Fifty Seven; function(12473257) should generate: One Crore Twenty Four Lakh Seventy Three Thousand Two Hundred and Fifty Seven Plenty of working VBA functions can be found on the internet for use with Microsoft Excel and Access but I was unable to find a similar function in R language. Can anyone help please?
0debug
Get selected form data using jQuery : <p>I have a scenario where a page have multiple forms and I am trying to get the form data which is being submitted.</p> <p>HTML</p> <pre><code>&lt;form name="form1"&gt; &lt;input type="text"&gt; &lt;input type="button" value="Submit"&gt; &lt;form&gt; &lt;form name="form2"&gt; &lt;input type="text"&gt; &lt;input type="button" value="Submit"&gt; &lt;form&gt; </code></pre> <p>jQuery</p> <pre><code>$('[type="button"]').click(function(e){ e.preventDefault(); console.log($(this).parent().attr('name')); }); </code></pre> <p>I always get form1 in console. I also tried <code>jQuery('form')</code> in console and it is also returning only the first form. I don't know what I am doing wrong or it is browser feature.</p>
0debug
build_fadt(GArray *table_data, GArray *linker, unsigned dsdt) { AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt)); fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI); fadt->arm_boot_flags = cpu_to_le16((1 << ACPI_FADT_ARM_USE_PSCI_G_0_2) | (1 << ACPI_FADT_ARM_PSCI_USE_HVC)); fadt->minor_revision = 0x1; fadt->dsdt = cpu_to_le32(dsdt); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, table_data, &fadt->dsdt, sizeof fadt->dsdt); build_header(linker, table_data, (void *)fadt, "FACP", sizeof(*fadt), 5, NULL, NULL); }
1threat
allocate memory in complecated objects : i have two classes, the first is myarray that have 2 filelds: size and int pointer. the class Supposed to make an array of size that was sent the second class(list_of_my_aray) have two fileds, pointer my class and size How do I build the non-default constructor of list_of_my_aray class MyArray { public: int size; int* myArray; MyArray(); MyArray(int size,int* arr); }; class list_of_myArray { public: int size; MyArray* list; GroupArray(); GroupArray(int size,MyArray*list); };
0debug
splitting a string on a new line into seperate variable : so i have a variable id that outputs ` 1 2 3 4 5 ` i just want to grab the first number 1 and add that as student1.id and the second number as student2.id and so on. currently if i print student1.id i get ` 1 2 3 4 5 ` how would i go about this? i tried doing a for loop but it said it is not iteratable. public class main { /** * Reads a text file containing student data and uses this to populate the student objects * * @param filename Path to the student data file to be read * @return Whether the file was read successfully */ public static boolean readFile(String filename) { File file = new File(filename); try { Scanner scanner = new Scanner(file); while(scanner.hasNextLine()){ String[] words = scanner.nextLine().split(","); addStudent(words[0],words[1],words[2],words[3],words[4],words[5],words[6],words[7],words[8]); // TODO: Finish adding the parameters } scanner.close(); } catch (FileNotFoundException e) { System.out.println("Failed to read file"); } return true; } static void addStudent(String id, String firstName, String lastName, String mathsMark1, String mathsMark2, String mathsMark3, String englishMark1, String englishMark2, String englishMark3) { Student student1 = new Student(); Student student2 = new Student(); Student student3 = new Student(); Student student4 = new Student(); Student student5 = new Student(); student1.id = id; student1.firstname = firstName; student1.lastname = lastName; System.out.println(student1.id); }
0debug
static int tscc2_decode_mb(TSCC2Context *c, int *q, int vlc_set, uint8_t *dst, int stride, int plane) { GetBitContext *gb = &c->gb; int prev_dc, dc, nc, ac, bpos, val; int i, j, k, l; if (get_bits1(gb)) { if (get_bits1(gb)) { val = get_bits(gb, 8); for (i = 0; i < 8; i++, dst += stride) memset(dst, val, 16); } else { if (get_bits_left(gb) < 16 * 8 * 8) return AVERROR_INVALIDDATA; for (i = 0; i < 8; i++) { for (j = 0; j < 16; j++) dst[j] = get_bits(gb, 8); dst += stride; } } return 0; } prev_dc = 0; for (j = 0; j < 2; j++) { for (k = 0; k < 4; k++) { if (!(j | k)) { dc = get_bits(gb, 8); } else { dc = get_vlc2(gb, c->dc_vlc.table, 9, 2); if (dc == -1) return AVERROR_INVALIDDATA; if (dc == 0x100) dc = get_bits(gb, 8); } dc = (dc + prev_dc) & 0xFF; prev_dc = dc; c->block[0] = dc; nc = get_vlc2(gb, c->nc_vlc[vlc_set].table, 9, 1); if (nc == -1) return AVERROR_INVALIDDATA; bpos = 1; memset(c->block + 1, 0, 15 * sizeof(*c->block)); for (l = 0; l < nc; l++) { ac = get_vlc2(gb, c->ac_vlc[vlc_set].table, 9, 2); if (ac == -1) return AVERROR_INVALIDDATA; if (ac == 0x1000) ac = get_bits(gb, 12); bpos += ac & 0xF; if (bpos >= 64) return AVERROR_INVALIDDATA; val = sign_extend(ac >> 4, 8); c->block[tscc2_zigzag[bpos++]] = val; } tscc2_idct4_put(c->block, q, dst + k * 4, stride); } dst += 4 * stride; } return 0; }
1threat
Cant do a rounded picture box, help me : im having a problem to round a picturebox edge on visual studio enterprise 2015 private void pictureBox3_Click(object sender, EventArgs e) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddEllipse(0, 0, pictureBox1.Width - 3, pictureBox1.Height - 3); Region rg = new Region(gp); pictureBox1.Region = rg; } this is the code, but nothing happens, could you help me?
0debug
npm http-server with SSL : <p>I'm using the npm package "http-server" (<a href="https://www.npmjs.com/package/http-server" rel="noreferrer">https://www.npmjs.com/package/http-server</a>) to set up a simple webserver, but I cannot get it to use SSL. My command in package.json is</p> <pre><code>http-server -p 8000 -o -S </code></pre> <p>with a cert.pem and key.pem in my root directory (for now). The "-o" option opens a browser to the default page, but the page is served using HTTP and not even accessible through HTTPS. I don't get any errors or warnings. I've also tried adding the "-C" and "-K" options without luck. Has any one had any success with this package?</p>
0debug
Compare two strings and output result where both are equal : <p>I have two strings, and I want to output one string where both give the same values. e.g.</p> <pre><code>var string1 = "ab?def#hij@lm"; var string2 = "abcd!f#hijkl]"; //expected output would be "abcdef#hijklm" </code></pre> <p>I have thought a way to do this would be to assign each character to an array, then compare each character individually but that seems inefficient, as I'm going to pass this through strings with tens of thousands of characters.</p> <p>Any help is appreciated, doesn't have to be code, just to guide me in the general direction. </p>
0debug
PCA *ff_pca_init(int n){ PCA *pca; if(n<=0) pca= av_mallocz(sizeof(*pca)); pca->n= n; pca->z = av_malloc_array(n, sizeof(*pca->z)); pca->count=0; pca->covariance= av_calloc(n*n, sizeof(double)); pca->mean= av_calloc(n, sizeof(double)); return pca;
1threat
Using enum instead of struct for tag dispatching in C++ : <p>Let's take implementation of the <code>std::unique_lock</code> from the Standard Library:</p> <pre><code>struct defer_lock_t { explicit defer_lock_t() = default; }; struct try_to_lock_t { explicit try_to_lock_t() = default; }; struct adopt_lock_t { explicit adopt_lock_t() = default; }; inline constexpr defer_lock_t defer_lock {}; inline constexpr try_to_lock_t try_to_lock {}; inline constexpr adopt_lock_t adopt_lock {}; unique_lock (mutex_type&amp; m, defer_lock_t t) noexcept; unique_lock (mutex_type&amp; m, try_to_lock_t t); unique_lock (mutex_type&amp; m, adopt_lock_t t); </code></pre> <p>Is there a reason why one wouldn't/couldn't/shouldn't use enums instead of structs to implement tag dispatching? Such as:</p> <pre><code>enum defer_lock_t { defer_lock }; enum try_to_lock_t { try_to_lock }; enum adopt_lock_t { adopt_lock }; unique_lock (mutex_type&amp; m, defer_lock_t t) noexcept; unique_lock (mutex_type&amp; m, try_to_lock_t t); unique_lock (mutex_type&amp; m, adopt_lock_t t); </code></pre> <p>The latter is more concise.</p> <p>The only advantage of using structs that I can think of is inheritance (eg, iterator tags). But in all other cases, why not use enum?</p>
0debug
List.Capacity does not working : <p>List.Capacity does not working </p> <p>Code</p> <pre><code> var xx = new List&lt;int&gt;(); xx.Add(1); int xxxx = xx.Capacity;// result is 4 and change to 8,12,16 while adding new item to xx list. </code></pre> <p>But the capacity is does not working, which mean does not increasing while set the capacity manually </p> <pre><code> var xx = new List&lt;int&gt;(1); // or xx.Capacity = 1; xx.Add(1); int xxxx = xx.Capacity;// result is always showing 1 does not increasing like 5, 9, 13... </code></pre>
0debug
TypeError: TypeError: undefined is not an object (evaluating 'theme.label') Error : <p>I am having this issue with expo and npm. Anyone has any idea how to resolve this?<a href="https://i.stack.imgur.com/zHbd2.jpg" rel="nofollow noreferrer">Error is here!</a></p>
0debug
how i can find the location of javascript : **Hi** how i can find the location of javascript this is the code : <div class="mmOtherOdds"> <div class="odd t1 n1"> <div>1</div> <div><a id="h_w_PC_ctl11_repMM_ctl01_repOdds_ctl01_lnkOdds">3,29</a></div> </div> <div class="odd t1 n13"> <div>1</div> <div><a href="javascript:AddCoupon(sCouponButtonClientID,sCouponQuotaClientID,3430082440);" id="h_w_PC_ctl11_repMM_ctl01_repOdds_ctl02_lnkOdds" class="down">2,22</a></div> </div> i need to know how i can find the location of this href="javascript:AddCoupon(sCouponButtonClientID,sCouponQuotaClientID,3430082440);"
0debug
Questions about custom switch button in Swift : <p>I want to make a switch button like the picture.</p> <p><a href="https://i.stack.imgur.com/4sYPi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4sYPi.png" alt="enter image description here"></a></p> <p>Is there a library or method in ios that allows this switch button?</p>
0debug
int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size, int flags) { XattrOperations *xops = get_xattr_operations(ctx->xops, name); if (xops) { return xops->setxattr(ctx, path, name, value, size, flags); } errno = -EOPNOTSUPP; return -1; }
1threat
Why use positional only arguments in pythin 3.8 : A new "positional only arguments" syntax has been introduced in 3.8. > There is new syntax (/) to indicate that some function parameters must > be specified positionally (i.e., cannot be used as keyword arguments). > This is the same notation as shown by help() for functions implemented > in C (produced by Larry Hastings’ “Argument Clinic” tool). Example: > Now pow(2, 10) and pow(2, 10, 17) are valid calls, but pow(x=2, y=10) and pow(2, 10, z=17) are invalid. ---- My question is, why ever use this syntax? Why is it better for the code's user? It seems to me that this makes it harder for users to specify what their arguments actually mean, if they so desire. Why make it harder on the user? I am clearly missing something.
0debug
static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) { AVFilterContext *avctx = inlink->dst; AVFilterLink *outlink = avctx->outputs[0]; ScaleVAAPIContext *ctx = avctx->priv; AVFrame *output_frame = NULL; VASurfaceID input_surface, output_surface; VAProcPipelineParameterBuffer params; VABufferID params_id; VAStatus vas; int err; av_log(ctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u (%"PRId64").\n", av_get_pix_fmt_name(input_frame->format), input_frame->width, input_frame->height, input_frame->pts); if (ctx->va_context == VA_INVALID_ID) return AVERROR(EINVAL); input_surface = (VASurfaceID)(uintptr_t)input_frame->data[3]; av_log(ctx, AV_LOG_DEBUG, "Using surface %#x for scale input.\n", input_surface); output_frame = av_frame_alloc(); if (!output_frame) { av_log(ctx, AV_LOG_ERROR, "Failed to allocate output frame."); err = AVERROR(ENOMEM); goto fail; } err = av_hwframe_get_buffer(ctx->output_frames_ref, output_frame, 0); if (err < 0) { av_log(ctx, AV_LOG_ERROR, "Failed to get surface for " "output: %d\n.", err); } output_surface = (VASurfaceID)(uintptr_t)output_frame->data[3]; av_log(ctx, AV_LOG_DEBUG, "Using surface %#x for scale output.\n", output_surface); memset(&params, 0, sizeof(params)); params.surface = input_surface; params.surface_region = 0; params.surface_color_standard = vaapi_proc_colour_standard(input_frame->colorspace); params.output_region = 0; params.output_background_color = 0xff000000; params.output_color_standard = params.surface_color_standard; params.pipeline_flags = 0; params.filter_flags = VA_FILTER_SCALING_HQ; vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context, output_surface); if (vas != VA_STATUS_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Failed to attach new picture: " "%d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); goto fail; } vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context, VAProcPipelineParameterBufferType, sizeof(params), 1, &params, &params_id); if (vas != VA_STATUS_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Failed to create parameter buffer: " "%d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); goto fail_after_begin; } av_log(ctx, AV_LOG_DEBUG, "Pipeline parameter buffer is %#x.\n", params_id); vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context, &params_id, 1); if (vas != VA_STATUS_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Failed to render parameter buffer: " "%d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); goto fail_after_begin; } vas = vaEndPicture(ctx->hwctx->display, ctx->va_context); if (vas != VA_STATUS_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Failed to start picture processing: " "%d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); goto fail_after_render; } if (ctx->hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) { vas = vaDestroyBuffer(ctx->hwctx->display, params_id); if (vas != VA_STATUS_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Failed to free parameter buffer: " "%d (%s).\n", vas, vaErrorStr(vas)); } } av_frame_copy_props(output_frame, input_frame); av_frame_free(&input_frame); av_log(ctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n", av_get_pix_fmt_name(output_frame->format), output_frame->width, output_frame->height, output_frame->pts); return ff_filter_frame(outlink, output_frame); fail_after_begin: vaRenderPicture(ctx->hwctx->display, ctx->va_context, &params_id, 1); fail_after_render: vaEndPicture(ctx->hwctx->display, ctx->va_context); fail: av_frame_free(&input_frame); av_frame_free(&output_frame); return err; }
1threat
def first_even(nums): first_even = next((el for el in nums if el%2==0),-1) return first_even
0debug
static int genh_read_header(AVFormatContext *s) { unsigned start_offset, header_size, codec, coef_type, coef[2]; GENHDemuxContext *c = s->priv_data; av_unused unsigned coef_splitted[2]; int align, ch, ret; AVStream *st; avio_skip(s->pb, 4); st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->channels = avio_rl32(s->pb); if (st->codecpar->channels <= 0) return AVERROR_INVALIDDATA; if (st->codecpar->channels == 1) st->codecpar->channel_layout = AV_CH_LAYOUT_MONO; else if (st->codecpar->channels == 2) st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; align = c->interleave_size = avio_rl32(s->pb); if (align < 0 || align > INT_MAX / st->codecpar->channels) return AVERROR_INVALIDDATA; st->codecpar->block_align = align * st->codecpar->channels; st->codecpar->sample_rate = avio_rl32(s->pb); avio_skip(s->pb, 4); st->duration = avio_rl32(s->pb); codec = avio_rl32(s->pb); switch (codec) { case 0: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX; break; case 1: case 11: st->codecpar->bits_per_coded_sample = 4; st->codecpar->block_align = 36 * st->codecpar->channels; st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV; break; case 2: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_DTK; break; case 3: st->codecpar->codec_id = st->codecpar->block_align > 0 ? AV_CODEC_ID_PCM_S16BE_PLANAR : AV_CODEC_ID_PCM_S16BE; break; case 4: st->codecpar->codec_id = st->codecpar->block_align > 0 ? AV_CODEC_ID_PCM_S16LE_PLANAR : AV_CODEC_ID_PCM_S16LE; break; case 5: st->codecpar->codec_id = st->codecpar->block_align > 0 ? AV_CODEC_ID_PCM_S8_PLANAR : AV_CODEC_ID_PCM_S8; break; case 6: st->codecpar->codec_id = AV_CODEC_ID_SDX2_DPCM; break; case 7: ret = ff_alloc_extradata(st->codecpar, 2); if (ret < 0) return ret; AV_WL16(st->codecpar->extradata, 3); st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WS; break; case 10: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_AICA; break; case 12: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_THP; break; case 13: st->codecpar->codec_id = AV_CODEC_ID_PCM_U8; break; case 17: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_QT; break; default: avpriv_request_sample(s, "codec %d", codec); return AVERROR_PATCHWELCOME; } start_offset = avio_rl32(s->pb); header_size = avio_rl32(s->pb); if (header_size > start_offset) return AVERROR_INVALIDDATA; if (header_size == 0) start_offset = 0x800; coef[0] = avio_rl32(s->pb); coef[1] = avio_rl32(s->pb); c->dsp_int_type = avio_rl32(s->pb); coef_type = avio_rl32(s->pb); coef_splitted[0] = avio_rl32(s->pb); coef_splitted[1] = avio_rl32(s->pb); if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_THP) { if (st->codecpar->channels > 2) { avpriv_request_sample(s, "channels %d>2", st->codecpar->channels); return AVERROR_PATCHWELCOME; } ff_alloc_extradata(st->codecpar, 32 * st->codecpar->channels); for (ch = 0; ch < st->codecpar->channels; ch++) { if (coef_type & 1) { avpriv_request_sample(s, "coef_type & 1"); return AVERROR_PATCHWELCOME; } else { avio_seek(s->pb, coef[ch], SEEK_SET); avio_read(s->pb, st->codecpar->extradata + 32 * ch, 32); } } if (c->dsp_int_type == 1) { st->codecpar->block_align = 8 * st->codecpar->channels; if (c->interleave_size != 1 && c->interleave_size != 2 && c->interleave_size != 4) return AVERROR_INVALIDDATA; } } avio_skip(s->pb, start_offset - avio_tell(s->pb)); avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); return 0; }
1threat
how is docker-compose better than normal docker? : <p>i'm currently using normal docker in my django-react application and have been asked to switch to docker compose. Please tell me how is it better than normal docker for testing and production.</p>
0debug
int mmubooke_get_physical_address (CPUState *env, mmu_ctx_t *ctx, target_ulong address, int rw, int access_type) { ppcemb_tlb_t *tlb; target_phys_addr_t raddr; int i, prot, ret; ret = -1; raddr = -1; for (i = 0; i < env->nb_tlb; i++) { tlb = &env->tlb[i].tlbe; if (ppcemb_tlb_check(env, tlb, &raddr, address, env->spr[SPR_BOOKE_PID], 1, i) < 0) continue; if (msr_pr != 0) prot = tlb->prot & 0xF; else prot = (tlb->prot >> 4) & 0xF; if (access_type == ACCESS_CODE) { if (msr_ir != (tlb->attr & 1)) continue; ctx->prot = prot; if (prot & PAGE_EXEC) { ret = 0; break; } ret = -3; } else { if (msr_dr != (tlb->attr & 1)) continue; ctx->prot = prot; if ((!rw && prot & PAGE_READ) || (rw && (prot & PAGE_WRITE))) { ret = 0; break; } ret = -2; } } if (ret >= 0) ctx->raddr = raddr; return ret; }
1threat
HOW TO PRINT "THAT'S IT!" IN PHP? WITH DOUBLE AND SINGLE QUOTATIONS? : <p>I want to print "that's it!" Exactly as same with double and single quotations in php? Can anyone have solution?</p>
0debug
how to make an array of NSStrings? : <p>If anyone knows how to make an array filled with NSStrings i could really use some help with this can't find a good example of this anywhere on the net, this isn't home work because its not due but it is a question that is on a pdf of questions my teacher gave me to study, just can't seem to figure this one out. so if anyone knows an example with some explanation would be great, thanks for taking your time on this.</p>
0debug
Equivalent of constexpr from C++? : <p>See this code:</p> <pre><code>fn main() { let something_const = 42; fn multiply(nbr: i32) -&gt; i32 { nbr * something_const } println!("{}", multiply(1)); } </code></pre> <p><code>rustc</code> outputs that</p> <pre class="lang-none prettyprint-override"><code>error[E0434]: can't capture dynamic environment in a fn item; use the || { ... } closure form instead --&gt; main.rs:19:15 | 19 | nbr * something_const | ^^^^^^^^^^^^^^^ </code></pre> <p>But <code>something_const</code> is not dynamic, because it is known at compile time.</p> <p>Is it an equivalent in Rust of the C++ <code>constexpr</code> mechanism?</p>
0debug
JSON Web Token (JWT) : Authorization vs Authentication : <p>JWT terminology has been bothering me for few reasons. Is JWT suitable for Authorization or is it only for Authentication?</p> <p>Correct me if I'm wrong but I have always read Authorization as being the act of allowing someone access to a resource yet JWT doesn't seem to have any implementation that actually allows access to users to a given resource. All JWT implementations talk about is providing a user a token . This token is then passed with every call to a back-end service endpoint where it is checked for validity and if valid access is granted. So we can use JWT for <strong>Authentication</strong> of any user but how can we restrict the access to particular valid users ?</p> <p>How can we use JWT for restricting few users depending on roles they have ? Do JWT provide any type Authorization details as well or it just provide us Authetication ?</p> <p>Thanks in advance for your help and reading my doubt patiently.</p>
0debug
OpenJDK JDK11 not having JMC- Java Mission Controller- FlightRecorder : <p>I was hoping JMC would be available with OpenJDK, JDK11 binaries as this has been opensourced from Java 11 by oracle, but could not locate this in Oracle and AdoptOpenJDK Java-11 binaries under bin folder. I have also tried this <a href="https://jdk.java.net/jmc/" rel="noreferrer">https://jdk.java.net/jmc/</a> as some article said its being releases separately. Does anyone know how to get JMC for OpenJDK-11.</p>
0debug
Java: Error parse date's string to date object : <p>I try to convert string to date on java. I read and try the example from this website <a href="https://www.mkyong.com/java/java-date-and-calendar-examples/" rel="nofollow">"Java Date and Calendar examples"</a> but I still cannot compile and run it. </p> <p>This is my code.</p> <pre><code>package javaapplication5; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class JavaApplication5 { public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss"); String dateInString = "31-08-1982 10:20:56"; Date date = sdf.parse(dateInString); System.out.println(date); } } </code></pre> <p>And I got this error.</p> <pre><code>Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - unreported exception java.text.ParseException; must be caught or declared to be thrown </code></pre> <p>What I missing or do it wrong? Thank you for help.</p>
0debug
static void quantize_bands(int (*out)[2], const float *in, const float *scaled, int size, float Q34, int is_signed, int maxval) { int i; double qc; for (i = 0; i < size; i++) { qc = scaled[i] * Q34; out[i][0] = (int)FFMIN((int)qc, maxval); out[i][1] = (int)FFMIN((int)(qc + 0.4054), maxval); if (is_signed && in[i] < 0.0f) { out[i][0] = -out[i][0]; out[i][1] = -out[i][1]; } } }
1threat
PHP Find and replace a part of string with regex : <p>I want to find and replace a part of string start and end with. Example:</p> <pre><code>&lt;LAT&gt;43.654209136963&lt;/LATS&gt; &lt;LONGS&gt;-0.59365832805634&lt;/LONGS&gt; &lt;LAT&gt;44.362339019775&lt;/LATE&gt; </code></pre> <p>Become:</p> <pre><code>&lt;LATS&gt;43.654209136963&lt;/LATS&gt; &lt;LONGS&gt;-0.59365832805634&lt;/LONGS&gt; &lt;LATE&gt;44.362339019775&lt;/LATE&gt; -Line1: &lt;LAT&gt; =&gt; &lt;LATS&gt; -Line3: &lt;LAT&gt; =&gt; &lt;LATE&gt; </code></pre> <p>Thanks for your helo</p>
0debug
static bool migration_object_check(MigrationState *ms, Error **errp) { if (!migrate_params_check(&ms->parameters, errp)) { return false; } return true; }
1threat
php(json_encode returns null)! : <p>i am trying to write kind of user client server using java(android) and php.i asked this question before but no one answer my question.my database is utf8.i am nearly for two weeks trying to solve the problem of this part but i couldn't. the problem is: I have one array that it contains my database rows and when you use:</p> <pre><code>print_r ($jasonData); </code></pre> <p>and give an output from that you can see it's not null but when i use:</p> <pre><code>echo json_encode($jasonData); </code></pre> <p>it shows null and i can't understand why it can happens. i've searched in stack before and i saw every related questions.but they didn't work for me. also the</p> <pre><code>echo json_last_error(); </code></pre> <p>shows 0.</p> <pre><code>&lt;?php $hostname = "localhost"; $dbname = "amir"; $dbpass = "123456"; $con = new mysqli($hostname,$dbname,$dbpass,'amir'); $jasonData = array(); $sql="select Username , Password from User_Login "; if($result = $con-&gt;query($sql)){ while($row = $result-&gt;fetch_row()){ $jasonData[] = array_map('utf8_encode', $row); /* print $row[0]; print $row[1]; */ } } print_r ($jasonData); echo json_encode($jsonData); print json_last_error(); $con-&gt;close(); </code></pre> <p>If anyone knows why that happens,please give me an advice how can i fix that.</p>
0debug
static void pci_map(PCIDevice * pci_dev, int region_num, uint32_t addr, uint32_t size, int type) { PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, pci_dev); EEPRO100State *s = &d->eepro100; logout("region %d, addr=0x%08x, size=0x%08x, type=%d\n", region_num, addr, size, type); assert(region_num == 1); register_ioport_write(addr, size, 1, ioport_write1, s); register_ioport_read(addr, size, 1, ioport_read1, s); register_ioport_write(addr, size, 2, ioport_write2, s); register_ioport_read(addr, size, 2, ioport_read2, s); register_ioport_write(addr, size, 4, ioport_write4, s); register_ioport_read(addr, size, 4, ioport_read4, s); s->region[region_num] = addr; }
1threat
MPAndroidChart - Adding labels to bar chart : <p>It is necessary for my application to have a label on each bar of the bar chart. Is there a way to do this with MPAndroidChart? I could not find a way to do this on the project wiki/javadocs.</p> <p>If there isn't a way to do this is there another software that will allow me to?</p> <p><a href="https://i.stack.imgur.com/dGrlb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dGrlb.png" alt="enter image description here"></a></p>
0debug
static void virgl_cmd_get_capset(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_get_capset gc; struct virtio_gpu_resp_capset *resp; uint32_t max_ver, max_size; VIRTIO_GPU_FILL_CMD(gc); virgl_renderer_get_cap_set(gc.capset_id, &max_ver, &max_size); if (!max_size) { cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; return; } resp = g_malloc(sizeof(*resp) + max_size); resp->hdr.type = VIRTIO_GPU_RESP_OK_CAPSET; virgl_renderer_fill_caps(gc.capset_id, gc.capset_version, (void *)resp->capset_data); virtio_gpu_ctrl_response(g, cmd, &resp->hdr, sizeof(*resp) + max_size); g_free(resp); }
1threat
javascript/jquery modify a specific elements class height and width : I have a list of elements where I would like to modify one of the classes height and width that are not equal to a specific class. For instance I have the element list let ganttRows = $('.white-grid-row'); let classesToKeep = ['gantt_row', 'task-parent', 'white-grid-row', 'odd']; for (let i = 0; i < ganttRows.length; i++) { for (let j = 0; j < ganttRows[i].classList.length; j++) { if (!classesToKeep.includes(ganttRows[i].classList[j])) { let className = ganttRows[i].classList[j]; $("." + className).css('width', 33);//changes element width not the class width //modify that randomly generated class height and width ONLY FOR THIS ELEMENT. //this part I'm not sure how to do. } } } How can I modify the height and width of that randomly generated class?
0debug
static int gxf_packet(AVFormatContext *s, AVPacket *pkt) { ByteIOContext *pb = s->pb; pkt_type_t pkt_type; int pkt_len; while (!url_feof(pb)) { int track_type, track_id, ret; int field_nr; if (!parse_packet_header(pb, &pkt_type, &pkt_len)) { if (!url_feof(pb)) av_log(s, AV_LOG_ERROR, "GXF: sync lost\n"); return -1; } if (pkt_type == PKT_FLT) { gxf_read_index(s, pkt_len); continue; } if (pkt_type != PKT_MEDIA) { url_fskip(pb, pkt_len); continue; } if (pkt_len < 16) { av_log(s, AV_LOG_ERROR, "GXF: invalid media packet length\n"); continue; } pkt_len -= 16; track_type = get_byte(pb); track_id = get_byte(pb); field_nr = get_be32(pb); get_be32(pb); get_be32(pb); get_byte(pb); get_byte(pb); , it might be better to take this into account ret = av_get_packet(pb, pkt, pkt_len); pkt->stream_index = get_sindex(s, track_id, track_type); pkt->dts = field_nr; return ret; } return AVERROR(EIO); }
1threat
$_POST open in new edited tab : <pre><code> &lt;form method="post" target="_blank" action="battle.php" onsubmit="window.open('battle.php','','width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=0,resizable=0,left=30,top=0');" &gt; &lt;input type="hidden" name="username" value="&lt;?php echo $username; ?&gt;"/&gt; &lt;input type="hidden" name="password" value="&lt;?php echo $password; ?&gt;"/&gt; &lt;input type="submit" value="OPEN TO BATTLE.php"/&gt; &lt;/form&gt; </code></pre> <p>^^Working but not the way I want it.</p> <p>I am trying to make this form open a new window at the size <code>'width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=0,resizable=0,left=30,top=0'</code>when the Submit button is clicked.</p> <p>I want it so that the $_POST data is transfered through to the new webpage</p>
0debug
how to read 2 txt files and write the result in a third file using python : <p>I have 3 files with the following content:</p> <p>today.txt</p> <p><strong>570</strong></p> <p>yesterday.txt</p> <p><strong>500</strong></p> <p>now.txt</p> <p><strong>0</strong></p> <p>Basically, i need to read the first 2 files and write the result in the third file:</p> <p>today.txt - yesterday.txt = now.txt (570 - 500 = 70) </p>
0debug
Cant send parameter containing "#" to dot net web service from ajax.any help wud be appriciated : var s=encodeURI("http://subdomain.mydomain.domain.asmx/getData?OUserId=" + UserId + "&Token=" + Token + "&OrgId=" + OrgId + '&Message=' + Message + '&Schoolid=' + SchoolId + '&SessionId=" ' + SessionId + '&UnicodeValue=' + UnicodeValue + '&ClassID='+ ClassIdCommaSeparated.toString()); $.ajax({ url: s, error: function (err) { alert(err); }, success: function (data) {....} here classIdcommaseparate is 1#1#1#1#1,1#1#1#1#1,1#1#1#1#1
0debug
error with plotting keras NN (matplotlib) : <p>Im getting the errors below when trying to run the code in this tutorial <a href="https://github.com/llSourcell/ethereum_future/blob/master/A%20Deep%20Learning%20Approach%20to%20Predicting%20Cryptocurrency%20Prices.ipynb/" rel="nofollow noreferrer">tutorial</a>. I was able to fix the previous errors but im getting stuck at this point since the training for this network takes like 10 minutes. </p> <p>When i go to line 254 its just a commented out line with no code and I cant see anything wrong with the plt.show command. I cant find the return statement it says is at line 254 in the code so im not sure what the issue is. Can anyone see what it is ?</p> <pre><code>Traceback (most recent call last): line 52, in run_file pydev_imports.execfile(file, globals, locals) # execute the script line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) line 369, in &lt;module&gt; plt.show(fig1) line 254, in show return _show(*args, **kw) TypeError: __call__() takes 1 positional argument but 2 were given </code></pre>
0debug
How to Find a String Among Thousands of Code Pages? : <p>Lets say you downloaded a free PHP script from GitHub and it has thousands of PHP files, language files, etc.</p> <p>Now if you need to customize a specific line of code and you don't know where it is located, you have to go through each file to find where it belongs to and after spending a huge amount of time, you may be lucky to find it.</p> <p>Is there any way to find the code faster (offline or in cPanel)?</p>
0debug
Window.open with 'noopener' opens a new window instead of a new tab : <p>I was using <code>window.open('')</code> with <code>'_blank'</code> as second parameter to open my link in new tab For eg. <code>window.open('http://google.com', '_blank')</code></p> <p>But, recently I added the third parameter <code>'noopener'</code> so that <code>window.opener</code> becomes null in the new tab and the new tab does not have access to the parent tab/window. i.e. <code>window.opener</code> is <code>null</code></p> <p><code>window.open('http://google.com', '_blank', 'noopener')</code></p> <p>So the above code solved the security problem, but instead of opening a new tab, a new window started opening which is not what I expected. My browser settings were same and no changes were made to it.</p> <p>Is there anything I can do to make this code open new tab instead of new window ? I do not want to remove <code>noopener</code> as third parameter</p>
0debug
static void vhost_set_memory(MemoryListener *listener, MemoryRegionSection *section, bool add) { struct vhost_dev *dev = container_of(listener, struct vhost_dev, memory_listener); hwaddr start_addr = section->offset_within_address_space; ram_addr_t size = int128_get64(section->size); bool log_dirty = memory_region_get_dirty_log_mask(section->mr) & ~(1 << DIRTY_MEMORY_MIGRATION); int s = offsetof(struct vhost_memory, regions) + (dev->mem->nregions + 1) * sizeof dev->mem->regions[0]; void *ram; dev->mem = g_realloc(dev->mem, s); if (log_dirty) { add = false; } assert(size); ram = memory_region_get_ram_ptr(section->mr) + section->offset_within_region; if (add) { if (!vhost_dev_cmp_memory(dev, start_addr, size, (uintptr_t)ram)) { return; } } else { if (!vhost_dev_find_reg(dev, start_addr, size)) { return; } } vhost_dev_unassign_memory(dev, start_addr, size); if (add) { vhost_dev_assign_memory(dev, start_addr, size, (uintptr_t)ram); } else { vhost_dev_unassign_memory(dev, start_addr, size); } dev->mem_changed_start_addr = MIN(dev->mem_changed_start_addr, start_addr); dev->mem_changed_end_addr = MAX(dev->mem_changed_end_addr, start_addr + size - 1); dev->memory_changed = true; }
1threat
static int decode_init(AVCodecContext *avctx) { LclContext * const c = (LclContext *)avctx->priv_data; int basesize = avctx->width * avctx->height; int zret; c->avctx = avctx; avctx->has_b_frames = 0; c->pic.data[0] = NULL; #ifdef CONFIG_ZLIB memset(&(c->zstream), 0, sizeof(z_stream)); #endif if (avctx->extradata_size < 8) { av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n"); return 1; } if (((avctx->codec_id == CODEC_ID_MSZH) && (*((char *)avctx->extradata + 7) != CODEC_MSZH)) || ((avctx->codec_id == CODEC_ID_ZLIB) && (*((char *)avctx->extradata + 7) != CODEC_ZLIB))) { av_log(avctx, AV_LOG_ERROR, "Codec id and codec type mismatch. This should not happen.\n"); } switch (c->imgtype = *((char *)avctx->extradata + 4)) { case IMGTYPE_YUV111: c->decomp_size = basesize * 3; av_log(avctx, AV_LOG_INFO, "Image type is YUV 1:1:1.\n"); break; case IMGTYPE_YUV422: c->decomp_size = basesize * 2; av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:2:2.\n"); break; case IMGTYPE_RGB24: c->decomp_size = basesize * 3; av_log(avctx, AV_LOG_INFO, "Image type is RGB 24.\n"); break; case IMGTYPE_YUV411: c->decomp_size = basesize / 2 * 3; av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:1:1.\n"); break; case IMGTYPE_YUV211: c->decomp_size = basesize * 2; av_log(avctx, AV_LOG_INFO, "Image type is YUV 2:1:1.\n"); break; case IMGTYPE_YUV420: c->decomp_size = basesize / 2 * 3; av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:2:0.\n"); break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported image format %d.\n", c->imgtype); return 1; } c->compression = *((char *)avctx->extradata + 5); switch (avctx->codec_id) { case CODEC_ID_MSZH: switch (c->compression) { case COMP_MSZH: av_log(avctx, AV_LOG_INFO, "Compression enabled.\n"); break; case COMP_MSZH_NOCOMP: c->decomp_size = 0; av_log(avctx, AV_LOG_INFO, "No compression.\n"); break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported compression format for MSZH (%d).\n", c->compression); return 1; } break; case CODEC_ID_ZLIB: #ifdef CONFIG_ZLIB switch (c->compression) { case COMP_ZLIB_HISPEED: av_log(avctx, AV_LOG_INFO, "High speed compression.\n"); break; case COMP_ZLIB_HICOMP: av_log(avctx, AV_LOG_INFO, "High compression.\n"); break; case COMP_ZLIB_NORMAL: av_log(avctx, AV_LOG_INFO, "Normal compression.\n"); break; default: if ((c->compression < Z_NO_COMPRESSION) || (c->compression > Z_BEST_COMPRESSION)) { av_log(avctx, AV_LOG_ERROR, "Unusupported compression level for ZLIB: (%d).\n", c->compression); return 1; } av_log(avctx, AV_LOG_INFO, "Compression level for ZLIB: (%d).\n", c->compression); } #else av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n"); return 1; #endif break; default: av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in compression switch.\n"); return 1; } if (c->decomp_size) { if ((c->decomp_buf = av_malloc(c->decomp_size+4*8)) == NULL) { av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); return 1; } } c->flags = *((char *)avctx->extradata + 6); if (c->flags & FLAG_MULTITHREAD) av_log(avctx, AV_LOG_INFO, "Multithread encoder flag set.\n"); if (c->flags & FLAG_NULLFRAME) av_log(avctx, AV_LOG_INFO, "Nullframe insertion flag set.\n"); if ((avctx->codec_id == CODEC_ID_ZLIB) && (c->flags & FLAG_PNGFILTER)) av_log(avctx, AV_LOG_INFO, "PNG filter flag set.\n"); if (c->flags & FLAGMASK_UNUSED) av_log(avctx, AV_LOG_ERROR, "Unknown flag set (%d).\n", c->flags); if (avctx->codec_id == CODEC_ID_ZLIB) { #ifdef CONFIG_ZLIB c->zstream.zalloc = Z_NULL; c->zstream.zfree = Z_NULL; c->zstream.opaque = Z_NULL; zret = inflateInit(&(c->zstream)); if (zret != Z_OK) { av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); return 1; } #else av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n"); return 1; #endif } avctx->pix_fmt = PIX_FMT_BGR24; return 0; }
1threat
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){ HYuvContext *s = avctx->priv_data; const int width= s->width; const int width2= s->width>>1; const int height= s->height; int fake_ystride, fake_ustride, fake_vstride; AVFrame * const p= &s->picture; AVFrame *picture = data; *data_size = 0; if (buf_size == 0) return 0; bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4); init_get_bits(&s->gb, s->bitstream_buffer, buf_size); p->reference= 0; if(avctx->get_buffer(avctx, p) < 0){ fprintf(stderr, "get_buffer() failed\n"); return -1; } fake_ystride= s->interlaced ? p->linesize[0]*2 : p->linesize[0]; fake_ustride= s->interlaced ? p->linesize[1]*2 : p->linesize[1]; fake_vstride= s->interlaced ? p->linesize[2]*2 : p->linesize[2]; s->last_slice_end= 0; if(s->bitstream_bpp<24){ int y, cy; int lefty, leftu, leftv; int lefttopy, lefttopu, lefttopv; if(s->yuy2){ p->data[0][3]= get_bits(&s->gb, 8); p->data[0][2]= get_bits(&s->gb, 8); p->data[0][1]= get_bits(&s->gb, 8); p->data[0][0]= get_bits(&s->gb, 8); fprintf(stderr, "YUY2 output isnt implemenetd yet\n"); return -1; }else{ leftv= p->data[2][0]= get_bits(&s->gb, 8); lefty= p->data[0][1]= get_bits(&s->gb, 8); leftu= p->data[1][0]= get_bits(&s->gb, 8); p->data[0][0]= get_bits(&s->gb, 8); switch(s->predictor){ case LEFT: case PLANE: decode_422_bitstream(s, width-2); lefty= add_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= add_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu); leftv= add_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv); } for(cy=y=1; y<s->height; y++,cy++){ uint8_t *ydst, *udst, *vdst; if(s->bitstream_bpp==12){ decode_gray_bitstream(s, width); ydst= p->data[0] + p->linesize[0]*y; lefty= add_left_prediction(ydst, s->temp[0], width, lefty); if(s->predictor == PLANE){ if(y>s->interlaced) s->dsp.add_bytes(ydst, ydst - fake_ystride, width); } y++; if(y>=s->height) break; } draw_slice(s, y); ydst= p->data[0] + p->linesize[0]*y; udst= p->data[1] + p->linesize[1]*cy; vdst= p->data[2] + p->linesize[2]*cy; decode_422_bitstream(s, width); lefty= add_left_prediction(ydst, s->temp[0], width, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= add_left_prediction(udst, s->temp[1], width2, leftu); leftv= add_left_prediction(vdst, s->temp[2], width2, leftv); } if(s->predictor == PLANE){ if(cy>s->interlaced){ s->dsp.add_bytes(ydst, ydst - fake_ystride, width); if(!(s->flags&CODEC_FLAG_GRAY)){ s->dsp.add_bytes(udst, udst - fake_ustride, width2); s->dsp.add_bytes(vdst, vdst - fake_vstride, width2); } } } } draw_slice(s, height); break; case MEDIAN: decode_422_bitstream(s, width-2); lefty= add_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= add_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu); leftv= add_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv); } cy=y=1; if(s->interlaced){ decode_422_bitstream(s, width); lefty= add_left_prediction(p->data[0] + p->linesize[0], s->temp[0], width, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= add_left_prediction(p->data[1] + p->linesize[2], s->temp[1], width2, leftu); leftv= add_left_prediction(p->data[2] + p->linesize[1], s->temp[2], width2, leftv); } y++; cy++; } decode_422_bitstream(s, 4); lefty= add_left_prediction(p->data[0] + fake_ystride, s->temp[0], 4, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= add_left_prediction(p->data[1] + fake_ustride, s->temp[1], 2, leftu); leftv= add_left_prediction(p->data[2] + fake_vstride, s->temp[2], 2, leftv); } lefttopy= p->data[0][3]; decode_422_bitstream(s, width-4); add_median_prediction(p->data[0] + fake_ystride+4, p->data[0]+4, s->temp[0], width-4, &lefty, &lefttopy); if(!(s->flags&CODEC_FLAG_GRAY)){ lefttopu= p->data[1][1]; lefttopv= p->data[2][1]; add_median_prediction(p->data[1] + fake_ustride+2, p->data[1]+2, s->temp[1], width2-2, &leftu, &lefttopu); add_median_prediction(p->data[2] + fake_vstride+2, p->data[2]+2, s->temp[2], width2-2, &leftv, &lefttopv); } y++; cy++; for(; y<height; y++,cy++){ uint8_t *ydst, *udst, *vdst; if(s->bitstream_bpp==12){ while(2*cy > y){ decode_gray_bitstream(s, width); ydst= p->data[0] + p->linesize[0]*y; add_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy); y++; } if(y>=height) break; } draw_slice(s, y); decode_422_bitstream(s, width); ydst= p->data[0] + p->linesize[0]*y; udst= p->data[1] + p->linesize[1]*cy; vdst= p->data[2] + p->linesize[2]*cy; add_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy); if(!(s->flags&CODEC_FLAG_GRAY)){ add_median_prediction(udst, udst - fake_ustride, s->temp[1], width2, &leftu, &lefttopu); add_median_prediction(vdst, vdst - fake_vstride, s->temp[2], width2, &leftv, &lefttopv); } } draw_slice(s, height); break; } } }else{ int y; int leftr, leftg, leftb; const int last_line= (height-1)*p->linesize[0]; if(s->bitstream_bpp==32){ p->data[0][last_line+3]= get_bits(&s->gb, 8); leftr= p->data[0][last_line+2]= get_bits(&s->gb, 8); leftg= p->data[0][last_line+1]= get_bits(&s->gb, 8); leftb= p->data[0][last_line+0]= get_bits(&s->gb, 8); }else{ leftr= p->data[0][last_line+2]= get_bits(&s->gb, 8); leftg= p->data[0][last_line+1]= get_bits(&s->gb, 8); leftb= p->data[0][last_line+0]= get_bits(&s->gb, 8); skip_bits(&s->gb, 8); } if(s->bgr32){ switch(s->predictor){ case LEFT: case PLANE: decode_bgr_bitstream(s, width-1); add_left_prediction_bgr32(p->data[0] + last_line+4, s->temp[0], width-1, &leftr, &leftg, &leftb); for(y=s->height-2; y>=0; y--){ decode_bgr_bitstream(s, width); add_left_prediction_bgr32(p->data[0] + p->linesize[0]*y, s->temp[0], width, &leftr, &leftg, &leftb); if(s->predictor == PLANE){ if((y&s->interlaced)==0){ s->dsp.add_bytes(p->data[0] + p->linesize[0]*y, p->data[0] + p->linesize[0]*y + fake_ystride, fake_ystride); } } } draw_slice(s, height); break; default: fprintf(stderr, "prediction type not supported!\n"); } }else{ fprintf(stderr, "BGR24 output isnt implemenetd yet\n"); return -1; } } emms_c(); *picture= *p; avctx->release_buffer(avctx, p); *data_size = sizeof(AVFrame); return (get_bits_count(&s->gb)+7)>>3; }
1threat
json data with out array name : [{"ash_id":"1","asg_code":"1226","ash_name":"hello","ash_cell":"123","ash_nic":"123","ash_long":"34.015","ash_lat":"71.5805","zm_id":null,"created_by":"0","created_date":"0000-00-00 00:00:00","last_updated":"2016-08-29 07:52:35"}] i have array without array name i can read data if there is name of jason array but i am un able to do that with this type of array any suggestion my code for josn with array name`String json = serviceClient.makeServiceCall(URL_ITEMS, ServiceHandler.GET); // print the json response in the log Log.d("Get match fixture resps", "> " + json); if (json != null) { try { Log.d("try", "in the try"); JSONObject jsonObj = new JSONObject(json); Log.d("jsonObject", "new json Object"); // Getting JSON Array node matchFixture = jsonObj.getJSONArray(TAG_FIXTURE); Log.d("json aray", "user point array"); int len = matchFixture.length(); Log.d("len", "get array length"); for (int i = 0; i < matchFixture.length(); i++) { JSONObject c = matchFixture.getJSONObject(i); Double matchId = Double.parseDouble(c.getString(TAG_MATCHID)); Log.d("matchId", String.valueOf(matchId)); Double teamA = Double.valueOf(c.getString(TAG_TEAMA)); Log.d("teamA", String.valueOf(teamA)); String teamB = c.getString(TAG_TEAMB); Log.d("teamB", teamB);`
0debug
static inline void gen_bx_im(DisasContext *s, uint32_t addr) { TCGv tmp; s->is_jmp = DISAS_UPDATE; if (s->thumb != (addr & 1)) { tmp = new_tmp(); tcg_gen_movi_i32(tmp, addr & 1); tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUState, thumb)); dead_tmp(tmp); } tcg_gen_movi_i32(cpu_R[15], addr & ~1); }
1threat
Hamcrest When to use Is or equalTo : <p>I'm new using hamcrest. While I'm discovering how to use it I have been a doubt about when to use <code>is</code> or <code>equalTo</code>. </p> <p>Is there any difference between <code>is</code> and <code>equalTo</code>, although it is conceptually or ocasionally? It seems to behave the same. </p> <pre><code> Assert.assertThat(actual, equalTo("blue")); Assert.assertThat(actual, is("red")); </code></pre> <p>Why do you would use one instead of the other?</p>
0debug
How to remove duplicate row in table : <p>I am new in codeigniter frame work and I am trying to stop duplicate record in my table In my table record are repeat I want to show one record at one time</p> <p>This is my code</p> <p>Controller</p> <pre><code> $modelResult = $this-&gt;freightBillModel-&gt;freightBillByDate($data); &lt;table id="freight_table" class="table table-bordered table-striped table-sm" style="display:block; overflow: auto; "&gt; &lt;tr&gt; &lt;th&gt;SR.No&lt;/th&gt; &lt;th&gt;Bill No&lt;/th&gt; &lt;th&gt;pkgs&lt;/th&gt; &lt;th&gt;freight&lt;/th&gt; &lt;/tr&gt; &lt;tbody&gt; &lt;?php $counter = 1; ?&gt; &lt;?php foreach($modelResult as $freight){?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $counter;?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $freight['tbb_no'];?&gt;&lt;/td&gt; &lt;?php $singleBill = $this-&gt;freightBillModel-&gt;fetchBillByNo($freight['tbb_no']); ?&gt; &lt;?php $lr_freight=0; $no_of_pkgs=0; ?&gt; &lt;?php foreach ($singleBill as $bill) : ?&gt; &lt;?php $lr_freight+=$bill-&gt;lr_freight; ?&gt; &lt;?php $no_of_pkgs+=$bill-&gt;no_of_pkgs; ?&gt; &lt;?php endforeach; ?&gt; &lt;td&gt;&lt;?php echo $no_of_pkgs;?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $lr_freight;?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php $counter++; ?&gt; &lt;?php }?&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Model:</p> <pre><code> public function freightBillByDate($data){ extract($data); $this-&gt;db-&gt;select('bn.branch_name as to,ts_tbb.tbb_no,ts_tbb.tbb_id,ts_tbb.bilty_id,ts_tbb.current_time,ts_tbb.status,b.*'); $this-&gt;db-&gt;from('ts_tbb'); $this-&gt;db-&gt;join('bilty b', 'b.id = ts_tbb.bilty_id'); $this-&gt;db-&gt;join('branch bn', 'b.lr_to=bn.branch_id'); $this-&gt;db-&gt;where('lr_from',$lr_from); $this-&gt;db-&gt;where('lr_to',$lr_to); if($bill_type=="pending_bill"){ $this-&gt;db-&gt;where('billed_status','not_billed'); }else if($bill_type=="bill_register"){ $this-&gt;db-&gt;where('billed_status','billed'); } $this-&gt;db-&gt;order_by('lr_date','desc'); $query=$this-&gt;db-&gt;get(); return $query-&gt;result_array(); } function fetchBillByNo($billNo){ return $this-&gt;db-&gt;select('*')-&gt;from('ts_tbb')-&gt;join('bilty','bilty_id=bilty.id')-&gt;where('tbb_no',$billNo)-&gt;get()-&gt;result(); }[![In this picture first two records are repeat][1]][1] </code></pre> <p>I want to show unique records, Current table it shows duplicate rows Please tell me where i am wrong in my code</p>
0debug
void *ff_schro_queue_pop(FFSchroQueue *queue) { FFSchroQueueElement *top = queue->p_head; if (top) { void *data = top->data; queue->p_head = queue->p_head->next; --queue->size; av_freep(&top); return data; } return NULL; }
1threat
static const uint8_t *avc_mp4_find_startcode(const uint8_t *start, const uint8_t *end, int nal_length_size) { int res = 0; if (end - start < nal_length_size) return NULL; while (nal_length_size--) res = (res << 8) | *start++; if (start + res > end || res < 0 || start + res < start) return NULL; return start + res; }
1threat
Im Getting an Error:Illegal Expression : im still kinda new to pascal but im getting an error thats torturing me a bit can u guys help? i get a error:illegal expression and Fatal: Syntax error, ; expected but : found The Pascal Piece is below: Program PaidUp; const size=30; var payment,totm1,totm2,totm3:real; section1,section2,section3,i,j,idnum:integer; IDNUMARR:array[1..999] of integer; PAYMENTARR:array[1..size] of real; Procedure InitialiseVariables; {This procedure initialises all variables used in the program} Begin idnum:=0; payment:=0; totm1:=0; totm2:=0; totm3:=0; section1:=0; section2:=0; section3:=0; i:=0; j:=0; End; {Initialise Variables} Procedure DeclareandInitialiseArrays; {This procedure declares and initialises all arrays used in the program} Begin IDNUMARR:array[1..999] of integer; PAYMENTARR:array[1..size] of real; For i:=1 to size do begin idnum[i]:=0; payment[i]:=0; end; {ends for statment} End; {Declare and Initialise Variables} Procedure PutDataIntoArray; {This procedure puts the data into the arrays} Begin while(idnum<>0 and payment<>0 and payment=1350 and payment=1620 and payment=1800 and payment=1650 and payment=1980 and payment=2200) do begin writeln('Invalid value, please enter another value'); readln(idnum); readln(payment); end;{ends while statement} set j:=j+1; idnum[j]:=idnum; payment[j]:=payment; End; {Put Data Into Array} Procedure DetermineStatisticsInformation; {This procedure determines which masqueraders belong to which group, tallys the total persons in a section and totals the amount of money paid in each section for costumes} Begin For j:=1 to size do begin if(payment[j]=1350 and payment[j]=1650) then begin writeln('Masquerader with memid:idnum[j] belongs to section1'); section1:= section1+1; totm1:= totm1+payment[j]; end;{ends if statement} if(payment[j]=1620 and payment[j]=1980) then begin writeln('Masquerader with memid:idnum[j] belongs to section2'); section2:= section2+1; totm2:=totm2+payment[j]; end;{ends if statement} if(payment[j]=1800 and payment[j]=2200)then begin writeln('Masquerader with memid:idnum[j] belongs to section3'); section3:= section3+1; totm3:=totm3+payment[j]; end;{ends if statement} End. {Determine Statistics Information} Procedure PrintResults; {This procedure outputs all information} Begin writeln('The number of masqueraders in section 1 is:', section1); writeln('The number of masqueraders in section 2 is:', section2); writeln('The number of masqueraders in section 3 is:', section3); writeln('Total Amount of money paid in section 1 is:', totm1); writeln('Total Amount of money paid in section 2 is:', totm2); writeln('Total Amount of money paid in section 3 is:', totm3); End. {Print Results}
0debug
void acpi_gpe_init(ACPIREGS *ar, uint8_t len) { ar->gpe.len = len; ar->gpe.sts = g_malloc0(len / 2); ar->gpe.en = g_malloc0(len / 2); }
1threat
Is there an Objective-C equivalent to Swift's fatalError? : <p>I want to discard superclass's default init method.I can achieve this easily with <code>fatalError</code> in Swift:</p> <pre><code>class subClass:NSObject{ private var k:String! override init(){ fatalError("init() has not been implemented") } init(kk:String){ k = kk } } </code></pre> <p>How can I do it in Objective-C?</p>
0debug
int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata) { CacheItem *it = NULL; g_assert(cache); g_assert(cache->page_cache); it = cache_get_by_addr(cache, addr); if (!it->it_data) { it->it_data = g_try_malloc(cache->page_size); if (!it->it_data) { DPRINTF("Error allocating page\n"); return -1; } cache->num_items++; } memcpy(it->it_data, pdata, cache->page_size); it->it_age = ++cache->max_item_age; it->it_addr = addr; return 0; }
1threat
Checking if the value for the key is the same as before Python : I have been working on this code and I cannot find a answer. 1. I have 2 lists point_values = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10] letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] 2. I want to set `a:1` and `b:3` and so on... >I want them set in a dictionary called `point_values`. **How should I do this?**
0debug
How to untrack files (git and git GUI) : <p>I am using git GUI (together with Git bash). Now, I know if I want to ignore files for git I have to put them in a .gitignore file. </p> <p>1)I have come to know that git in windows does not create a .gitignore file for you and you have to create it yourself. Also git GUI won't do that. Is this correct?</p> <p>Now my special situation:</p> <p>I made a mistake in the beginning of managing this project and together with my .c and .h files I also tracked another file (let's call it "shouldnottrack.file"). This file is generated by the build process, so in principle should not be tracked. </p> <p>But I did it and it was included in the commits (staged, commited etc).</p> <p>Now, I want to <strong>untrack</strong> this file. </p> <p>I have done it temporalily by doing <code>git checkout -- shouldnottrack.file</code> but this works only once</p> <p>2) How can I untrack this file? (GUI, command, any method ok)</p> <p>3) If I include this file in the .gitignore file, will git untrack it automatically?</p> <p>thanks</p>
0debug
file read exception handle : I am getting this error "Exception thrown at 0x0FC04AFF (vcruntime140d.dll) in Ergasia.exe: 0xC0000005: Access violation writing location 0x00000020. If there is a handler for this exception, the program may be safely continued.". Which takes me to this part of my code : for (unsigned int i = 0; i < width*height * 3; i = i + 3) { file.read((char *)cR, 1); file.read((char *)cG, 1); file.read((char *)cB, 1); buffer[i] = cR / 255.0f; buffer[i + 1] = cG / 255.0f; buffer[i + 2] = cB / 255.0f; } I tried using try/catch and some other if checks but neither worked. Anyone knows what's causing it?
0debug
static void alpha_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); CPUClass *cc = CPU_CLASS(oc); AlphaCPUClass *acc = ALPHA_CPU_CLASS(oc); acc->parent_realize = dc->realize; dc->realize = alpha_cpu_realizefn; cc->class_by_name = alpha_cpu_class_by_name; cc->has_work = alpha_cpu_has_work; cc->do_interrupt = alpha_cpu_do_interrupt; cc->cpu_exec_interrupt = alpha_cpu_exec_interrupt; cc->dump_state = alpha_cpu_dump_state; cc->set_pc = alpha_cpu_set_pc; cc->gdb_read_register = alpha_cpu_gdb_read_register; cc->gdb_write_register = alpha_cpu_gdb_write_register; #ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = alpha_cpu_handle_mmu_fault; #else cc->do_unassigned_access = alpha_cpu_unassigned_access; cc->do_unaligned_access = alpha_cpu_do_unaligned_access; cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; dc->vmsd = &vmstate_alpha_cpu; #endif cc->disas_set_info = alpha_cpu_disas_set_info; cc->gdb_num_core_regs = 67; dc->cannot_destroy_with_object_finalize_yet = true; }
1threat
static int mov_write_wfex_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); avio_wb32(pb, 0); ffio_wfourcc(pb, "wfex"); ff_put_wav_header(pb, track->enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX); return update_size(pb, pos); }
1threat
static void pci_idx(void) { QVirtioPCIDevice *dev; QPCIBus *bus; QVirtQueuePCI *vqpci; QGuestAllocator *alloc; QVirtioBlkReq req; void *addr; uint64_t req_addr; uint64_t capacity; uint32_t features; uint32_t free_head; uint8_t status; char *data; bus = pci_test_start(); alloc = pc_alloc_init(); dev = virtio_blk_pci_init(bus, PCI_SLOT); qpci_msix_enable(dev->pdev); qvirtio_pci_set_msix_configuration_vector(dev, alloc, 0); addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(true); capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev, (uint64_t)(uintptr_t)addr); g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512); features = qvirtio_get_features(&qvirtio_pci, &dev->vdev); features = features & ~(QVIRTIO_F_BAD_FEATURE | (1u << VIRTIO_RING_F_INDIRECT_DESC) | (1u << VIRTIO_F_NOTIFY_ON_EMPTY) | (1u << VIRTIO_BLK_F_SCSI)); qvirtio_set_features(&qvirtio_pci, &dev->vdev, features); vqpci = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev, alloc, 0); qvirtqueue_pci_msix_setup(dev, vqpci, alloc, 1); qvirtio_set_driver_ok(&qvirtio_pci, &dev->vdev); req.type = VIRTIO_BLK_T_OUT; req.ioprio = 1; req.sector = 0; req.data = g_malloc0(512); strcpy(req.data, "TEST"); req_addr = virtio_blk_request(alloc, &req, 512); g_free(req.data); free_head = qvirtqueue_add(&vqpci->vq, req_addr, 16, false, true); qvirtqueue_add(&vqpci->vq, req_addr + 16, 512, false, true); qvirtqueue_add(&vqpci->vq, req_addr + 528, 1, true, false); qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head); qvirtio_wait_queue_isr(&qvirtio_pci, &dev->vdev, &vqpci->vq, QVIRTIO_BLK_TIMEOUT_US); req.type = VIRTIO_BLK_T_OUT; req.ioprio = 1; req.sector = 1; req.data = g_malloc0(512); strcpy(req.data, "TEST"); req_addr = virtio_blk_request(alloc, &req, 512); g_free(req.data); qvirtqueue_set_used_event(&vqpci->vq, 2); free_head = qvirtqueue_add(&vqpci->vq, req_addr, 16, false, true); qvirtqueue_add(&vqpci->vq, req_addr + 16, 512, false, true); qvirtqueue_add(&vqpci->vq, req_addr + 528, 1, true, false); qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head); status = qvirtio_wait_status_byte_no_isr(&qvirtio_pci, &dev->vdev, &vqpci->vq, req_addr + 528, QVIRTIO_BLK_TIMEOUT_US); g_assert_cmpint(status, ==, 0); guest_free(alloc, req_addr); req.type = VIRTIO_BLK_T_IN; req.ioprio = 1; req.sector = 1; req.data = g_malloc0(512); req_addr = virtio_blk_request(alloc, &req, 512); g_free(req.data); free_head = qvirtqueue_add(&vqpci->vq, req_addr, 16, false, true); qvirtqueue_add(&vqpci->vq, req_addr + 16, 512, true, true); qvirtqueue_add(&vqpci->vq, req_addr + 528, 1, true, false); qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head); qvirtio_wait_queue_isr(&qvirtio_pci, &dev->vdev, &vqpci->vq, QVIRTIO_BLK_TIMEOUT_US); status = readb(req_addr + 528); g_assert_cmpint(status, ==, 0); data = g_malloc0(512); memread(req_addr + 16, data, 512); g_assert_cmpstr(data, ==, "TEST"); g_free(data); guest_free(alloc, req_addr); guest_free(alloc, vqpci->vq.desc); pc_alloc_uninit(alloc); qpci_msix_disable(dev->pdev); qvirtio_pci_device_disable(dev); g_free(dev); qpci_free_pc(bus); test_end(); }
1threat
CSS - background not working in firefox : I'm trying to get a background image to work in all browser. The following code works perfectly for every browser but firefox: `<style> body { background: url('src/images/SpeqS.jpg') no-repeat center; background-size: 50%; height: 100%; } </style>` Does anyone have any idea?
0debug
static uint32_t rtl8139_TxStatus_read(RTL8139State *s, uint8_t addr, int size) { uint32_t reg = (addr - TxStatus0) / 4; uint32_t offset = addr & 0x3; uint32_t ret = 0; if (addr & (size - 1)) { DPRINTF("not implemented read for TxStatus addr=0x%x size=0x%x\n", addr, size); return ret; } switch (size) { case 1: case 2: case 4: ret = (s->TxStatus[reg] >> offset * 8) & ((1 << (size * 8)) - 1); DPRINTF("TxStatus[%d] read addr=0x%x size=0x%x val=0x%08x\n", reg, addr, size, ret); break; default: DPRINTF("unsupported size 0x%x of TxStatus reading\n", size); break; } return ret; }
1threat
Please tell answer to the follwing one : if we create ChromeDriver driver=new ChromeDriver(); chrome driver methods will be executed and if we create WebDriver driver=new ChromeDriver(); again chromeDriver methods are executed[as per methodoverriding] then why we write latter one only while executing?
0debug
static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); RawVideoContext *context = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int linesize_align = 4; int res, len; int need_copy = !avpkt->buf || context->is_2_4_bpp || context->is_yuv2; AVFrame *frame = data; AVPicture *picture = data; frame->pict_type = AV_PICTURE_TYPE_I; frame->key_frame = 1; frame->reordered_opaque = avctx->reordered_opaque; frame->pkt_pts = avctx->pkt->pts; av_frame_set_pkt_pos (frame, avctx->pkt->pos); av_frame_set_pkt_duration(frame, avctx->pkt->duration); if (context->tff >= 0) { frame->interlaced_frame = 1; frame->top_field_first = context->tff; } if ((res = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0) return res; if (need_copy) frame->buf[0] = av_buffer_alloc(context->frame_size); else frame->buf[0] = av_buffer_ref(avpkt->buf); if (!frame->buf[0]) return AVERROR(ENOMEM); if (context->is_2_4_bpp) { int i; uint8_t *dst = frame->buf[0]->data; buf_size = context->frame_size - AVPALETTE_SIZE; if (avctx->bits_per_coded_sample == 4) { for (i = 0; 2 * i + 1 < buf_size && i<avpkt->size; i++) { dst[2 * i + 0] = buf[i] >> 4; dst[2 * i + 1] = buf[i] & 15; } linesize_align = 8; } else { av_assert0(avctx->bits_per_coded_sample == 2); for (i = 0; 4 * i + 3 < buf_size && i<avpkt->size; i++) { dst[4 * i + 0] = buf[i] >> 6; dst[4 * i + 1] = buf[i] >> 4 & 3; dst[4 * i + 2] = buf[i] >> 2 & 3; dst[4 * i + 3] = buf[i] & 3; } linesize_align = 16; } buf = dst; } else if (need_copy) { memcpy(frame->buf[0]->data, buf, FFMIN(buf_size, context->frame_size)); buf = frame->buf[0]->data; } if (avctx->codec_tag == MKTAG('A', 'V', '1', 'x') || avctx->codec_tag == MKTAG('A', 'V', 'u', 'p')) buf += buf_size - context->frame_size; len = context->frame_size - (avctx->pix_fmt==AV_PIX_FMT_PAL8 ? AVPALETTE_SIZE : 0); if (buf_size < len) { av_log(avctx, AV_LOG_ERROR, "Invalid buffer size, packet size %d < expected frame_size %d\n", buf_size, len); av_buffer_unref(&frame->buf[0]); return AVERROR(EINVAL); } if ((res = avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height)) < 0) { av_buffer_unref(&frame->buf[0]); return res; } if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); if (pal) { av_buffer_unref(&context->palette); context->palette = av_buffer_alloc(AVPALETTE_SIZE); if (!context->palette) { av_buffer_unref(&frame->buf[0]); return AVERROR(ENOMEM); } memcpy(context->palette->data, pal, AVPALETTE_SIZE); frame->palette_has_changed = 1; } } if ((avctx->pix_fmt==AV_PIX_FMT_BGR24 || avctx->pix_fmt==AV_PIX_FMT_GRAY8 || avctx->pix_fmt==AV_PIX_FMT_RGB555LE || avctx->pix_fmt==AV_PIX_FMT_RGB555BE || avctx->pix_fmt==AV_PIX_FMT_RGB565LE || avctx->pix_fmt==AV_PIX_FMT_MONOWHITE || avctx->pix_fmt==AV_PIX_FMT_PAL8) && FFALIGN(frame->linesize[0], linesize_align) * avctx->height <= buf_size) frame->linesize[0] = FFALIGN(frame->linesize[0], linesize_align); if (avctx->pix_fmt == AV_PIX_FMT_NV12 && avctx->codec_tag == MKTAG('N', 'V', '1', '2') && FFALIGN(frame->linesize[0], linesize_align) * avctx->height + FFALIGN(frame->linesize[1], linesize_align) * ((avctx->height + 1) / 2) <= buf_size) { int la0 = FFALIGN(frame->linesize[0], linesize_align); frame->data[1] += (la0 - frame->linesize[0]) * avctx->height; frame->linesize[0] = la0; frame->linesize[1] = FFALIGN(frame->linesize[1], linesize_align); } if ((avctx->pix_fmt == AV_PIX_FMT_PAL8 && buf_size < context->frame_size) || (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)) { frame->buf[1] = av_buffer_ref(context->palette); if (!frame->buf[1]) { av_buffer_unref(&frame->buf[0]); return AVERROR(ENOMEM); } frame->data[1] = frame->buf[1]->data; } if (avctx->pix_fmt == AV_PIX_FMT_BGR24 && ((frame->linesize[0] + 3) & ~3) * avctx->height <= buf_size) frame->linesize[0] = (frame->linesize[0] + 3) & ~3; if (context->flip) flip(avctx, picture); if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2') || avctx->codec_tag == MKTAG('Y', 'V', '1', '6') || avctx->codec_tag == MKTAG('Y', 'V', '2', '4') || avctx->codec_tag == MKTAG('Y', 'V', 'U', '9')) FFSWAP(uint8_t *, picture->data[1], picture->data[2]); if (avctx->codec_tag == AV_RL32("I420") && (avctx->width+1)*(avctx->height+1) * 3/2 == buf_size) { picture->data[1] = picture->data[1] + (avctx->width+1)*(avctx->height+1) -avctx->width*avctx->height; picture->data[2] = picture->data[2] + ((avctx->width+1)*(avctx->height+1) -avctx->width*avctx->height)*5/4; } if (avctx->codec_tag == AV_RL32("yuv2") && avctx->pix_fmt == AV_PIX_FMT_YUYV422) { int x, y; uint8_t *line = picture->data[0]; for (y = 0; y < avctx->height; y++) { for (x = 0; x < avctx->width; x++) line[2 * x + 1] ^= 0x80; line += picture->linesize[0]; } } if (avctx->codec_tag == AV_RL32("YVYU") && avctx->pix_fmt == AV_PIX_FMT_YUYV422) { int x, y; uint8_t *line = picture->data[0]; for(y = 0; y < avctx->height; y++) { for(x = 0; x < avctx->width - 1; x += 2) FFSWAP(uint8_t, line[2*x + 1], line[2*x + 3]); line += picture->linesize[0]; } } if (avctx->field_order > AV_FIELD_PROGRESSIVE) { frame->interlaced_frame = 1; if (avctx->field_order == AV_FIELD_TT || avctx->field_order == AV_FIELD_TB) frame->top_field_first = 1; } *got_frame = 1; return buf_size; }
1threat
How can i return the value from retrofit onResponse? : I'm beginner in android and write simple retrofit example:<br/> LOGININTERFACE mAPISERVICE; mAPISERVICE= LOGINGENERATOR.getAPIServices(); mAPISERVICE.savePost("0016642902","0016642902","password").enqueue(new Callback<LGOINMODEL>() { @Override public void onResponse(Call<LGOINMODEL> call, Response<LGOINMODEL> response) { LGOINMODEL output=response.body(); if(response.isSuccessful()) test[0] ="behzad behzad behzad"; } @Override public void onFailure(Call<LGOINMODEL> call, Throwable t) { } }); <br/> but in this line:<br/> test[0] ="behzad behzad behzad"; <br/> can't return value,read any tutorial and example and other post in stack over flow,but so can not solve that,how can i solve that problem?thanks.
0debug
Avoid concurrency issues with consumer / producer classes : <p>So, I'm building an console application that has a List of objects. </p> <ul> <li><p>Every 1000ms, a "producer" is doing a HTTP request and creating a new object from the result, and adds it to the List of objects.</p></li> <li><p>Every 1000ms, a "consumer" is going analysing through all the objects in the list.</p></li> <li><p>Every 2000ms, another "consumer" is going analysing through all the objects in the list.</p></li> <li><p>Every 3500ms, another "consumer" is going analysing through all the objects in the list.</p></li> </ul> <p>Once in a while, at arbitrary times, I want to ask one of the consumers what the result of this analysed data is. </p> <p>So this sounds like a classic producer / consumer pattern. In JavaScript this wouldn't be a problem, since it's nonblocking. But how about C#? I would assume this could be quite a concurrency nightmare. As far as I can understand, this cannot be done simply with Tasks, since you cannot control whether it is running in the same thread context, or a new thread. </p> <p>I'm looking for the "simplest" way to do accomplish the case above. I've looked into things like TPL Dataflow, also considered a pattern doing a simple "event loop" with deltatime (like in video games), what are your suggestions?</p> <p>Best regards,</p>
0debug
static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) { BDRVQcow2State *s = bs->opaque; ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1); *spec_info = (ImageInfoSpecific){ .type = IMAGE_INFO_SPECIFIC_KIND_QCOW2, .u.qcow2.data = g_new(ImageInfoSpecificQCow2, 1), }; if (s->qcow_version == 2) { *spec_info->u.qcow2.data = (ImageInfoSpecificQCow2){ .compat = g_strdup("0.10"), .refcount_bits = s->refcount_bits, }; } else if (s->qcow_version == 3) { *spec_info->u.qcow2.data = (ImageInfoSpecificQCow2){ .compat = g_strdup("1.1"), .lazy_refcounts = s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS, .has_lazy_refcounts = true, .corrupt = s->incompatible_features & QCOW2_INCOMPAT_CORRUPT, .has_corrupt = true, .refcount_bits = s->refcount_bits, }; } else { assert(false); } return spec_info; }
1threat
static int xen_pt_msgaddr32_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, uint32_t *val, uint32_t dev_value, uint32_t valid_mask) { XenPTRegInfo *reg = cfg_entry->reg; uint32_t writable_mask = 0; uint32_t old_addr = cfg_entry->data; writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask; cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask); s->msi->addr_lo = cfg_entry->data; *val = XEN_PT_MERGE_VALUE(*val, dev_value, 0); if (cfg_entry->data != old_addr) { if (s->msi->mapped) { xen_pt_msi_update(s); } } return 0; }
1threat
How can I pass dictionary to a function in python? : <p>I am trying to pass dictionary to a function in python but it shows me error. </p> <pre><code>class stud: def method(**arg): print(arg) dict1 = {1:"abc",2:"xyz"} a = stud() a.method(dict1) </code></pre> <p>Can you tell me were I goes wrong or the right way to pass dictionary to a function? </p>
0debug
void optimize_flags_init(void) { cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); cpu_cc_op = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUX86State, cc_op), "cc_op"); cpu_cc_src = tcg_global_mem_new(TCG_AREG0, offsetof(CPUX86State, cc_src), "cc_src"); cpu_cc_dst = tcg_global_mem_new(TCG_AREG0, offsetof(CPUX86State, cc_dst), "cc_dst"); #ifdef TARGET_X86_64 cpu_regs[R_EAX] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[R_EAX]), "rax"); cpu_regs[R_ECX] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[R_ECX]), "rcx"); cpu_regs[R_EDX] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[R_EDX]), "rdx"); cpu_regs[R_EBX] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[R_EBX]), "rbx"); cpu_regs[R_ESP] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[R_ESP]), "rsp"); cpu_regs[R_EBP] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[R_EBP]), "rbp"); cpu_regs[R_ESI] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[R_ESI]), "rsi"); cpu_regs[R_EDI] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[R_EDI]), "rdi"); cpu_regs[8] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[8]), "r8"); cpu_regs[9] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[9]), "r9"); cpu_regs[10] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[10]), "r10"); cpu_regs[11] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[11]), "r11"); cpu_regs[12] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[12]), "r12"); cpu_regs[13] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[13]), "r13"); cpu_regs[14] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[14]), "r14"); cpu_regs[15] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUX86State, regs[15]), "r15"); #else cpu_regs[R_EAX] = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUX86State, regs[R_EAX]), "eax"); cpu_regs[R_ECX] = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUX86State, regs[R_ECX]), "ecx"); cpu_regs[R_EDX] = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUX86State, regs[R_EDX]), "edx"); cpu_regs[R_EBX] = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUX86State, regs[R_EBX]), "ebx"); cpu_regs[R_ESP] = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUX86State, regs[R_ESP]), "esp"); cpu_regs[R_EBP] = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUX86State, regs[R_EBP]), "ebp"); cpu_regs[R_ESI] = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUX86State, regs[R_ESI]), "esi"); cpu_regs[R_EDI] = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUX86State, regs[R_EDI]), "edi"); #endif #define GEN_HELPER 2 #include "helper.h" }
1threat
divide an element of a vector between the number of consecutive 0 wich preceed : I have this data: 20 0 20 40 0 0 0 40 20 0 20 0 20 0 0 60 and I want to get the following output using R: 20 10 10 40 10 10 10 10 20 10 10 10 10 20 20 20 Any ideas?
0debug
Why is Python datetime time delta not found? : <p>I am trying to make an array of dates in mmddyyyy format. The dates will start on the current day and then go two weeks into the future. So it all depends on the starting date. When I run my code I get an error that states:</p> <pre><code>Traceback (most recent call last): File "timeTest.py", line 8, in &lt;module&gt; day = datetime.timedelta(days=i) AttributeError: type object 'datetime.datetime' has no attribute 'timedelta' </code></pre> <p>I am not sure why this is happening because after searching online, I noticed that people are using the 'timedelta' in this way.</p> <p>Here is my code:</p> <pre><code>import time from datetime import datetime, date, time, timedelta dayDates = [] today = datetime.now() dayDates.append(today.strftime("%m%d%Y")) for i in range(0,14): day = today + datetime.timedelta(days=i) print day </code></pre>
0debug
Using this inside loop : <p>I'm trying to use <code>this</code> inside loop, without jQuery. For some reason, it doesn't work. Why?</p> <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;a href="https://google.foo"&gt;Google&lt;/a&gt; &lt;script&gt; /* // Plain JS - Works function doSomething() { var links = document.querySelectorAll('a'); for (var i = 0; i &lt; links.length; i++) { links[i].href = links[i].href.replace('foo', 'bar'); } } // jQuery - Works function doSomething() { $('a').each(function() { $(this).attr('href', $(this).attr('href').replace('foo', 'bar')); }); } */ // Plain JS - Doesn't work function doSomething() { var links = document.querySelectorAll('a'); for (var i = 0; i &lt; links.length; i++) { this[i].setAttribute('href', this[i].getAttribute('href').replace('foo', 'bar')); } } doSomething(); &lt;/script&gt; </code></pre>
0debug
why function pointer to make it difficult ~ : from [Wikipedia - Function object](https://en.wikipedia.org/wiki/Function_object) > A typical use of a function object is in writing callback functions. A callback in procedural languages, such as C, may be performed by using function pointers.[2] However it can be difficult or awkward to pass a state into or out of the callback function. This restriction also inhibits more dynamic behavior of the function. A function object solves those problems since the function is really a façade for a full object, carrying its own state. 1. why function pointer to make it difficult `pass a state into or out of the callback function` and `dynamic behavior of the function` 2. if function do not use function pointer how programs can called function
0debug