idx
int64
func
string
target
int64
179,720
void SessionModelAssociator::OnGotSession( int handle, std::vector<SessionWindow*>* windows) { DCHECK(CalledOnValidThread()); DCHECK(local_session_syncid_); sync_pb::SessionSpecifics specifics; specifics.set_session_tag(GetCurrentMachineTag()); sync_pb::SessionHeader* header_s = specifics.mutable_header(); PopulateSessionSpecificsHeader(*windows, header_s); sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); sync_api::ReadNode root(&trans); if (!root.InitByTagLookup(kSessionsTag)) { LOG(ERROR) << kNoSessionsFolderError; return; } sync_api::WriteNode header_node(&trans); if (!header_node.InitByIdLookup(local_session_syncid_)) { LOG(ERROR) << "Failed to load local session header node."; return; } header_node.SetSessionSpecifics(specifics); }
0
153,074
modifiers2keycode(int modifiers, int *key, char_u *string) { int new_slen = 0; if (modifiers != 0) { // Some keys have the modifier included. Need to handle that here to // make mappings work. This may result in a special key, such as // K_S_TAB. *key = simplify_key(*key, &modifiers); if (modifiers != 0) { string[new_slen++] = K_SPECIAL; string[new_slen++] = (int)KS_MODIFIER; string[new_slen++] = modifiers; } } return new_slen; }
0
10,106
coolkey_find_attribute(sc_card_t *card, sc_cardctl_coolkey_attribute_t *attribute) { u8 object_record_type; CK_ATTRIBUTE_TYPE attr_type = attribute->attribute_type; const u8 *obj = attribute->object->data; const u8 *attr = NULL; size_t buf_len = attribute->object->length; coolkey_object_header_t *object_head; int attribute_count,i; attribute->attribute_data_type = SC_CARDCTL_COOLKEY_ATTR_TYPE_STRING; attribute->attribute_length = 0; attribute->attribute_value = NULL; if (obj == NULL) { /* cast away const so we can cache the data value */ int r = coolkey_fill_object(card, (sc_cardctl_coolkey_object_t *)attribute->object); if (r < 0) { return r; } obj = attribute->object->data; } /* should be a static assert so we catch this at compile time */ assert(sizeof(coolkey_object_header_t) >= sizeof(coolkey_v0_object_header_t)); /* make sure we have enough of the object to read the record_type */ if (buf_len <= sizeof(coolkey_v0_object_header_t)) { return SC_ERROR_CORRUPTED_DATA; } object_head = (coolkey_object_header_t *)obj; object_record_type = object_head->record_type; /* make sure it's a type we recognize */ if ((object_record_type != COOLKEY_V1_OBJECT) && (object_record_type != COOLKEY_V0_OBJECT)) { return SC_ERROR_CORRUPTED_DATA; } /* * now loop through all the attributes in the list. first find the start of the list */ attr = coolkey_attribute_start(obj, object_record_type, buf_len); if (attr == NULL) { return SC_ERROR_CORRUPTED_DATA; } buf_len -= (attr-obj); /* now get the count */ attribute_count = coolkey_get_attribute_count(obj, object_record_type, buf_len); for (i=0; i < attribute_count; i++) { size_t record_len = coolkey_get_attribute_record_len(attr, object_record_type, buf_len); /* make sure we have the complete record */ if (buf_len < record_len) { return SC_ERROR_CORRUPTED_DATA; } /* does the attribute match the one we are looking for */ if (attr_type == coolkey_get_attribute_type(attr, object_record_type, record_len)) { /* yup, return it */ return coolkey_get_attribute_data(attr, object_record_type, record_len, attribute); } /* go to the next attribute on the list */ buf_len -= record_len; attr += record_len; } /* not find in attribute list, check the fixed attribute record */ if (object_record_type == COOLKEY_V1_OBJECT) { unsigned long fixed_attributes = bebytes2ulong(object_head->fixed_attributes_values); return coolkey_get_attribute_data_fixed(attr_type, fixed_attributes, attribute); } return SC_ERROR_DATA_OBJECT_NOT_FOUND; }
1
94,786
int mod_timer_pending(struct timer_list *timer, unsigned long expires) { return __mod_timer(timer, expires, MOD_TIMER_PENDING_ONLY); }
0
322,408
static void add_query_tests(QmpSchema *schema) { SchemaInfoList *tail; SchemaInfo *si, *arg_type, *ret_type; const char *test_name; /* Test the query-like commands */ for (tail = schema->list; tail; tail = tail->next) { si = tail->value; if (si->meta_type != SCHEMA_META_TYPE_COMMAND) { continue; } if (query_is_blacklisted(si->name)) { continue; } arg_type = qmp_schema_lookup(schema, si->u.command.arg_type); if (object_type_has_mandatory_members(arg_type)) { continue; } ret_type = qmp_schema_lookup(schema, si->u.command.ret_type); if (ret_type->meta_type == SCHEMA_META_TYPE_OBJECT && !ret_type->u.object.members) { continue; } test_name = g_strdup_printf("qmp/%s", si->name); qtest_add_data_func(test_name, si->name, test_query); } }
1
330,081
int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) { int i, ret; int32_t config_len; uint32_t num; uint32_t features; BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); /* * We poison the endianness to ensure it does not get used before * subsections have been loaded. */ vdev->device_endian = VIRTIO_DEVICE_ENDIAN_UNKNOWN; if (k->load_config) { ret = k->load_config(qbus->parent, f); if (ret) return ret; } qemu_get_8s(f, &vdev->status); qemu_get_8s(f, &vdev->isr); qemu_get_be16s(f, &vdev->queue_sel); if (vdev->queue_sel >= VIRTIO_QUEUE_MAX) { return -1; } qemu_get_be32s(f, &features); /* * Temporarily set guest_features low bits - needed by * virtio net load code testing for VIRTIO_NET_F_CTRL_GUEST_OFFLOADS * VIRTIO_NET_F_GUEST_ANNOUNCE and VIRTIO_NET_F_CTRL_VQ. * * Note: devices should always test host features in future - don't create * new dependencies like this. */ vdev->guest_features = features; config_len = qemu_get_be32(f); /* * There are cases where the incoming config can be bigger or smaller * than what we have; so load what we have space for, and skip * any excess that's in the stream. */ qemu_get_buffer(f, vdev->config, MIN(config_len, vdev->config_len)); while (config_len > vdev->config_len) { qemu_get_byte(f); config_len--; } num = qemu_get_be32(f); if (num > VIRTIO_QUEUE_MAX) { error_report("Invalid number of virtqueues: 0x%x", num); return -1; } for (i = 0; i < num; i++) { vdev->vq[i].vring.num = qemu_get_be32(f); if (k->has_variable_vring_alignment) { vdev->vq[i].vring.align = qemu_get_be32(f); } vdev->vq[i].vring.desc = qemu_get_be64(f); qemu_get_be16s(f, &vdev->vq[i].last_avail_idx); vdev->vq[i].signalled_used_valid = false; vdev->vq[i].notification = true; if (vdev->vq[i].vring.desc) { /* XXX virtio-1 devices */ virtio_queue_update_rings(vdev, i); } else if (vdev->vq[i].last_avail_idx) { error_report("VQ %d address 0x0 " "inconsistent with Host index 0x%x", i, vdev->vq[i].last_avail_idx); return -1; } if (k->load_queue) { ret = k->load_queue(qbus->parent, i, f); if (ret) return ret; } } virtio_notify_vector(vdev, VIRTIO_NO_VECTOR); if (vdc->load != NULL) { ret = vdc->load(vdev, f, version_id); if (ret) { return ret; } } if (vdc->vmsd) { ret = vmstate_load_state(f, vdc->vmsd, vdev, version_id); if (ret) { return ret; } } /* Subsections */ ret = vmstate_load_state(f, &vmstate_virtio, vdev, 1); if (ret) { return ret; } if (vdev->device_endian == VIRTIO_DEVICE_ENDIAN_UNKNOWN) { vdev->device_endian = virtio_default_endian(); } if (virtio_64bit_features_needed(vdev)) { /* * Subsection load filled vdev->guest_features. Run them * through virtio_set_features to sanity-check them against * host_features. */ uint64_t features64 = vdev->guest_features; if (virtio_set_features_nocheck(vdev, features64) < 0) { error_report("Features 0x%" PRIx64 " unsupported. " "Allowed features: 0x%" PRIx64, features64, vdev->host_features); return -1; } } else { if (virtio_set_features_nocheck(vdev, features) < 0) { error_report("Features 0x%x unsupported. " "Allowed features: 0x%" PRIx64, features, vdev->host_features); return -1; } } rcu_read_lock(); for (i = 0; i < num; i++) { if (vdev->vq[i].vring.desc) { uint16_t nheads; nheads = vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_avail_idx; /* Check it isn't doing strange things with descriptor numbers. */ if (nheads > vdev->vq[i].vring.num) { error_report("VQ %d size 0x%x Guest index 0x%x " "inconsistent with Host index 0x%x: delta 0x%x", i, vdev->vq[i].vring.num, vring_avail_idx(&vdev->vq[i]), vdev->vq[i].last_avail_idx, nheads); return -1; } vdev->vq[i].used_idx = vring_used_idx(&vdev->vq[i]); vdev->vq[i].shadow_avail_idx = vring_avail_idx(&vdev->vq[i]); /* * Some devices migrate VirtQueueElements that have been popped * from the avail ring but not yet returned to the used ring. * Since max ring size < UINT16_MAX it's safe to use modulo * UINT16_MAX + 1 subtraction. */ vdev->vq[i].inuse = (uint16_t)(vdev->vq[i].last_avail_idx - vdev->vq[i].used_idx); if (vdev->vq[i].inuse > vdev->vq[i].vring.num) { error_report("VQ %d size 0x%x < last_avail_idx 0x%x - " "used_idx 0x%x", i, vdev->vq[i].vring.num, vdev->vq[i].last_avail_idx, vdev->vq[i].used_idx); return -1; } } } rcu_read_unlock(); return 0; }
1
354,014
AP_DECLARE(void) ap_update_vhost_from_headers(request_rec *r) { core_server_config *conf = ap_get_core_module_config(r->server->module_config); const char *host_header = apr_table_get(r->headers_in, "Host"); int is_v6literal = 0; int have_hostname_from_url = 0; if (r->hostname) { /* * If there was a host part in the Request-URI, ignore the 'Host' * header. */ have_hostname_from_url = 1; is_v6literal = fix_hostname(r, NULL, conf->http_conformance); } else if (host_header != NULL) { is_v6literal = fix_hostname(r, host_header, conf->http_conformance); } if (r->status != HTTP_OK) return; if (conf->http_conformance != AP_HTTP_CONFORMANCE_UNSAFE) { /* * If we have both hostname from an absoluteURI and a Host header, * we must ignore the Host header (RFC 2616 5.2). * To enforce this, we reset the Host header to the value from the * request line. */ if (have_hostname_from_url && host_header != NULL) { const char *repl = construct_host_header(r, is_v6literal); apr_table_setn(r->headers_in, "Host", repl); ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02417) "Replacing host header '%s' with host '%s' given " "in the request uri", host_header, repl); } } /* check if we tucked away a name_chain */ if (r->connection->vhost_lookup_data) { if (r->hostname) check_hostalias(r); else check_serverpath(r); } }
1
348,668
void free_G_buffers(__G) /* releases all memory allocated in global vars */ __GDEF { #ifndef SFX unsigned i; #endif #ifdef SYSTEM_SPECIFIC_DTOR SYSTEM_SPECIFIC_DTOR(__G); #endif inflate_free(__G); checkdir(__G__ (char *)NULL, END); #ifdef DYNALLOC_CRCTAB if (CRC_32_TAB) { free_crc_table(); CRC_32_TAB = NULL; } #endif if (G.key != (char *)NULL) { free(G.key); G.key = (char *)NULL; } if (G.extra_field != (uch *)NULL) { free(G.extra_field); G.extra_field = (uch *)NULL; } #if (!defined(VMS) && !defined(SMALL_MEM)) /* VMS uses its own buffer scheme for textmode flush() */ if (G.outbuf2) { free(G.outbuf2); /* malloc'd ONLY if unshrink and -a */ G.outbuf2 = (uch *)NULL; } #endif if (G.outbuf) free(G.outbuf); if (G.inbuf) free(G.inbuf); G.inbuf = G.outbuf = (uch *)NULL; #ifdef UNICODE_SUPPORT if (G.filename_full) { free(G.filename_full); G.filename_full = (char *)NULL; G.fnfull_bufsize = 0; } #endif /* UNICODE_SUPPORT */ #ifndef SFX for (i = 0; i < DIR_BLKSIZ; i++) { if (G.info[i].cfilname != (char Far *)NULL) { zffree(G.info[i].cfilname); G.info[i].cfilname = (char Far *)NULL; } } #endif #ifdef MALLOC_WORK if (G.area.Slide) { free(G.area.Slide); G.area.Slide = (uch *)NULL; } #endif } /* end function free_G_buffers() */
1
238,265
virtio_gpu_fill_display_info(VirtIOGPU *g, struct virtio_gpu_resp_display_info *dpy_info) { int i; for (i = 0; i < g->conf.max_outputs; i++) { if (g->enabled_output_bitmask & (1 << i)) { dpy_info->pmodes[i].enabled = 1; dpy_info->pmodes[i].r.width = g->req_state[i].width; dpy_info->pmodes[i].r.height = g->req_state[i].height; } } }
0
333,449
static int decode_ref_pic_list_reordering(H264Context *h){ MpegEncContext * const s = &h->s; int list, index; print_short_term(h); print_long_term(h); if(h->slice_type==I_TYPE || h->slice_type==SI_TYPE) return 0; //FIXME move before func for(list=0; list<2; list++){ memcpy(h->ref_list[list], h->default_ref_list[list], sizeof(Picture)*h->ref_count[list]); if(get_bits1(&s->gb)){ int pred= h->curr_pic_num; for(index=0; ; index++){ int reordering_of_pic_nums_idc= get_ue_golomb(&s->gb); int pic_id; int i; Picture *ref = NULL; if(reordering_of_pic_nums_idc==3) break; if(index >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "reference count overflow\n"); return -1; } if(reordering_of_pic_nums_idc<3){ if(reordering_of_pic_nums_idc<2){ const int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1; if(abs_diff_pic_num >= h->max_pic_num){ av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n"); return -1; } if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num; else pred+= abs_diff_pic_num; pred &= h->max_pic_num - 1; for(i= h->short_ref_count-1; i>=0; i--){ ref = h->short_ref[i]; assert(ref->reference == 3); assert(!ref->long_ref); if(ref->data[0] != NULL && ref->frame_num == pred && ref->long_ref == 0) // ignore non existing pictures by testing data[0] pointer break; } if(i>=0) ref->pic_id= ref->frame_num; }else{ pic_id= get_ue_golomb(&s->gb); //long_term_pic_idx ref = h->long_ref[pic_id]; if(ref){ ref->pic_id= pic_id; assert(ref->reference == 3); assert(ref->long_ref); i=0; }else{ i=-1; } } if (i < 0) { av_log(h->s.avctx, AV_LOG_ERROR, "reference picture missing during reorder\n"); memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME } else { for(i=index; i+1<h->ref_count[list]; i++){ if(ref->long_ref == h->ref_list[list][i].long_ref && ref->pic_id == h->ref_list[list][i].pic_id) break; } for(; i > index; i--){ h->ref_list[list][i]= h->ref_list[list][i-1]; } h->ref_list[list][index]= *ref; } }else{ av_log(h->s.avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n"); return -1; } } } if(h->slice_type!=B_TYPE) break; } for(list=0; list<2; list++){ for(index= 0; index < h->ref_count[list]; index++){ if(!h->ref_list[list][index].data[0]) h->ref_list[list][index]= s->current_picture; } if(h->slice_type!=B_TYPE) break; } if(h->slice_type==B_TYPE && !h->direct_spatial_mv_pred) direct_dist_scale_factor(h); direct_ref_list_init(h); return 0; }
1
243,946
String HTMLInputElement::sanitizeValue(const String& proposedValue) const { if (proposedValue.isNull()) return proposedValue; return m_inputType->sanitizeValue(proposedValue); }
0
209,540
bool ExtensionRegistry::AddTerminated( const scoped_refptr<const Extension>& extension) { return terminated_extensions_.Insert(extension); }
0
128,296
static RList * get_java_bin_obj_list(RAnal *anal) { RBinJavaObj *bin_obj = (RBinJavaObj * )get_java_bin_obj(anal); // See libr/bin/p/bin_java.c to see what is happening here. The original intention // was to use a shared global db variable from shlr/java/class.c, but the // BIN_OBJS_ADDRS variable kept getting corrupted on Mac, so I (deeso) switched the // way the access to the db was taking place by using the bin_obj as a proxy back // to the BIN_OBJS_ADDRS which is instantiated in libr/bin/p/bin_java.c // not the easiest way to make sausage, but its getting made. return r_bin_java_get_bin_obj_list_thru_obj (bin_obj); }
0
214,956
void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { int width = std::min(size.width(), kMaxWindowWidth); int height = std::min(size.height(), kMaxWindowHeight); if (IsPopup()) { gtk_widget_set_size_request(view_.get(), width, height); } if (requested_size_.width() != width || requested_size_.height() != height) { requested_size_ = gfx::Size(width, height); host_->SendScreenRects(); host_->WasResized(); } }
0
456,331
static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node) { #ifdef CONFIG_VMAP_STACK void *stack; int i; for (i = 0; i < NR_CACHED_STACKS; i++) { struct vm_struct *s; s = this_cpu_xchg(cached_stacks[i], NULL); if (!s) continue; /* Clear stale pointers from reused stack. */ memset(s->addr, 0, THREAD_SIZE); tsk->stack_vm_area = s; tsk->stack = s->addr; return s->addr; } /* * Allocated stacks are cached and later reused by new threads, * so memcg accounting is performed manually on assigning/releasing * stacks to tasks. Drop __GFP_ACCOUNT. */ stack = __vmalloc_node_range(THREAD_SIZE, THREAD_ALIGN, VMALLOC_START, VMALLOC_END, THREADINFO_GFP & ~__GFP_ACCOUNT, PAGE_KERNEL, 0, node, __builtin_return_address(0)); /* * We can't call find_vm_area() in interrupt context, and * free_thread_stack() can be called in interrupt context, * so cache the vm_struct. */ if (stack) { tsk->stack_vm_area = find_vm_area(stack); tsk->stack = stack; } return stack; #else struct page *page = alloc_pages_node(node, THREADINFO_GFP, THREAD_SIZE_ORDER); if (likely(page)) { tsk->stack = page_address(page); return tsk->stack; } return NULL; #endif }
0
238,306
__be32 nfsd4_check_resp_size(struct nfsd4_compoundres *resp, u32 respsize) { struct xdr_buf *buf = &resp->rqstp->rq_res; struct nfsd4_slot *slot = resp->cstate.slot; if (buf->len + respsize <= buf->buflen) return nfs_ok; if (!nfsd4_has_session(&resp->cstate)) return nfserr_resource; if (slot->sl_flags & NFSD4_SLOT_CACHETHIS) { WARN_ON_ONCE(1); return nfserr_rep_too_big_to_cache; } return nfserr_rep_too_big; }
0
167,526
ProcXvQueryImageAttributes(ClientPtr client) { xvQueryImageAttributesReply rep; int size, num_planes, i; CARD16 width, height; XvImagePtr pImage = NULL; XvPortPtr pPort; int *offsets; int *pitches; int planeLength; REQUEST(xvQueryImageAttributesReq); REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); for (i = 0; i < pPort->pAdaptor->nImages; i++) { if (pPort->pAdaptor->pImages[i].id == stuff->id) { pImage = &(pPort->pAdaptor->pImages[i]); break; } } #ifdef XvMCExtension if (!pImage) pImage = XvMCFindXvImage(pPort, stuff->id); #endif if (!pImage) return BadMatch; num_planes = pImage->num_planes; if (!(offsets = malloc(num_planes << 3))) return BadAlloc; pitches = offsets + num_planes; width = stuff->width; height = stuff->height; size = (*pPort->pAdaptor->ddQueryImageAttributes) (pPort, pImage, &width, &height, offsets, pitches); rep = (xvQueryImageAttributesReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = planeLength = num_planes << 1, .num_planes = num_planes, .width = width, .height = height, .data_size = size }; _WriteQueryImageAttributesReply(client, &rep); if (client->swapped) SwapLongs((CARD32 *) offsets, planeLength); WriteToClient(client, planeLength << 2, offsets); free(offsets); return Success; }
0
145,593
static void sections_from_bin(RList *ret, RBinFile *bf, RDyldBinImage *bin) { RDyldCache *cache = (RDyldCache*) bf->o->bin_obj; if (!cache) { return; } struct MACH0_(obj_t) *mach0 = bin_to_mach0 (bf, bin); if (!mach0) { return; } struct section_t *sections = NULL; if (!(sections = MACH0_(get_sections) (mach0))) { return; } ut64 slide = rebase_infos_get_slide (cache); int i; for (i = 0; !sections[i].last; i++) { RBinSection *ptr = R_NEW0 (RBinSection); if (!ptr) { break; } if (bin->file) { ptr->name = r_str_newf ("%s.%s", bin->file, (char*)sections[i].name); } else { ptr->name = r_str_newf ("%s", (char*)sections[i].name); } if (strstr (ptr->name, "la_symbol_ptr")) { int len = sections[i].size / 8; ptr->format = r_str_newf ("Cd %d[%d]", 8, len); } ptr->is_data = __is_data_section (ptr->name); ptr->size = sections[i].size; ptr->vsize = sections[i].vsize; ptr->vaddr = sections[i].addr; ptr->paddr = va2pa (sections[i].addr, cache->n_maps, cache->maps, cache->buf, slide, NULL, NULL); if (!ptr->vaddr) { ptr->vaddr = ptr->paddr; } ptr->perm = sections[i].perm; r_list_append (ret, ptr); } free (sections); MACH0_(mach0_free) (mach0); }
0
452,906
static bool torture_smb2_notify_dir(struct torture_context *torture, struct smb2_tree *tree1, struct smb2_tree *tree2) { bool ret = true; NTSTATUS status; union smb_notify notify; union smb_open io; union smb_close cl; int i, count; struct smb2_handle h1 = {{0}}; struct smb2_handle h2 = {{0}}; struct smb2_request *req, *req2; const char *fname = BASEDIR_DIR "\\subdir-name"; extern int torture_numops; torture_comment(torture, "TESTING CHANGE NOTIFY ON DIRECTORIES\n"); smb2_deltree(tree1, BASEDIR_DIR); smb2_util_rmdir(tree1, BASEDIR_DIR); /* get a handle on the directory */ ZERO_STRUCT(io.smb2); io.generic.level = RAW_OPEN_SMB2; io.smb2.in.create_flags = 0; io.smb2.in.desired_access = SEC_FILE_ALL; io.smb2.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; io.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL; io.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; io.smb2.in.alloc_size = 0; io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE; io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS; io.smb2.in.security_flags = 0; io.smb2.in.fname = BASEDIR_DIR; status = smb2_create(tree1, torture, &(io.smb2)); CHECK_STATUS(status, NT_STATUS_OK); h1 = io.smb2.out.file.handle; io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN; io.smb2.in.desired_access = SEC_RIGHTS_FILE_READ; status = smb2_create(tree1, torture, &(io.smb2)); CHECK_STATUS(status, NT_STATUS_OK); h2 = io.smb2.out.file.handle; /* ask for a change notify, on file or directory name changes */ ZERO_STRUCT(notify.smb2); notify.smb2.level = RAW_NOTIFY_SMB2; notify.smb2.in.buffer_size = 1000; notify.smb2.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; notify.smb2.in.file.handle = h1; notify.smb2.in.recursive = true; torture_comment(torture, "Testing notify cancel\n"); req = smb2_notify_send(tree1, &(notify.smb2)); smb2_cancel(req); status = smb2_notify_recv(req, torture, &(notify.smb2)); CHECK_STATUS(status, NT_STATUS_CANCELLED); torture_comment(torture, "Testing notify mkdir\n"); req = smb2_notify_send(tree1, &(notify.smb2)); smb2_util_mkdir(tree2, fname); status = smb2_notify_recv(req, torture, &(notify.smb2)); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(notify.smb2.out.num_changes, 1); CHECK_VAL(notify.smb2.out.changes[0].action, NOTIFY_ACTION_ADDED); CHECK_WIRE_STR(notify.smb2.out.changes[0].name, "subdir-name"); torture_comment(torture, "Testing notify rmdir\n"); req = smb2_notify_send(tree1, &(notify.smb2)); smb2_util_rmdir(tree2, fname); status = smb2_notify_recv(req, torture, &(notify.smb2)); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(notify.smb2.out.num_changes, 1); CHECK_VAL(notify.smb2.out.changes[0].action, NOTIFY_ACTION_REMOVED); CHECK_WIRE_STR(notify.smb2.out.changes[0].name, "subdir-name"); torture_comment(torture, "Testing notify mkdir - rmdir - mkdir - rmdir\n"); smb2_util_mkdir(tree2, fname); smb2_util_rmdir(tree2, fname); smb2_util_mkdir(tree2, fname); smb2_util_rmdir(tree2, fname); smb_msleep(200); req = smb2_notify_send(tree1, &(notify.smb2)); status = smb2_notify_recv(req, torture, &(notify.smb2)); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(notify.smb2.out.num_changes, 4); CHECK_VAL(notify.smb2.out.changes[0].action, NOTIFY_ACTION_ADDED); CHECK_WIRE_STR(notify.smb2.out.changes[0].name, "subdir-name"); CHECK_VAL(notify.smb2.out.changes[1].action, NOTIFY_ACTION_REMOVED); CHECK_WIRE_STR(notify.smb2.out.changes[1].name, "subdir-name"); CHECK_VAL(notify.smb2.out.changes[2].action, NOTIFY_ACTION_ADDED); CHECK_WIRE_STR(notify.smb2.out.changes[2].name, "subdir-name"); CHECK_VAL(notify.smb2.out.changes[3].action, NOTIFY_ACTION_REMOVED); CHECK_WIRE_STR(notify.smb2.out.changes[3].name, "subdir-name"); count = torture_numops; torture_comment(torture, "Testing buffered notify on create of %d files\n", count); for (i=0;i<count;i++) { struct smb2_handle h12; char *fname2 = talloc_asprintf(torture, BASEDIR_DIR "\\test%d.txt", i); ZERO_STRUCT(io.smb2); io.generic.level = RAW_OPEN_SMB2; io.smb2.in.create_flags = 0; io.smb2.in.desired_access = SEC_FILE_ALL; io.smb2.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE; io.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL; io.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; io.smb2.in.alloc_size = 0; io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE; io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS; io.smb2.in.security_flags = 0; io.smb2.in.fname = fname2; status = smb2_create(tree1, torture, &(io.smb2)); if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) { torture_comment(torture, "Failed to create %s \n", fname); ret = false; goto done; } h12 = io.smb2.out.file.handle; talloc_free(fname2); smb2_util_close(tree1, h12); } /* (1st notify) setup a new notify on a different directory handle. This new notify won't see the events above. */ notify.smb2.in.file.handle = h2; req2 = smb2_notify_send(tree1, &(notify.smb2)); /* (2nd notify) whereas this notify will see the above buffered events, and it directly returns the buffered events */ notify.smb2.in.file.handle = h1; req = smb2_notify_send(tree1, &(notify.smb2)); status = smb2_util_unlink(tree1, BASEDIR_DIR "\\nonexistent.txt"); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); /* (1st unlink) as the 2nd notify directly returns, this unlink is only seen by the 1st notify and the 3rd notify (later) */ torture_comment(torture, "Testing notify on unlink for the first file\n"); status = smb2_util_unlink(tree2, BASEDIR_DIR "\\test0.txt"); CHECK_STATUS(status, NT_STATUS_OK); /* receive the reply from the 2nd notify */ status = smb2_notify_recv(req, torture, &(notify.smb2)); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(notify.smb2.out.num_changes, count); for (i=1;i<count;i++) { CHECK_VAL(notify.smb2.out.changes[i].action, NOTIFY_ACTION_ADDED); } CHECK_WIRE_STR(notify.smb2.out.changes[0].name, "test0.txt"); torture_comment(torture, "and now from the 1st notify\n"); status = smb2_notify_recv(req2, torture, &(notify.smb2)); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(notify.smb2.out.num_changes, 1); CHECK_VAL(notify.smb2.out.changes[0].action, NOTIFY_ACTION_REMOVED); CHECK_WIRE_STR(notify.smb2.out.changes[0].name, "test0.txt"); torture_comment(torture, "(3rd notify) this notify will only see the 1st unlink\n"); req = smb2_notify_send(tree1, &(notify.smb2)); status = smb2_util_unlink(tree1, BASEDIR_DIR "\\nonexistent.txt"); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); for (i=1;i<count;i++) { char *fname2 = talloc_asprintf(torture, BASEDIR_DIR "\\test%d.txt", i); status = smb2_util_unlink(tree2, fname2); CHECK_STATUS(status, NT_STATUS_OK); talloc_free(fname2); } /* receive the 3rd notify */ status = smb2_notify_recv(req, torture, &(notify.smb2)); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(notify.smb2.out.num_changes, 1); CHECK_VAL(notify.smb2.out.changes[0].action, NOTIFY_ACTION_REMOVED); CHECK_WIRE_STR(notify.smb2.out.changes[0].name, "test0.txt"); /* and we now see the rest of the unlink calls on both * directory handles */ notify.smb2.in.file.handle = h1; sleep(3); req = smb2_notify_send(tree1, &(notify.smb2)); status = smb2_notify_recv(req, torture, &(notify.smb2)); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(notify.smb2.out.num_changes, count-1); for (i=0;i<notify.smb2.out.num_changes;i++) { CHECK_VAL(notify.smb2.out.changes[i].action, NOTIFY_ACTION_REMOVED); } notify.smb2.in.file.handle = h2; req = smb2_notify_send(tree1, &(notify.smb2)); status = smb2_notify_recv(req, torture, &(notify.smb2)); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(notify.smb2.out.num_changes, count-1); for (i=0;i<notify.smb2.out.num_changes;i++) { CHECK_VAL(notify.smb2.out.changes[i].action, NOTIFY_ACTION_REMOVED); } torture_comment(torture, "Testing if a close() on the dir handle triggers the notify reply\n"); notify.smb2.in.file.handle = h1; req = smb2_notify_send(tree1, &(notify.smb2)); ZERO_STRUCT(cl.smb2); cl.smb2.level = RAW_CLOSE_SMB2; cl.smb2.in.file.handle = h1; status = smb2_close(tree1, &(cl.smb2)); CHECK_STATUS(status, NT_STATUS_OK); status = smb2_notify_recv(req, torture, &(notify.smb2)); CHECK_STATUS(status, NT_STATUS_NOTIFY_CLEANUP); CHECK_VAL(notify.smb2.out.num_changes, 9); done: smb2_util_close(tree1, h1); smb2_util_close(tree1, h2); smb2_deltree(tree1, BASEDIR_DIR); return ret; }
0
78,240
smtp_proceed_connected(struct smtp_session *s) { if (s->listener->flags & F_SMTPS) smtp_cert_init(s); else smtp_send_banner(s); }
0
8,434
static int replace_map_fd_with_map_ptr(struct verifier_env *env) { struct bpf_insn *insn = env->prog->insnsi; int insn_cnt = env->prog->len; int i, j; for (i = 0; i < insn_cnt; i++, insn++) { if (BPF_CLASS(insn->code) == BPF_LDX && (BPF_MODE(insn->code) != BPF_MEM || insn->imm != 0)) { verbose("BPF_LDX uses reserved fields\n"); return -EINVAL; } if (BPF_CLASS(insn->code) == BPF_STX && ((BPF_MODE(insn->code) != BPF_MEM && BPF_MODE(insn->code) != BPF_XADD) || insn->imm != 0)) { verbose("BPF_STX uses reserved fields\n"); return -EINVAL; } if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) { struct bpf_map *map; struct fd f; if (i == insn_cnt - 1 || insn[1].code != 0 || insn[1].dst_reg != 0 || insn[1].src_reg != 0 || insn[1].off != 0) { verbose("invalid bpf_ld_imm64 insn\n"); return -EINVAL; } if (insn->src_reg == 0) /* valid generic load 64-bit imm */ goto next_insn; if (insn->src_reg != BPF_PSEUDO_MAP_FD) { verbose("unrecognized bpf_ld_imm64 insn\n"); return -EINVAL; } f = fdget(insn->imm); map = __bpf_map_get(f); if (IS_ERR(map)) { verbose("fd %d is not pointing to valid bpf_map\n", insn->imm); return PTR_ERR(map); } /* store map pointer inside BPF_LD_IMM64 instruction */ insn[0].imm = (u32) (unsigned long) map; insn[1].imm = ((u64) (unsigned long) map) >> 32; /* check whether we recorded this map already */ for (j = 0; j < env->used_map_cnt; j++) if (env->used_maps[j] == map) { fdput(f); goto next_insn; } if (env->used_map_cnt >= MAX_USED_MAPS) { fdput(f); return -E2BIG; } /* remember this map */ env->used_maps[env->used_map_cnt++] = map; /* hold the map. If the program is rejected by verifier, * the map will be released by release_maps() or it * will be used by the valid program until it's unloaded * and all maps are released in free_bpf_prog_info() */ bpf_map_inc(map, false); fdput(f); next_insn: insn++; i++; } } /* now all pseudo BPF_LD_IMM64 instructions load valid * 'struct bpf_map *' into a register instead of user map_fd. * These pointers will be used later by verifier to validate map access. */ return 0; }
1
417,202
parse_CT_CLEAR(char *arg OVS_UNUSED, struct ofpbuf *ofpacts, enum ofputil_protocol *usable_protocols OVS_UNUSED) { ofpact_put_CT_CLEAR(ofpacts); return NULL; }
0
79,895
wf_cliprdr_server_unlock_clipboard_data(CliprdrClientContext* context, const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData) { (void)context; (void)unlockClipboardData; return CHANNEL_RC_OK; }
0
316,906
SoftOpus::~SoftOpus() { if (mDecoder != NULL) { opus_multistream_decoder_destroy(mDecoder); mDecoder = NULL; } if (mHeader != NULL) { delete mHeader; mHeader = NULL; } }
0
60,342
define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free) { int j; int c; int saved_did_emsg = FALSE; char_u *name = name_arg; int is_global = FALSE; char_u *p; char_u *arg; char_u *whitep; char_u *line_arg = NULL; garray_T newargs; garray_T argtypes; garray_T default_args; garray_T newlines; int varargs = FALSE; int flags = 0; char_u *ret_type = NULL; ufunc_T *fp = NULL; int fp_allocated = FALSE; int free_fp = FALSE; int overwrite = FALSE; dictitem_T *v; funcdict_T fudi; static int func_nr = 0; // number for nameless function int paren; hashitem_T *hi; linenr_T sourcing_lnum_top; int vim9script = in_vim9script(); imported_T *import = NULL; /* * ":function" without argument: list functions. */ if (ends_excmd2(eap->cmd, eap->arg)) { if (!eap->skip) list_functions(NULL); set_nextcmd(eap, eap->arg); return NULL; } /* * ":function /pat": list functions matching pattern. */ if (*eap->arg == '/') { p = skip_regexp(eap->arg + 1, '/', TRUE); if (!eap->skip) { regmatch_T regmatch; c = *p; *p = NUL; regmatch.regprog = vim_regcomp(eap->arg + 1, RE_MAGIC); *p = c; if (regmatch.regprog != NULL) { regmatch.rm_ic = p_ic; list_functions(&regmatch); vim_regfree(regmatch.regprog); } } if (*p == '/') ++p; set_nextcmd(eap, p); return NULL; } ga_init(&newargs); ga_init(&argtypes); ga_init(&default_args); /* * Get the function name. There are these situations: * func normal function name * "name" == func, "fudi.fd_dict" == NULL * dict.func new dictionary entry * "name" == NULL, "fudi.fd_dict" set, * "fudi.fd_di" == NULL, "fudi.fd_newkey" == func * dict.func existing dict entry with a Funcref * "name" == func, "fudi.fd_dict" set, * "fudi.fd_di" set, "fudi.fd_newkey" == NULL * dict.func existing dict entry that's not a Funcref * "name" == NULL, "fudi.fd_dict" set, * "fudi.fd_di" set, "fudi.fd_newkey" == NULL * s:func script-local function name * g:func global function name, same as "func" */ p = eap->arg; if (name_arg != NULL) { // nested function, argument is (args). paren = TRUE; CLEAR_FIELD(fudi); } else { if (vim9script) { if (p[0] == 's' && p[1] == ':') { semsg(_(e_cannot_use_s_colon_in_vim9_script_str), p); return NULL; } p = to_name_end(p, TRUE); if (*skipwhite(p) == '.' && vim_strchr(p, '(') != NULL) { semsg(_(e_cannot_define_dict_func_in_vim9_script_str), eap->arg); return NULL; } p = eap->arg; } name = save_function_name(&p, &is_global, eap->skip, TFN_NO_AUTOLOAD | TFN_NEW_FUNC, &fudi); paren = (vim_strchr(p, '(') != NULL); if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) { /* * Return on an invalid expression in braces, unless the expression * evaluation has been cancelled due to an aborting error, an * interrupt, or an exception. */ if (!aborting()) { if (!eap->skip && fudi.fd_newkey != NULL) semsg(_(e_key_not_present_in_dictionary), fudi.fd_newkey); vim_free(fudi.fd_newkey); return NULL; } else eap->skip = TRUE; } // For "export def FuncName()" in an autoload script the function name // is stored with the legacy autoload name "dir#script#FuncName" so // that it can also be found in legacy script. if (is_export && name != NULL) { char_u *prefixed = may_prefix_autoload(name); if (prefixed != NULL && prefixed != name) { vim_free(name); name = prefixed; } } else if (paren && vim9script && name != NULL && vim_strchr(name, AUTOLOAD_CHAR) != NULL) { emsg(_(e_cannot_use_name_with_hash_in_vim9_script_use_export_instead)); goto ret_free; } } // An error in a function call during evaluation of an expression in magic // braces should not cause the function not to be defined. saved_did_emsg = did_emsg; did_emsg = FALSE; /* * ":function func" with only function name: list function. */ if (!paren) { if (!ends_excmd(*skipwhite(p))) { semsg(_(e_trailing_characters_str), p); goto ret_free; } set_nextcmd(eap, p); if (eap->nextcmd != NULL) *p = NUL; if (!eap->skip && !got_int) { fp = find_func(name, is_global); if (fp == NULL && ASCII_ISUPPER(*eap->arg)) { char_u *up = untrans_function_name(name); // With Vim9 script the name was made script-local, if not // found try again with the original name. if (up != NULL) fp = find_func(up, FALSE); } if (fp != NULL) { list_func_head(fp, TRUE); for (j = 0; j < fp->uf_lines.ga_len && !got_int; ++j) { if (FUNCLINE(fp, j) == NULL) continue; msg_putchar('\n'); msg_outnum((long)(j + 1)); if (j < 9) msg_putchar(' '); if (j < 99) msg_putchar(' '); msg_prt_line(FUNCLINE(fp, j), FALSE); out_flush(); // show a line at a time ui_breakcheck(); } if (!got_int) { msg_putchar('\n'); if (fp->uf_def_status != UF_NOT_COMPILED) msg_puts(" enddef"); else msg_puts(" endfunction"); } } else emsg_funcname(e_undefined_function_str, eap->arg); } goto ret_free; } /* * ":function name(arg1, arg2)" Define function. */ p = skipwhite(p); if (*p != '(') { if (!eap->skip) { semsg(_(e_missing_paren_str), eap->arg); goto ret_free; } // attempt to continue by skipping some text if (vim_strchr(p, '(') != NULL) p = vim_strchr(p, '('); } if ((vim9script || eap->cmdidx == CMD_def) && VIM_ISWHITE(p[-1])) { semsg(_(e_no_white_space_allowed_before_str_str), "(", p - 1); goto ret_free; } // In Vim9 script only global functions can be redefined. if (vim9script && eap->forceit && !is_global) { emsg(_(e_no_bang_allowed)); goto ret_free; } ga_init2(&newlines, sizeof(char_u *), 10); if (!eap->skip && name_arg == NULL) { // Check the name of the function. Unless it's a dictionary function // (that we are overwriting). if (name != NULL) arg = name; else arg = fudi.fd_newkey; if (arg != NULL && (fudi.fd_di == NULL || (fudi.fd_di->di_tv.v_type != VAR_FUNC && fudi.fd_di->di_tv.v_type != VAR_PARTIAL))) { char_u *name_base = arg; int i; if (*arg == K_SPECIAL) { name_base = vim_strchr(arg, '_'); if (name_base == NULL) name_base = arg + 3; else ++name_base; } for (i = 0; name_base[i] != NUL && (i == 0 ? eval_isnamec1(name_base[i]) : eval_isnamec(name_base[i])); ++i) ; if (name_base[i] != NUL) emsg_funcname(e_invalid_argument_str, arg); // In Vim9 script a function cannot have the same name as a // variable. if (vim9script && *arg == K_SPECIAL && eval_variable(name_base, (int)STRLEN(name_base), 0, NULL, NULL, EVAL_VAR_NOAUTOLOAD + EVAL_VAR_IMPORT + EVAL_VAR_NO_FUNC) == OK) { semsg(_(e_redefining_script_item_str), name_base); goto ret_free; } } // Disallow using the g: dict. if (fudi.fd_dict != NULL && fudi.fd_dict->dv_scope == VAR_DEF_SCOPE) { emsg(_(e_cannot_use_g_here)); goto ret_free; } } // This may get more lines and make the pointers into the first line // invalid. ++p; if (get_function_args(&p, ')', &newargs, eap->cmdidx == CMD_def ? &argtypes : NULL, FALSE, NULL, &varargs, &default_args, eap->skip, eap, lines_to_free) == FAIL) goto errret_2; whitep = p; if (eap->cmdidx == CMD_def) { // find the return type: :def Func(): type if (*skipwhite(p) == ':') { if (*p != ':') { semsg(_(e_no_white_space_allowed_before_colon_str), p); p = skipwhite(p); } else if (!IS_WHITE_OR_NUL(p[1])) semsg(_(e_white_space_required_after_str_str), ":", p); ret_type = skipwhite(p + 1); p = skip_type(ret_type, FALSE); if (p > ret_type) { ret_type = vim_strnsave(ret_type, p - ret_type); whitep = p; p = skipwhite(p); } else { semsg(_(e_expected_type_str), ret_type); ret_type = NULL; } } p = skipwhite(p); } else // find extra arguments "range", "dict", "abort" and "closure" for (;;) { whitep = p; p = skipwhite(p); if (STRNCMP(p, "range", 5) == 0) { flags |= FC_RANGE; p += 5; } else if (STRNCMP(p, "dict", 4) == 0) { flags |= FC_DICT; p += 4; } else if (STRNCMP(p, "abort", 5) == 0) { flags |= FC_ABORT; p += 5; } else if (STRNCMP(p, "closure", 7) == 0) { flags |= FC_CLOSURE; p += 7; if (current_funccal == NULL) { emsg_funcname(e_closure_function_should_not_be_at_top_level, name == NULL ? (char_u *)"" : name); goto erret; } } else break; } // When there is a line break use what follows for the function body. // Makes 'exe "func Test()\n...\nendfunc"' work. if (*p == '\n') line_arg = p + 1; else if (*p != NUL && !(*p == '"' && (!vim9script || eap->cmdidx == CMD_function) && eap->cmdidx != CMD_def) && !(VIM_ISWHITE(*whitep) && *p == '#' && (vim9script || eap->cmdidx == CMD_def)) && !eap->skip && !did_emsg) semsg(_(e_trailing_characters_str), p); /* * Read the body of the function, until "}", ":endfunction" or ":enddef" is * found. */ if (KeyTyped) { // Check if the function already exists, don't let the user type the // whole function before telling him it doesn't work! For a script we // need to skip the body to be able to find what follows. if (!eap->skip && !eap->forceit) { if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL) emsg(_(e_dictionary_entry_already_exists)); else if (name != NULL && find_func(name, is_global) != NULL) emsg_funcname(e_function_str_already_exists_add_bang_to_replace, name); } if (!eap->skip && did_emsg) goto erret; msg_putchar('\n'); // don't overwrite the function name cmdline_row = msg_row; } // Save the starting line number. sourcing_lnum_top = SOURCING_LNUM; // Do not define the function when getting the body fails and when // skipping. if (get_function_body(eap, &newlines, line_arg, lines_to_free) == FAIL || eap->skip) goto erret; /* * If there are no errors, add the function */ if (fudi.fd_dict == NULL) { hashtab_T *ht; char_u *find_name = name; int var_conflict = FALSE; int ffed_flags = is_global ? FFED_IS_GLOBAL : 0; v = find_var(name, &ht, TRUE); if (v != NULL && (vim9script || v->di_tv.v_type == VAR_FUNC)) var_conflict = TRUE; if (SCRIPT_ID_VALID(current_sctx.sc_sid)) { scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); if (si->sn_autoload_prefix != NULL) { if (is_export) { find_name = name + STRLEN(si->sn_autoload_prefix); v = find_var(find_name, &ht, TRUE); if (v != NULL) var_conflict = TRUE; // Only check if the function already exists in the script, // global functions can be shadowed. ffed_flags |= FFED_NO_GLOBAL; } else { char_u *prefixed = may_prefix_autoload(name); if (prefixed != NULL && prefixed != name) { v = find_var(prefixed, &ht, TRUE); if (v != NULL) var_conflict = TRUE; vim_free(prefixed); } } } } if (var_conflict) { emsg_funcname(e_function_name_conflicts_with_variable_str, name); goto erret; } fp = find_func_even_dead(find_name, ffed_flags); if (vim9script) { char_u *uname = untrans_function_name(name); import = find_imported(uname == NULL ? name : uname, 0, FALSE); } if (fp != NULL || import != NULL) { int dead = fp != NULL && (fp->uf_flags & FC_DEAD); // Function can be replaced with "function!" and when sourcing the // same script again, but only once. // A name that is used by an import can not be overruled. if (import != NULL || (!dead && !eap->forceit && (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid || fp->uf_script_ctx.sc_seq == current_sctx.sc_seq))) { SOURCING_LNUM = sourcing_lnum_top; if (vim9script) emsg_funcname(e_name_already_defined_str, name); else emsg_funcname(e_function_str_already_exists_add_bang_to_replace, name); goto erret; } if (fp->uf_calls > 0) { emsg_funcname( e_cannot_redefine_function_str_it_is_in_use, name); goto erret; } if (fp->uf_refcount > 1) { // This function is referenced somewhere, don't redefine it but // create a new one. --fp->uf_refcount; fp->uf_flags |= FC_REMOVED; fp = NULL; overwrite = TRUE; } else { char_u *exp_name = fp->uf_name_exp; // redefine existing function, keep the expanded name VIM_CLEAR(name); fp->uf_name_exp = NULL; func_clear_items(fp); fp->uf_name_exp = exp_name; fp->uf_flags &= ~FC_DEAD; #ifdef FEAT_PROFILE fp->uf_profiling = FALSE; fp->uf_prof_initialized = FALSE; #endif fp->uf_def_status = UF_NOT_COMPILED; } } } else { char numbuf[20]; fp = NULL; if (fudi.fd_newkey == NULL && !eap->forceit) { emsg(_(e_dictionary_entry_already_exists)); goto erret; } if (fudi.fd_di == NULL) { // Can't add a function to a locked dictionary if (value_check_lock(fudi.fd_dict->dv_lock, eap->arg, FALSE)) goto erret; } // Can't change an existing function if it is locked else if (value_check_lock(fudi.fd_di->di_tv.v_lock, eap->arg, FALSE)) goto erret; // Give the function a sequential number. Can only be used with a // Funcref! vim_free(name); sprintf(numbuf, "%d", ++func_nr); name = vim_strsave((char_u *)numbuf); if (name == NULL) goto erret; } if (fp == NULL) { if (fudi.fd_dict == NULL && vim_strchr(name, AUTOLOAD_CHAR) != NULL) { int slen, plen; char_u *scriptname; // Check that the autoload name matches the script name. j = FAIL; if (SOURCING_NAME != NULL) { scriptname = autoload_name(name); if (scriptname != NULL) { p = vim_strchr(scriptname, '/'); plen = (int)STRLEN(p); slen = (int)STRLEN(SOURCING_NAME); if (slen > plen && fnamecmp(p, SOURCING_NAME + slen - plen) == 0) j = OK; vim_free(scriptname); } } if (j == FAIL) { linenr_T save_lnum = SOURCING_LNUM; SOURCING_LNUM = sourcing_lnum_top; semsg(_(e_function_name_does_not_match_script_file_name_str), name); SOURCING_LNUM = save_lnum; goto erret; } } fp = alloc_clear(offsetof(ufunc_T, uf_name) + STRLEN(name) + 1); if (fp == NULL) goto erret; fp_allocated = TRUE; if (fudi.fd_dict != NULL) { if (fudi.fd_di == NULL) { // add new dict entry fudi.fd_di = dictitem_alloc(fudi.fd_newkey); if (fudi.fd_di == NULL) { vim_free(fp); fp = NULL; goto erret; } if (dict_add(fudi.fd_dict, fudi.fd_di) == FAIL) { vim_free(fudi.fd_di); vim_free(fp); fp = NULL; goto erret; } } else // overwrite existing dict entry clear_tv(&fudi.fd_di->di_tv); fudi.fd_di->di_tv.v_type = VAR_FUNC; fudi.fd_di->di_tv.vval.v_string = vim_strsave(name); // behave like "dict" was used flags |= FC_DICT; } } fp->uf_args = newargs; fp->uf_def_args = default_args; fp->uf_ret_type = &t_any; fp->uf_func_type = &t_func_any; if (eap->cmdidx == CMD_def) { int lnum_save = SOURCING_LNUM; cstack_T *cstack = eap->cstack; fp->uf_def_status = UF_TO_BE_COMPILED; // error messages are for the first function line SOURCING_LNUM = sourcing_lnum_top; // The function may use script variables from the context. function_using_block_scopes(fp, cstack); if (parse_argument_types(fp, &argtypes, varargs) == FAIL) { SOURCING_LNUM = lnum_save; free_fp = fp_allocated; goto erret; } varargs = FALSE; // parse the return type, if any if (parse_return_type(fp, ret_type) == FAIL) { SOURCING_LNUM = lnum_save; free_fp = fp_allocated; goto erret; } SOURCING_LNUM = lnum_save; } else fp->uf_def_status = UF_NOT_COMPILED; if (fp_allocated) { // insert the new function in the function list set_ufunc_name(fp, name); if (overwrite) { hi = hash_find(&func_hashtab, name); hi->hi_key = UF2HIKEY(fp); } else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) { free_fp = TRUE; goto erret; } fp->uf_refcount = 1; } fp->uf_lines = newlines; newlines.ga_data = NULL; if ((flags & FC_CLOSURE) != 0) { if (register_closure(fp) == FAIL) goto erret; } else fp->uf_scoped = NULL; #ifdef FEAT_PROFILE if (prof_def_func()) func_do_profile(fp); #endif fp->uf_varargs = varargs; if (sandbox) flags |= FC_SANDBOX; if (vim9script && !ASCII_ISUPPER(*fp->uf_name)) flags |= FC_VIM9; fp->uf_flags = flags; fp->uf_calls = 0; fp->uf_cleared = FALSE; fp->uf_script_ctx = current_sctx; fp->uf_script_ctx_version = current_sctx.sc_version; fp->uf_script_ctx.sc_lnum += sourcing_lnum_top; if (is_export) { fp->uf_flags |= FC_EXPORT; // let ex_export() know the export worked. is_export = FALSE; } if (eap->cmdidx == CMD_def) set_function_type(fp); else if (fp->uf_script_ctx.sc_version == SCRIPT_VERSION_VIM9) // :func does not use Vim9 script syntax, even in a Vim9 script file fp->uf_script_ctx.sc_version = SCRIPT_VERSION_MAX; goto ret_free; erret: ga_clear_strings(&newargs); ga_clear_strings(&default_args); if (fp != NULL) { ga_init(&fp->uf_args); ga_init(&fp->uf_def_args); } errret_2: ga_clear_strings(&newlines); if (fp != NULL) VIM_CLEAR(fp->uf_arg_types); if (free_fp) { vim_free(fp); fp = NULL; } ret_free: ga_clear_strings(&argtypes); vim_free(fudi.fd_newkey); if (name != name_arg) vim_free(name); vim_free(ret_type); did_emsg |= saved_did_emsg; return fp; }
0
411,715
template<typename tc> CImg<T>& draw_line(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const tc *const color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true) { if (is_empty()) return *this; if (!color) throw CImgArgumentException(_cimg_instance "draw_line(): Specified color is (null).", cimg_instance); static unsigned int hatch = ~0U - (~0U>>1); if (init_hatch) hatch = ~0U - (~0U>>1); int nx0 = x0, ny0 = y0, nz0 = z0, nx1 = x1, ny1 = y1, nz1 = z1; if (nx0>nx1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1); if (nx1<0 || nx0>=width()) return *this; if (nx0<0) { const float D = 1.0f + nx1 - nx0; ny0-=(int)((float)nx0*(1.0f + ny1 - ny0)/D); nz0-=(int)((float)nx0*(1.0f + nz1 - nz0)/D); nx0 = 0; } if (nx1>=width()) { const float d = (float)nx1 - width(), D = 1.0f + nx1 - nx0; ny1+=(int)(d*(1.0f + ny0 - ny1)/D); nz1+=(int)(d*(1.0f + nz0 - nz1)/D); nx1 = width() - 1; } if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1); if (ny1<0 || ny0>=height()) return *this; if (ny0<0) { const float D = 1.0f + ny1 - ny0; nx0-=(int)((float)ny0*(1.0f + nx1 - nx0)/D); nz0-=(int)((float)ny0*(1.0f + nz1 - nz0)/D); ny0 = 0; } if (ny1>=height()) { const float d = (float)ny1 - height(), D = 1.0f + ny1 - ny0; nx1+=(int)(d*(1.0f + nx0 - nx1)/D); nz1+=(int)(d*(1.0f + nz0 - nz1)/D); ny1 = height() - 1; } if (nz0>nz1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1); if (nz1<0 || nz0>=depth()) return *this; if (nz0<0) { const float D = 1.0f + nz1 - nz0; nx0-=(int)((float)nz0*(1.0f + nx1 - nx0)/D); ny0-=(int)((float)nz0*(1.0f + ny1 - ny0)/D); nz0 = 0; } if (nz1>=depth()) { const float d = (float)nz1 - depth(), D = 1.0f + nz1 - nz0; nx1+=(int)(d*(1.0f + nx0 - nx1)/D); ny1+=(int)(d*(1.0f + ny0 - ny1)/D); nz1 = depth() - 1; } const unsigned int dmax = (unsigned int)cimg::max(cimg::abs(nx1 - nx0),cimg::abs(ny1 - ny0),nz1 - nz0); const ulongT whd = (ulongT)_width*_height*_depth; const float px = (nx1 - nx0)/(float)dmax, py = (ny1 - ny0)/(float)dmax, pz = (nz1 - nz0)/(float)dmax; float x = (float)nx0, y = (float)ny0, z = (float)nz0; if (opacity>=1) for (unsigned int t = 0; t<=dmax; ++t) { if (!(~pattern) || (~pattern && pattern&hatch)) { T* ptrd = data((unsigned int)x,(unsigned int)y,(unsigned int)z); const tc *col = color; cimg_forC(*this,c) { *ptrd = (T)*(col++); ptrd+=whd; } } x+=px; y+=py; z+=pz; if (pattern) { hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1); } } else { const float nopacity = cimg::abs(opacity), copacity = 1 - std::max(opacity,0.0f); for (unsigned int t = 0; t<=dmax; ++t) { if (!(~pattern) || (~pattern && pattern&hatch)) { T* ptrd = data((unsigned int)x,(unsigned int)y,(unsigned int)z); const tc *col = color; cimg_forC(*this,c) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whd; } } x+=px; y+=py; z+=pz; if (pattern) { hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1); } } } return *this;
0
339,528
vnc_display_setup_auth(VncDisplay *vs, bool password, bool sasl, bool tls, bool x509) { /* * We have a choice of 3 authentication options * * 1. none * 2. vnc * 3. sasl * * The channel can be run in 2 modes * * 1. clear * 2. tls * * And TLS can use 2 types of credentials * * 1. anon * 2. x509 * * We thus have 9 possible logical combinations * * 1. clear + none * 2. clear + vnc * 3. clear + sasl * 4. tls + anon + none * 5. tls + anon + vnc * 6. tls + anon + sasl * 7. tls + x509 + none * 8. tls + x509 + vnc * 9. tls + x509 + sasl * * These need to be mapped into the VNC auth schemes * in an appropriate manner. In regular VNC, all the * TLS options get mapped into VNC_AUTH_VENCRYPT * sub-auth types. */ if (password) { if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509VNC; } else { VNC_DEBUG("Initializing VNC server with TLS password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC; } } else { VNC_DEBUG("Initializing VNC server with password auth\n"); vs->auth = VNC_AUTH_VNC; vs->subauth = VNC_AUTH_INVALID; } } else if (sasl) { if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509SASL; } else { VNC_DEBUG("Initializing VNC server with TLS SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL; } } else { VNC_DEBUG("Initializing VNC server with SASL auth\n"); vs->auth = VNC_AUTH_SASL; vs->subauth = VNC_AUTH_INVALID; } } else { if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509NONE; } else { VNC_DEBUG("Initializing VNC server with TLS no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE; } } else { VNC_DEBUG("Initializing VNC server with no auth\n"); vs->auth = VNC_AUTH_NONE; vs->subauth = VNC_AUTH_INVALID; } } }
0
144,882
flatpak_dir_new_full (GFile *path, gboolean user, DirExtraData *extra_data) { FlatpakDir *dir = g_object_new (FLATPAK_TYPE_DIR, "path", path, "user", user, NULL); if (extra_data != NULL) dir->extra_data = dir_extra_data_clone (extra_data); return dir; }
0
437,542
static void io_submit_state_end(struct io_submit_state *state) { blk_finish_plug(&state->plug); io_file_put(state); if (state->free_reqs) kmem_cache_free_bulk(req_cachep, state->free_reqs, &state->reqs[state->cur_req]); }
0
42,064
ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip) { return 1; }
0
54,623
mp_sint32 PlayerGeneric::getCurrentBeatIndex() { if (player) return player->getBeatIndexFromSamplePos(getCurrentSamplePosition()); return 0; }
0
136,247
String StringUtil::Translate(const String& input, const String& from, const String& to) { if (input.empty()) return input; int len = input.size(); String retstr(len, ReserveString); char *ret = retstr.mutableData(); memcpy(ret, input.data(), len); auto trlen = std::min(from.size(), to.size()); string_translate(ret, len, from.data(), to.data(), trlen); retstr.setSize(len); return retstr; }
0
335,302
static bool event_notifier_poll(void *opaque) { EventNotifier *e = opaque; AioContext *ctx = container_of(e, AioContext, notifier); return atomic_read(&ctx->notified); }
0
239,822
void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { if (!owned_by_render_frame_host_) { Destroy(true); } else { RendererExited(static_cast<base::TerminationStatus>(status), exit_code); } }
0
479,557
static cimg_int64 cut(const double val) { return val<(double)min()?min():val>(double)max()?max():(cimg_int64)val; }
0
474,807
static void __sock_set_timestamps(struct sock *sk, bool val, bool new, bool ns) { if (val) { sock_valbool_flag(sk, SOCK_TSTAMP_NEW, new); sock_valbool_flag(sk, SOCK_RCVTSTAMPNS, ns); sock_set_flag(sk, SOCK_RCVTSTAMP); sock_enable_timestamp(sk, SOCK_TIMESTAMP); } else { sock_reset_flag(sk, SOCK_RCVTSTAMP); sock_reset_flag(sk, SOCK_RCVTSTAMPNS); } }
0
97,033
multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flags) { struct gc_arena gc = gc_new(); bool ret = true; if (BLEN(&m->top.c2.buf) > 0) { unsigned int mroute_flags; struct mroute_addr src, dest; const int dev_type = TUNNEL_TYPE(m->top.c1.tuntap); int16_t vid = 0; #ifdef ENABLE_PF struct mroute_addr esrc, *e1, *e2; if (dev_type == DEV_TYPE_TUN) { e1 = NULL; e2 = &src; } else { e1 = e2 = &esrc; mroute_addr_reset(&esrc); } #endif #ifdef MULTI_DEBUG_EVENT_LOOP printf("TUN -> TCP/UDP [%d]\n", BLEN(&m->top.c2.buf)); #endif if (m->pending) { return true; } if (dev_type == DEV_TYPE_TAP && m->top.options.vlan_tagging) { vid = vlan_decapsulate(&m->top, &m->top.c2.buf); if (vid < 0) { return false; } } /* * Route an incoming tun/tap packet to * the appropriate multi_instance object. */ mroute_flags = mroute_extract_addr_from_packet(&src, &dest, #ifdef ENABLE_PF e1, #else NULL, #endif NULL, vid, &m->top.c2.buf, dev_type); if (mroute_flags & MROUTE_EXTRACT_SUCCEEDED) { struct context *c; /* broadcast or multicast dest addr? */ if (mroute_flags & (MROUTE_EXTRACT_BCAST|MROUTE_EXTRACT_MCAST)) { /* for now, treat multicast as broadcast */ #ifdef ENABLE_PF multi_bcast(m, &m->top.c2.buf, NULL, e2, vid); #else multi_bcast(m, &m->top.c2.buf, NULL, NULL, vid); #endif } else { multi_set_pending(m, multi_get_instance_by_virtual_addr(m, &dest, dev_type == DEV_TYPE_TUN)); if (m->pending) { /* get instance context */ c = &m->pending->context; set_prefix(m->pending); #ifdef ENABLE_PF if (!pf_addr_test(&c->c2.pf, c, e2, "tun_tap_src_addr")) { msg(D_PF_DROPPED, "PF: addr[%s] -> client packet dropped by packet filter", mroute_addr_print_ex(&src, MAPF_SHOW_ARP, &gc)); buf_reset_len(&c->c2.buf); } else #endif { if (multi_output_queue_ready(m, m->pending)) { /* transfer packet pointer from top-level context buffer to instance */ c->c2.buf = m->top.c2.buf; } else { /* drop packet */ msg(D_MULTI_DROPPED, "MULTI: packet dropped due to output saturation (multi_process_incoming_tun)"); buf_reset_len(&c->c2.buf); } } /* encrypt in instance context */ process_incoming_tun(c); /* postprocess and set wakeup */ ret = multi_process_post(m, m->pending, mpp_flags); clear_prefix(); } } } } gc_free(&gc); return ret; }
0
482,534
static void sqlite3WhereOpcodeRewriteTrace( sqlite3 *db, int pc, VdbeOp *pOp ){ if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return; sqlite3VdbePrintOp(0, pc, pOp); }
0
271,129
static void do_pcd_read(void) { pcd_busy = 1; pcd_retries = 0; pcd_transfer(); if (!pcd_count) { next_request(0); return; } pi_do_claimed(pcd_current->pi, pcd_start); }
0
407,605
ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf) { ldns_status res = LDNS_STATUS_OK; /*ldns_buffer_printf(buffer, "%u:", ldns_rdf_get_type(rdf));*/ if (rdf) { switch(ldns_rdf_get_type(rdf)) { case LDNS_RDF_TYPE_NONE: break; case LDNS_RDF_TYPE_DNAME: res = ldns_rdf2buffer_str_dname(buffer, rdf); break; case LDNS_RDF_TYPE_INT8: res = ldns_rdf2buffer_str_int8(buffer, rdf); break; case LDNS_RDF_TYPE_INT16: res = ldns_rdf2buffer_str_int16(buffer, rdf); break; case LDNS_RDF_TYPE_INT32: res = ldns_rdf2buffer_str_int32(buffer, rdf); break; case LDNS_RDF_TYPE_PERIOD: res = ldns_rdf2buffer_str_period(buffer, rdf); break; case LDNS_RDF_TYPE_TSIGTIME: res = ldns_rdf2buffer_str_tsigtime(buffer, rdf); break; case LDNS_RDF_TYPE_A: res = ldns_rdf2buffer_str_a(buffer, rdf); break; case LDNS_RDF_TYPE_AAAA: res = ldns_rdf2buffer_str_aaaa(buffer, rdf); break; case LDNS_RDF_TYPE_STR: res = ldns_rdf2buffer_str_str(buffer, rdf); break; case LDNS_RDF_TYPE_APL: res = ldns_rdf2buffer_str_apl(buffer, rdf); break; case LDNS_RDF_TYPE_B32_EXT: res = ldns_rdf2buffer_str_b32_ext(buffer, rdf); break; case LDNS_RDF_TYPE_B64: res = ldns_rdf2buffer_str_b64(buffer, rdf); break; case LDNS_RDF_TYPE_HEX: res = ldns_rdf2buffer_str_hex(buffer, rdf); break; case LDNS_RDF_TYPE_NSEC: res = ldns_rdf2buffer_str_nsec(buffer, rdf); break; case LDNS_RDF_TYPE_NSEC3_SALT: res = ldns_rdf2buffer_str_nsec3_salt(buffer, rdf); break; case LDNS_RDF_TYPE_TYPE: res = ldns_rdf2buffer_str_type(buffer, rdf); break; case LDNS_RDF_TYPE_CLASS: res = ldns_rdf2buffer_str_class(buffer, rdf); break; case LDNS_RDF_TYPE_CERT_ALG: res = ldns_rdf2buffer_str_cert_alg(buffer, rdf); break; case LDNS_RDF_TYPE_ALG: res = ldns_rdf2buffer_str_alg(buffer, rdf); break; case LDNS_RDF_TYPE_UNKNOWN: res = ldns_rdf2buffer_str_unknown(buffer, rdf); break; case LDNS_RDF_TYPE_TIME: res = ldns_rdf2buffer_str_time(buffer, rdf); break; case LDNS_RDF_TYPE_LOC: res = ldns_rdf2buffer_str_loc(buffer, rdf); break; case LDNS_RDF_TYPE_WKS: case LDNS_RDF_TYPE_SERVICE: res = ldns_rdf2buffer_str_wks(buffer, rdf); break; case LDNS_RDF_TYPE_NSAP: res = ldns_rdf2buffer_str_nsap(buffer, rdf); break; case LDNS_RDF_TYPE_ATMA: res = ldns_rdf2buffer_str_atma(buffer, rdf); break; case LDNS_RDF_TYPE_IPSECKEY: res = ldns_rdf2buffer_str_ipseckey(buffer, rdf); break; case LDNS_RDF_TYPE_TSIG: res = ldns_rdf2buffer_str_tsig(buffer, rdf); break; case LDNS_RDF_TYPE_INT16_DATA: res = ldns_rdf2buffer_str_int16_data(buffer, rdf); break; case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER: res = ldns_rdf2buffer_str_b32_ext(buffer, rdf); break; case LDNS_RDF_TYPE_ILNP64: res = ldns_rdf2buffer_str_ilnp64(buffer, rdf); break; case LDNS_RDF_TYPE_EUI48: res = ldns_rdf2buffer_str_eui48(buffer, rdf); break; case LDNS_RDF_TYPE_EUI64: res = ldns_rdf2buffer_str_eui64(buffer, rdf); break; case LDNS_RDF_TYPE_TAG: res = ldns_rdf2buffer_str_tag(buffer, rdf); break; case LDNS_RDF_TYPE_LONG_STR: res = ldns_rdf2buffer_str_long_str(buffer, rdf); break; case LDNS_RDF_TYPE_MULTI_STR: res = ldns_rdf2buffer_str_multi_str(buffer, rdf); break; } } else { /** This will write mangled RRs */ ldns_buffer_printf(buffer, "(null) "); res = LDNS_STATUS_ERR; } return res; }
0
330,677
static inline int halfpel_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr, int dmin, int xmin, int ymin, int xmax, int ymax, int pred_x, int pred_y, uint8_t *ref_picture) { UINT16 *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame const int quant= s->qscale; int pen_x, pen_y; int mx, my, mx1, my1, d, xx, yy, dminh; UINT8 *pix, *ptr; mx = *mx_ptr; my = *my_ptr; ptr = ref_picture + (my * s->linesize) + mx; xx = 16 * s->mb_x; yy = 16 * s->mb_y; pix = s->new_picture[0] + (yy * s->linesize) + xx; dminh = dmin; if (mx > xmin && mx < xmax && my > ymin && my < ymax) { mx= mx1= 2*(mx - xx); my= my1= 2*(my - yy); if(dmin < Z_THRESHOLD && mx==0 && my==0){ *mx_ptr = 0; *my_ptr = 0; return dmin; } pen_x= pred_x + mx; pen_y= pred_y + my; ptr-= s->linesize; CHECK_HALF_MV(xy2, -1, -1) CHECK_HALF_MV(y2 , 0, -1) CHECK_HALF_MV(xy2, +1, -1) ptr+= s->linesize; CHECK_HALF_MV(x2 , -1, 0) CHECK_HALF_MV(x2 , +1, 0) CHECK_HALF_MV(xy2, -1, +1) CHECK_HALF_MV(y2 , 0, +1) CHECK_HALF_MV(xy2, +1, +1) }else{ mx= 2*(mx - xx); my= 2*(my - yy); } *mx_ptr = mx; *my_ptr = my; return dminh; }
0
38,806
Error Box::read_children(BitstreamRange& range, int max_number) { int count = 0; while (!range.eof() && !range.error()) { std::shared_ptr<Box> box; Error error = Box::read(range, &box); if (error != Error::Ok) { return error; } if (m_children.size() > MAX_CHILDREN_PER_BOX) { std::stringstream sstr; sstr << "Maximum number of child boxes " << MAX_CHILDREN_PER_BOX << " exceeded."; // Sanity check. return Error(heif_error_Memory_allocation_error, heif_suberror_Security_limit_exceeded, sstr.str()); } m_children.push_back(std::move(box)); // count the new child and end reading new children when we reached the expected number count++; if (max_number != READ_CHILDREN_ALL && count == max_number) { break; } } return range.get_error(); }
0
272,487
PHP_FUNCTION(imagecopymerge) { zval *SIM, *DIM; long SX, SY, SW, SH, DX, DY, PCT; gdImagePtr im_dst, im_src; int srcH, srcW, srcY, srcX, dstY, dstX, pct; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrlllllll", &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH, &PCT) == FAILURE) { return; } ZEND_FETCH_RESOURCE(im_src, gdImagePtr, &SIM, -1, "Image", le_gd); ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, &DIM, -1, "Image", le_gd); srcX = SX; srcY = SY; srcH = SH; srcW = SW; dstX = DX; dstY = DY; pct = PCT; gdImageCopyMerge(im_dst, im_src, dstX, dstY, srcX, srcY, srcW, srcH, pct); RETURN_TRUE; }
0
356,735
static jas_cmreal_t jas_cmshapmatlut_lookup(jas_cmshapmatlut_t *lut, jas_cmreal_t x) { jas_cmreal_t t; int lo; int hi; t = x * (lut->size - 1); lo = floor(t); if (lo < 0) return lut->data[0]; hi = ceil(t); if (hi >= lut->size) return lut->data[lut->size - 1]; return lut->data[lo] + (t - lo) * (lut->data[hi] - lut->data[lo]); }
0
354,002
gst_matroska_demux_parse_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml, GstMatroskaTrackContext ** dest_context) { GstMatroskaTrackContext *context; GstCaps *caps = NULL; GstTagList *cached_taglist; GstFlowReturn ret; guint32 id, riff_fourcc = 0; guint16 riff_audio_fmt = 0; gchar *codec = NULL; DEBUG_ELEMENT_START (demux, ebml, "TrackEntry"); /* start with the master */ if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) { DEBUG_ELEMENT_STOP (demux, ebml, "TrackEntry", ret); return ret; } /* allocate generic... if we know the type, we'll g_renew() * with the precise type */ context = g_new0 (GstMatroskaTrackContext, 1); context->index_writer_id = -1; context->type = 0; /* no type yet */ context->default_duration = 0; context->pos = 0; context->set_discont = TRUE; context->timecodescale = 1.0; context->flags = GST_MATROSKA_TRACK_ENABLED | GST_MATROSKA_TRACK_DEFAULT | GST_MATROSKA_TRACK_LACING; context->from_time = GST_CLOCK_TIME_NONE; context->from_offset = -1; context->to_offset = G_MAXINT64; context->alignment = 1; context->dts_only = FALSE; context->intra_only = FALSE; context->tags = gst_tag_list_new_empty (); g_queue_init (&context->protection_event_queue); context->protection_info = NULL; GST_DEBUG_OBJECT (demux, "Parsing a TrackEntry (%d tracks parsed so far)", demux->common.num_streams); /* try reading the trackentry headers */ while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) { if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK) break; switch (id) { /* track number (unique stream ID) */ case GST_MATROSKA_ID_TRACKNUMBER:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 0) { GST_ERROR_OBJECT (demux, "Invalid TrackNumber 0"); ret = GST_FLOW_ERROR; break; } GST_DEBUG_OBJECT (demux, "TrackNumber: %" G_GUINT64_FORMAT, num); context->num = num; break; } /* track UID (unique identifier) */ case GST_MATROSKA_ID_TRACKUID:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 0) { GST_ERROR_OBJECT (demux, "Invalid TrackUID 0"); ret = GST_FLOW_ERROR; break; } GST_DEBUG_OBJECT (demux, "TrackUID: %" G_GUINT64_FORMAT, num); context->uid = num; break; } /* track type (video, audio, combined, subtitle, etc.) */ case GST_MATROSKA_ID_TRACKTYPE:{ guint64 track_type; if ((ret = gst_ebml_read_uint (ebml, &id, &track_type)) != GST_FLOW_OK) { break; } if (context->type != 0 && context->type != track_type) { GST_WARNING_OBJECT (demux, "More than one tracktype defined in a TrackEntry - skipping"); break; } else if (track_type < 1 || track_type > 254) { GST_WARNING_OBJECT (demux, "Invalid TrackType %" G_GUINT64_FORMAT, track_type); break; } GST_DEBUG_OBJECT (demux, "TrackType: %" G_GUINT64_FORMAT, track_type); /* ok, so we're actually going to reallocate this thing */ switch (track_type) { case GST_MATROSKA_TRACK_TYPE_VIDEO: gst_matroska_track_init_video_context (&context); break; case GST_MATROSKA_TRACK_TYPE_AUDIO: gst_matroska_track_init_audio_context (&context); break; case GST_MATROSKA_TRACK_TYPE_SUBTITLE: gst_matroska_track_init_subtitle_context (&context); break; case GST_MATROSKA_TRACK_TYPE_COMPLEX: case GST_MATROSKA_TRACK_TYPE_LOGO: case GST_MATROSKA_TRACK_TYPE_BUTTONS: case GST_MATROSKA_TRACK_TYPE_CONTROL: default: GST_WARNING_OBJECT (demux, "Unknown or unsupported TrackType %" G_GUINT64_FORMAT, track_type); context->type = 0; break; } break; } /* tracktype specific stuff for video */ case GST_MATROSKA_ID_TRACKVIDEO:{ GstMatroskaTrackVideoContext *videocontext; DEBUG_ELEMENT_START (demux, ebml, "TrackVideo"); if (!gst_matroska_track_init_video_context (&context)) { GST_WARNING_OBJECT (demux, "TrackVideo element in non-video track - ignoring track"); ret = GST_FLOW_ERROR; break; } else if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) { break; } videocontext = (GstMatroskaTrackVideoContext *) context; while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) { if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK) break; switch (id) { /* Should be one level up but some broken muxers write it here. */ case GST_MATROSKA_ID_TRACKDEFAULTDURATION:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 0) { GST_WARNING_OBJECT (demux, "Invalid TrackDefaultDuration 0"); break; } GST_DEBUG_OBJECT (demux, "TrackDefaultDuration: %" G_GUINT64_FORMAT, num); context->default_duration = num; break; } /* video framerate */ /* NOTE: This one is here only for backward compatibility. * Use _TRACKDEFAULDURATION one level up. */ case GST_MATROSKA_ID_VIDEOFRAMERATE:{ gdouble num; if ((ret = gst_ebml_read_float (ebml, &id, &num)) != GST_FLOW_OK) break; if (num <= 0.0) { GST_WARNING_OBJECT (demux, "Invalid TrackVideoFPS %lf", num); break; } GST_DEBUG_OBJECT (demux, "TrackVideoFrameRate: %lf", num); if (context->default_duration == 0) context->default_duration = gst_gdouble_to_guint64 ((gdouble) GST_SECOND * (1.0 / num)); videocontext->default_fps = num; break; } /* width of the size to display the video at */ case GST_MATROSKA_ID_VIDEODISPLAYWIDTH:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 0) { GST_WARNING_OBJECT (demux, "Invalid TrackVideoDisplayWidth 0"); break; } GST_DEBUG_OBJECT (demux, "TrackVideoDisplayWidth: %" G_GUINT64_FORMAT, num); videocontext->display_width = num; break; } /* height of the size to display the video at */ case GST_MATROSKA_ID_VIDEODISPLAYHEIGHT:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 0) { GST_WARNING_OBJECT (demux, "Invalid TrackVideoDisplayHeight 0"); break; } GST_DEBUG_OBJECT (demux, "TrackVideoDisplayHeight: %" G_GUINT64_FORMAT, num); videocontext->display_height = num; break; } /* width of the video in the file */ case GST_MATROSKA_ID_VIDEOPIXELWIDTH:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 0) { GST_WARNING_OBJECT (demux, "Invalid TrackVideoPixelWidth 0"); break; } GST_DEBUG_OBJECT (demux, "TrackVideoPixelWidth: %" G_GUINT64_FORMAT, num); videocontext->pixel_width = num; break; } /* height of the video in the file */ case GST_MATROSKA_ID_VIDEOPIXELHEIGHT:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 0) { GST_WARNING_OBJECT (demux, "Invalid TrackVideoPixelHeight 0"); break; } GST_DEBUG_OBJECT (demux, "TrackVideoPixelHeight: %" G_GUINT64_FORMAT, num); videocontext->pixel_height = num; break; } /* whether the video is interlaced */ case GST_MATROSKA_ID_VIDEOFLAGINTERLACED:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 1) videocontext->interlace_mode = GST_MATROSKA_INTERLACE_MODE_INTERLACED; else if (num == 2) videocontext->interlace_mode = GST_MATROSKA_INTERLACE_MODE_PROGRESSIVE; else videocontext->interlace_mode = GST_MATROSKA_INTERLACE_MODE_UNKNOWN; GST_DEBUG_OBJECT (demux, "video track interlacing mode: %d", videocontext->interlace_mode); break; } /* interlaced field order */ case GST_MATROSKA_ID_VIDEOFIELDORDER:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (videocontext->interlace_mode != GST_MATROSKA_INTERLACE_MODE_INTERLACED) { GST_WARNING_OBJECT (demux, "FieldOrder element when not interlaced - ignoring"); break; } if (num == 0) /* turns out we're actually progressive */ videocontext->interlace_mode = GST_MATROSKA_INTERLACE_MODE_PROGRESSIVE; else if (num == 2) videocontext->field_order = GST_VIDEO_FIELD_ORDER_UNKNOWN; else if (num == 9) videocontext->field_order = GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST; else if (num == 14) videocontext->field_order = GST_VIDEO_FIELD_ORDER_BOTTOM_FIELD_FIRST; else { GST_FIXME_OBJECT (demux, "Unknown or unsupported FieldOrder %" G_GUINT64_FORMAT, num); videocontext->field_order = GST_VIDEO_FIELD_ORDER_UNKNOWN; } GST_DEBUG_OBJECT (demux, "video track field order: %d", videocontext->field_order); break; } /* aspect ratio behaviour */ case GST_MATROSKA_ID_VIDEOASPECTRATIOTYPE:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num != GST_MATROSKA_ASPECT_RATIO_MODE_FREE && num != GST_MATROSKA_ASPECT_RATIO_MODE_KEEP && num != GST_MATROSKA_ASPECT_RATIO_MODE_FIXED) { GST_WARNING_OBJECT (demux, "Unknown TrackVideoAspectRatioType 0x%x", (guint) num); break; } GST_DEBUG_OBJECT (demux, "TrackVideoAspectRatioType: %" G_GUINT64_FORMAT, num); videocontext->asr_mode = num; break; } /* colourspace (only matters for raw video) fourcc */ case GST_MATROSKA_ID_VIDEOCOLOURSPACE:{ guint8 *data; guint64 datalen; if ((ret = gst_ebml_read_binary (ebml, &id, &data, &datalen)) != GST_FLOW_OK) break; if (datalen != 4) { g_free (data); GST_WARNING_OBJECT (demux, "Invalid TrackVideoColourSpace length %" G_GUINT64_FORMAT, datalen); break; } memcpy (&videocontext->fourcc, data, 4); GST_DEBUG_OBJECT (demux, "TrackVideoColourSpace: %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (videocontext->fourcc)); g_free (data); break; } /* color info */ case GST_MATROSKA_ID_VIDEOCOLOUR:{ ret = gst_matroska_demux_parse_colour (demux, ebml, videocontext); break; } case GST_MATROSKA_ID_VIDEOSTEREOMODE: { guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; GST_DEBUG_OBJECT (demux, "StereoMode: %" G_GUINT64_FORMAT, num); switch (num) { case GST_MATROSKA_STEREO_MODE_SBS_RL: videocontext->multiview_flags = GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST; /* fall through */ case GST_MATROSKA_STEREO_MODE_SBS_LR: videocontext->multiview_mode = GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE; break; case GST_MATROSKA_STEREO_MODE_TB_RL: videocontext->multiview_flags = GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST; /* fall through */ case GST_MATROSKA_STEREO_MODE_TB_LR: videocontext->multiview_mode = GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM; break; case GST_MATROSKA_STEREO_MODE_CHECKER_RL: videocontext->multiview_flags = GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST; /* fall through */ case GST_MATROSKA_STEREO_MODE_CHECKER_LR: videocontext->multiview_mode = GST_VIDEO_MULTIVIEW_MODE_CHECKERBOARD; break; case GST_MATROSKA_STEREO_MODE_FBF_RL: videocontext->multiview_flags = GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST; /* fall through */ case GST_MATROSKA_STEREO_MODE_FBF_LR: videocontext->multiview_mode = GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME; /* FIXME: In frame-by-frame mode, left/right frame buffers are * laced within one block, and we'll need to apply FIRST_IN_BUNDLE * accordingly. See http://www.matroska.org/technical/specs/index.html#StereoMode */ GST_FIXME_OBJECT (demux, "Frame-by-frame stereoscopic mode not fully implemented"); break; } break; } default: GST_WARNING_OBJECT (demux, "Unknown TrackVideo subelement 0x%x - ignoring", id); /* fall through */ case GST_MATROSKA_ID_VIDEODISPLAYUNIT: case GST_MATROSKA_ID_VIDEOPIXELCROPBOTTOM: case GST_MATROSKA_ID_VIDEOPIXELCROPTOP: case GST_MATROSKA_ID_VIDEOPIXELCROPLEFT: case GST_MATROSKA_ID_VIDEOPIXELCROPRIGHT: case GST_MATROSKA_ID_VIDEOGAMMAVALUE: ret = gst_ebml_read_skip (ebml); break; } } DEBUG_ELEMENT_STOP (demux, ebml, "TrackVideo", ret); break; } /* tracktype specific stuff for audio */ case GST_MATROSKA_ID_TRACKAUDIO:{ GstMatroskaTrackAudioContext *audiocontext; DEBUG_ELEMENT_START (demux, ebml, "TrackAudio"); if (!gst_matroska_track_init_audio_context (&context)) { GST_WARNING_OBJECT (demux, "TrackAudio element in non-audio track - ignoring track"); ret = GST_FLOW_ERROR; break; } if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) break; audiocontext = (GstMatroskaTrackAudioContext *) context; while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) { if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK) break; switch (id) { /* samplerate */ case GST_MATROSKA_ID_AUDIOSAMPLINGFREQ:{ gdouble num; if ((ret = gst_ebml_read_float (ebml, &id, &num)) != GST_FLOW_OK) break; if (num <= 0.0) { GST_WARNING_OBJECT (demux, "Invalid TrackAudioSamplingFrequency %lf", num); break; } GST_DEBUG_OBJECT (demux, "TrackAudioSamplingFrequency: %lf", num); audiocontext->samplerate = num; break; } /* bitdepth */ case GST_MATROSKA_ID_AUDIOBITDEPTH:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 0) { GST_WARNING_OBJECT (demux, "Invalid TrackAudioBitDepth 0"); break; } GST_DEBUG_OBJECT (demux, "TrackAudioBitDepth: %" G_GUINT64_FORMAT, num); audiocontext->bitdepth = num; break; } /* channels */ case GST_MATROSKA_ID_AUDIOCHANNELS:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 0) { GST_WARNING_OBJECT (demux, "Invalid TrackAudioChannels 0"); break; } GST_DEBUG_OBJECT (demux, "TrackAudioChannels: %" G_GUINT64_FORMAT, num); audiocontext->channels = num; break; } default: GST_WARNING_OBJECT (demux, "Unknown TrackAudio subelement 0x%x - ignoring", id); /* fall through */ case GST_MATROSKA_ID_AUDIOCHANNELPOSITIONS: case GST_MATROSKA_ID_AUDIOOUTPUTSAMPLINGFREQ: ret = gst_ebml_read_skip (ebml); break; } } DEBUG_ELEMENT_STOP (demux, ebml, "TrackAudio", ret); break; } /* codec identifier */ case GST_MATROSKA_ID_CODECID:{ gchar *text; if ((ret = gst_ebml_read_ascii (ebml, &id, &text)) != GST_FLOW_OK) break; GST_DEBUG_OBJECT (demux, "CodecID: %s", GST_STR_NULL (text)); context->codec_id = text; break; } /* codec private data */ case GST_MATROSKA_ID_CODECPRIVATE:{ guint8 *data; guint64 size; if ((ret = gst_ebml_read_binary (ebml, &id, &data, &size)) != GST_FLOW_OK) break; context->codec_priv = data; context->codec_priv_size = size; GST_DEBUG_OBJECT (demux, "CodecPrivate of size %" G_GUINT64_FORMAT, size); break; } /* name of the codec */ case GST_MATROSKA_ID_CODECNAME:{ gchar *text; if ((ret = gst_ebml_read_utf8 (ebml, &id, &text)) != GST_FLOW_OK) break; GST_DEBUG_OBJECT (demux, "CodecName: %s", GST_STR_NULL (text)); context->codec_name = text; break; } /* codec delay */ case GST_MATROSKA_ID_CODECDELAY:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; context->codec_delay = num; GST_DEBUG_OBJECT (demux, "CodecDelay: %" GST_TIME_FORMAT, GST_TIME_ARGS (num)); break; } /* codec delay */ case GST_MATROSKA_ID_SEEKPREROLL:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; context->seek_preroll = num; GST_DEBUG_OBJECT (demux, "SeekPreroll: %" GST_TIME_FORMAT, GST_TIME_ARGS (num)); break; } /* name of this track */ case GST_MATROSKA_ID_TRACKNAME:{ gchar *text; if ((ret = gst_ebml_read_utf8 (ebml, &id, &text)) != GST_FLOW_OK) break; context->name = text; GST_DEBUG_OBJECT (demux, "TrackName: %s", GST_STR_NULL (text)); break; } /* language (matters for audio/subtitles, mostly) */ case GST_MATROSKA_ID_TRACKLANGUAGE:{ gchar *text; if ((ret = gst_ebml_read_utf8 (ebml, &id, &text)) != GST_FLOW_OK) break; context->language = text; /* fre-ca => fre */ if (strlen (context->language) >= 4 && context->language[3] == '-') context->language[3] = '\0'; GST_DEBUG_OBJECT (demux, "TrackLanguage: %s", GST_STR_NULL (context->language)); break; } /* whether this is actually used */ case GST_MATROSKA_ID_TRACKFLAGENABLED:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num) context->flags |= GST_MATROSKA_TRACK_ENABLED; else context->flags &= ~GST_MATROSKA_TRACK_ENABLED; GST_DEBUG_OBJECT (demux, "TrackEnabled: %d", (context->flags & GST_MATROSKA_TRACK_ENABLED) ? 1 : 0); break; } /* whether it's the default for this track type */ case GST_MATROSKA_ID_TRACKFLAGDEFAULT:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num) context->flags |= GST_MATROSKA_TRACK_DEFAULT; else context->flags &= ~GST_MATROSKA_TRACK_DEFAULT; GST_DEBUG_OBJECT (demux, "TrackDefault: %d", (context->flags & GST_MATROSKA_TRACK_DEFAULT) ? 1 : 0); break; } /* whether the track must be used during playback */ case GST_MATROSKA_ID_TRACKFLAGFORCED:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num) context->flags |= GST_MATROSKA_TRACK_FORCED; else context->flags &= ~GST_MATROSKA_TRACK_FORCED; GST_DEBUG_OBJECT (demux, "TrackForced: %d", (context->flags & GST_MATROSKA_TRACK_FORCED) ? 1 : 0); break; } /* lacing (like MPEG, where blocks don't end/start on frame * boundaries) */ case GST_MATROSKA_ID_TRACKFLAGLACING:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num) context->flags |= GST_MATROSKA_TRACK_LACING; else context->flags &= ~GST_MATROSKA_TRACK_LACING; GST_DEBUG_OBJECT (demux, "TrackLacing: %d", (context->flags & GST_MATROSKA_TRACK_LACING) ? 1 : 0); break; } /* default length (in time) of one data block in this track */ case GST_MATROSKA_ID_TRACKDEFAULTDURATION:{ guint64 num; if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK) break; if (num == 0) { GST_WARNING_OBJECT (demux, "Invalid TrackDefaultDuration 0"); break; } GST_DEBUG_OBJECT (demux, "TrackDefaultDuration: %" G_GUINT64_FORMAT, num); context->default_duration = num; break; } case GST_MATROSKA_ID_CONTENTENCODINGS:{ ret = gst_matroska_read_common_read_track_encodings (&demux->common, ebml, context); break; } case GST_MATROSKA_ID_TRACKTIMECODESCALE:{ gdouble num; if ((ret = gst_ebml_read_float (ebml, &id, &num)) != GST_FLOW_OK) break; if (num <= 0.0) { GST_WARNING_OBJECT (demux, "Invalid TrackTimeCodeScale %lf", num); break; } GST_DEBUG_OBJECT (demux, "TrackTimeCodeScale: %lf", num); context->timecodescale = num; break; } default: GST_WARNING ("Unknown TrackEntry subelement 0x%x - ignoring", id); /* pass-through */ /* we ignore these because they're nothing useful (i.e. crap) * or simply not implemented yet. */ case GST_MATROSKA_ID_TRACKMINCACHE: case GST_MATROSKA_ID_TRACKMAXCACHE: case GST_MATROSKA_ID_MAXBLOCKADDITIONID: case GST_MATROSKA_ID_TRACKATTACHMENTLINK: case GST_MATROSKA_ID_TRACKOVERLAY: case GST_MATROSKA_ID_TRACKTRANSLATE: case GST_MATROSKA_ID_TRACKOFFSET: case GST_MATROSKA_ID_CODECSETTINGS: case GST_MATROSKA_ID_CODECINFOURL: case GST_MATROSKA_ID_CODECDOWNLOADURL: case GST_MATROSKA_ID_CODECDECODEALL: ret = gst_ebml_read_skip (ebml); break; } } DEBUG_ELEMENT_STOP (demux, ebml, "TrackEntry", ret); /* Decode codec private data if necessary */ if (context->encodings && context->encodings->len > 0 && context->codec_priv && context->codec_priv_size > 0) { if (!gst_matroska_decode_data (context->encodings, &context->codec_priv, &context->codec_priv_size, GST_MATROSKA_TRACK_ENCODING_SCOPE_CODEC_DATA, TRUE)) { GST_WARNING_OBJECT (demux, "Decoding codec private data failed"); ret = GST_FLOW_ERROR; } } if (context->type == 0 || context->codec_id == NULL || (ret != GST_FLOW_OK && ret != GST_FLOW_EOS)) { if (ret == GST_FLOW_OK || ret == GST_FLOW_EOS) GST_WARNING_OBJECT (ebml, "Unknown stream/codec in track entry header"); gst_matroska_track_free (context); context = NULL; *dest_context = NULL; return ret; } /* check for a cached track taglist */ cached_taglist = (GstTagList *) g_hash_table_lookup (demux->common.cached_track_taglists, GUINT_TO_POINTER (context->uid)); if (cached_taglist) gst_tag_list_insert (context->tags, cached_taglist, GST_TAG_MERGE_APPEND); /* compute caps */ switch (context->type) { case GST_MATROSKA_TRACK_TYPE_VIDEO:{ GstMatroskaTrackVideoContext *videocontext = (GstMatroskaTrackVideoContext *) context; caps = gst_matroska_demux_video_caps (videocontext, context->codec_id, context->codec_priv, context->codec_priv_size, &codec, &riff_fourcc); if (codec) { gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE, GST_TAG_VIDEO_CODEC, codec, NULL); context->tags_changed = TRUE; g_free (codec); } break; } case GST_MATROSKA_TRACK_TYPE_AUDIO:{ GstClockTime lead_in_ts = 0; GstMatroskaTrackAudioContext *audiocontext = (GstMatroskaTrackAudioContext *) context; caps = gst_matroska_demux_audio_caps (audiocontext, context->codec_id, context->codec_priv, context->codec_priv_size, &codec, &riff_audio_fmt, &lead_in_ts); if (lead_in_ts > demux->audio_lead_in_ts) { demux->audio_lead_in_ts = lead_in_ts; GST_DEBUG_OBJECT (demux, "Increased audio lead-in to %" GST_TIME_FORMAT, GST_TIME_ARGS (lead_in_ts)); } if (codec) { gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE, GST_TAG_AUDIO_CODEC, codec, NULL); context->tags_changed = TRUE; g_free (codec); } break; } case GST_MATROSKA_TRACK_TYPE_SUBTITLE:{ GstMatroskaTrackSubtitleContext *subtitlecontext = (GstMatroskaTrackSubtitleContext *) context; caps = gst_matroska_demux_subtitle_caps (subtitlecontext, context->codec_id, context->codec_priv, context->codec_priv_size); break; } case GST_MATROSKA_TRACK_TYPE_COMPLEX: case GST_MATROSKA_TRACK_TYPE_LOGO: case GST_MATROSKA_TRACK_TYPE_BUTTONS: case GST_MATROSKA_TRACK_TYPE_CONTROL: default: /* we should already have quit by now */ g_assert_not_reached (); } if ((context->language == NULL || *context->language == '\0') && (context->type == GST_MATROSKA_TRACK_TYPE_AUDIO || context->type == GST_MATROSKA_TRACK_TYPE_SUBTITLE)) { GST_LOG ("stream %d: language=eng (assuming default)", context->index); context->language = g_strdup ("eng"); } if (context->language) { const gchar *lang; /* Matroska contains ISO 639-2B codes, we want ISO 639-1 */ lang = gst_tag_get_language_code (context->language); gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE, GST_TAG_LANGUAGE_CODE, (lang) ? lang : context->language, NULL); if (context->name) { gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE, GST_TAG_TITLE, context->name, NULL); } context->tags_changed = TRUE; } if (caps == NULL) { GST_WARNING_OBJECT (demux, "could not determine caps for stream with " "codec_id='%s'", context->codec_id); switch (context->type) { case GST_MATROSKA_TRACK_TYPE_VIDEO: caps = gst_caps_new_empty_simple ("video/x-unknown"); break; case GST_MATROSKA_TRACK_TYPE_AUDIO: caps = gst_caps_new_empty_simple ("audio/x-unknown"); break; case GST_MATROSKA_TRACK_TYPE_SUBTITLE: caps = gst_caps_new_empty_simple ("application/x-subtitle-unknown"); break; case GST_MATROSKA_TRACK_TYPE_COMPLEX: default: caps = gst_caps_new_empty_simple ("application/x-matroska-unknown"); break; } gst_caps_set_simple (caps, "codec-id", G_TYPE_STRING, context->codec_id, NULL); /* add any unrecognised riff fourcc / audio format, but after codec-id */ if (context->type == GST_MATROSKA_TRACK_TYPE_AUDIO && riff_audio_fmt != 0) gst_caps_set_simple (caps, "format", G_TYPE_INT, riff_audio_fmt, NULL); else if (context->type == GST_MATROSKA_TRACK_TYPE_VIDEO && riff_fourcc != 0) { gchar *fstr = g_strdup_printf ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (riff_fourcc)); gst_caps_set_simple (caps, "fourcc", G_TYPE_STRING, fstr, NULL); g_free (fstr); } } else if (context->stream_headers != NULL) { gst_matroska_demux_add_stream_headers_to_caps (demux, context->stream_headers, caps); } if (context->encodings) { GstMatroskaTrackEncoding *enc; guint i; for (i = 0; i < context->encodings->len; i++) { enc = &g_array_index (context->encodings, GstMatroskaTrackEncoding, i); if (enc->type == GST_MATROSKA_ENCODING_ENCRYPTION /* encryption */ ) { GstStructure *s = gst_caps_get_structure (caps, 0); if (!gst_structure_has_name (s, "application/x-webm-enc")) { gst_structure_set (s, "original-media-type", G_TYPE_STRING, gst_structure_get_name (s), NULL); gst_structure_set (s, "encryption-algorithm", G_TYPE_STRING, gst_matroska_track_encryption_algorithm_name (enc->enc_algo), NULL); gst_structure_set (s, "encoding-scope", G_TYPE_STRING, gst_matroska_track_encoding_scope_name (enc->scope), NULL); gst_structure_set (s, "cipher-mode", G_TYPE_STRING, gst_matroska_track_encryption_cipher_mode_name (enc->enc_cipher_mode), NULL); gst_structure_set_name (s, "application/x-webm-enc"); } } } } context->caps = caps; /* tadaah! */ *dest_context = context; return ret; }
1
385,092
htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options) { xmlParserInputBufferPtr input; xmlParserInputPtr stream; if (ctxt == NULL) return (NULL); if (buffer == NULL) return (NULL); xmlInitParser(); htmlCtxtReset(ctxt); input = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE); if (input == NULL) { return(NULL); } stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE); if (stream == NULL) { xmlFreeParserInputBuffer(input); return(NULL); } inputPush(ctxt, stream); return (htmlDoRead(ctxt, URL, encoding, options, 1)); }
0
194,448
void V4L2JpegEncodeAccelerator::EncodedInstanceDmaBuf::DestroyTask() { DCHECK(parent_->encoder_task_runner_->BelongsToCurrentThread()); while (!input_job_queue_.empty()) input_job_queue_.pop(); while (!running_job_queue_.empty()) running_job_queue_.pop(); DestroyInputBuffers(); DestroyOutputBuffers(); }
0
56,193
static void print_udev_format(const char *name, const char *value) { char enc[265], safe[256]; size_t namelen = strlen(name); *safe = *enc = '\0'; if (!strcmp(name, "TYPE") || !strcmp(name, "VERSION")) { blkid_encode_string(value, enc, sizeof(enc)); printf("ID_FS_%s=%s\n", name, enc); } else if (!strcmp(name, "UUID") || !strcmp(name, "LABEL") || !strcmp(name, "UUID_SUB")) { blkid_safe_string(value, safe, sizeof(safe)); printf("ID_FS_%s=%s\n", name, safe); blkid_encode_string(value, enc, sizeof(enc)); printf("ID_FS_%s_ENC=%s\n", name, enc); } else if (!strcmp(name, "PTUUID")) { printf("ID_PART_TABLE_UUID=%s\n", value); } else if (!strcmp(name, "PTTYPE")) { printf("ID_PART_TABLE_TYPE=%s\n", value); } else if (!strcmp(name, "PART_ENTRY_NAME") || !strcmp(name, "PART_ENTRY_TYPE")) { blkid_encode_string(value, enc, sizeof(enc)); printf("ID_%s=%s\n", name, enc); } else if (!strncmp(name, "PART_ENTRY_", 11)) printf("ID_%s=%s\n", name, value); else if (namelen >= 15 && ( !strcmp(name + (namelen - 12), "_SECTOR_SIZE") || !strcmp(name + (namelen - 8), "_IO_SIZE") || !strcmp(name, "ALIGNMENT_OFFSET"))) printf("ID_IOLIMIT_%s=%s\n", name, value); else printf("ID_FS_%s=%s\n", name, value); }
0
454,327
TEST(GetComputedPathsTest, ExpressionFieldPathDoesNotCountAsRenameWhenUsingRemoveBuiltin) { intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest()); auto expr = ExpressionFieldPath::parse(expCtx, "$$REMOVE", expCtx->variablesParseState); auto computedPaths = expr->getComputedPaths("a", Variables::kRootId); ASSERT_EQ(computedPaths.paths.size(), 1u); ASSERT_EQ(computedPaths.paths.count("a"), 1u); ASSERT(computedPaths.renames.empty()); }
0
218,892
ScriptPromise BluetoothRemoteGATTCharacteristic::getDescriptors( ScriptState* scriptState, const StringOrUnsignedLong& descriptorUUID, ExceptionState& exceptionState) { String descriptor = BluetoothUUID::getDescriptor(descriptorUUID, exceptionState); if (exceptionState.hadException()) return exceptionState.reject(scriptState); return getDescriptorsImpl( scriptState, mojom::blink::WebBluetoothGATTQueryQuantity::MULTIPLE, descriptor); }
0
375,070
_equalFieldStore(const FieldStore *a, const FieldStore *b) { COMPARE_NODE_FIELD(arg); COMPARE_NODE_FIELD(newvals); COMPARE_NODE_FIELD(fieldnums); COMPARE_SCALAR_FIELD(resulttype); return true; }
0
291,097
ptaaInitFull(PTAA *ptaa, PTA *pta) { l_int32 n, i; PTA *ptat; PROCNAME("ptaaInitFull"); if (!ptaa) return ERROR_INT("ptaa not defined", procName, 1); if (!pta) return ERROR_INT("pta not defined", procName, 1); n = ptaa->nalloc; ptaa->n = n; for (i = 0; i < n; i++) { ptat = ptaCopy(pta); ptaaReplacePta(ptaa, i, ptat); } return 0; }
0
107,119
static inline bool nested_vmx_allowed(struct kvm_vcpu *vcpu) { return nested && guest_cpuid_has(vcpu, X86_FEATURE_VMX); }
0
114,663
static void sas_ata_set_dmamode(struct ata_port *ap, struct ata_device *ata_dev) { struct domain_device *dev = ap->private_data; struct sas_internal *i = dev_to_sas_internal(dev); if (i->dft->lldd_ata_set_dmamode) i->dft->lldd_ata_set_dmamode(dev); }
0
226,618
void CalculatePageLayoutFromPrintParams( const PrintMsg_Print_Params& params, PageSizeMargins* page_layout_in_points) { int dpi = GetDPI(&params); int content_width = params.content_size.width(); int content_height = params.content_size.height(); int margin_bottom = params.page_size.height() - content_height - params.margin_top; int margin_right = params.page_size.width() - content_width - params.margin_left; page_layout_in_points->content_width = ConvertUnit(content_width, dpi, kPointsPerInch); page_layout_in_points->content_height = ConvertUnit(content_height, dpi, kPointsPerInch); page_layout_in_points->margin_top = ConvertUnit(params.margin_top, dpi, kPointsPerInch); page_layout_in_points->margin_right = ConvertUnit(margin_right, dpi, kPointsPerInch); page_layout_in_points->margin_bottom = ConvertUnit(margin_bottom, dpi, kPointsPerInch); page_layout_in_points->margin_left = ConvertUnit(params.margin_left, dpi, kPointsPerInch); }
0
160,597
IRC_PROTOCOL_CALLBACK(303) { IRC_PROTOCOL_MIN_ARGS(4); weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL), date, irc_protocol_tags (command, "irc_numeric", NULL, NULL), _("%sUsers online: %s%s"), weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); return WEECHAT_RC_OK; }
0
253,370
std::wstring GetUsageStatsKeyPath(bool medium) { EXPECT_TRUE(!medium || system_level_); std::wstring result(L"Software\\"); if (kUseGoogleUpdateIntegration) { result.append(L"Google\\Update\\ClientState"); if (medium) result.append(L"Medium"); result.push_back(L'\\'); result.append(mode_->app_guid); } else { result.append(kProductPathName); } return result; }
0
392,583
HWB_to_RGB (HWBType HWB, RGBType * RGB) { /* * H is given on [0, 6] or UNDEFINED. W and B are given on [0, 1]. * RGB are each returned on [0, 1]. */ float h = HWB.H, w = HWB.W, b = HWB.B, v, n, f; int i; v = 1 - b; if (h == HWB_UNDEFINED) RETURN_RGB (v, v, v); i = floor (h); f = h - i; if (i & 1) f = 1 - f; /* if i is odd */ n = w + f * (v - w); /* linear interpolation between w and v */ switch (i) { case 6: case 0: RETURN_RGB (v, n, w); case 1: RETURN_RGB (n, v, w); case 2: RETURN_RGB (w, v, n); case 3: RETURN_RGB (w, n, v); case 4: RETURN_RGB (n, w, v); case 5: RETURN_RGB (v, w, n); } return RGB; }
0
302,565
R_API const char *r_anal_function_get_var_reg_at(RAnalFunction *fcn, st64 delta, ut64 addr) { st64 offset = addr - fcn->addr; RPVector *inst_accesses = ht_up_find (fcn->inst_vars, offset, NULL); if (!inst_accesses) { return NULL; } RAnalVar *var = NULL; void **it; r_pvector_foreach (inst_accesses, it) { RAnalVar *v = *it; if (v->delta == delta) { var = v; break; } } if (!var) { return NULL; } size_t index; r_vector_lower_bound (&var->accesses, offset, index, ACCESS_CMP); RAnalVarAccess *acc = NULL; if (index < var->accesses.len) { acc = r_vector_index_ptr (&var->accesses, index); } if (!acc || acc->offset != offset) { return NULL; } return acc->reg; }
0
54,041
void Compute(OpKernelContext* ctx) override { const Tensor& indices_tensor = ctx->input(0); OP_REQUIRES(ctx, TensorShapeUtils::IsVector(indices_tensor.shape()) || TensorShapeUtils::IsScalar(indices_tensor.shape()), errors::InvalidArgument( "The indices can only be scalar or vector, got \"", indices_tensor.shape().DebugString(), "\"")); const Tensor& dims_tensor = ctx->input(1); OP_REQUIRES( ctx, TensorShapeUtils::IsVector(dims_tensor.shape()), errors::InvalidArgument("The indices can only be 1-D, got \"", dims_tensor.shape().DebugString(), "\"")); auto dims = dims_tensor.vec<Tidx>(); // Make sure dims does not contain a zero for (int i = 0; i < dims.size(); i++) { OP_REQUIRES( ctx, dims(i) != 0, errors::InvalidArgument("Input dims cannot contain a dim of zero, " "but dims contains zero at index ", i)); } // Chek to make sure indices is not out of boundary Eigen::Tensor<Tidx, 0, Eigen::RowMajor> dims_prod_eigen = dims.prod(); Tidx dims_prod = dims_prod_eigen(); const Tidx* indices = indices_tensor.flat<Tidx>().data(); int64 size = indices_tensor.NumElements(); bool check = std::all_of(indices, indices + size, [&](Tidx index) { return index < dims_prod; }); OP_REQUIRES(ctx, check, errors::InvalidArgument("index is out of bound as with dims")); Eigen::array<bool, 1> reverse({true}); Tensor strides_tensor; OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<Tidx>::value, TensorShape({dims_tensor.NumElements()}), &strides_tensor)); auto strides = strides_tensor.vec<Tidx>(); strides = dims.reverse(reverse) .scan(0, Eigen::internal::ProdReducer<Tidx>(), false) .reverse(reverse); Tensor strides_shifted_tensor; OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<Tidx>::value, TensorShape({dims_tensor.NumElements()}), &strides_shifted_tensor)); auto strides_shifted = strides_shifted_tensor.vec<Tidx>(); strides_shifted = dims.reverse(reverse) .scan(0, Eigen::internal::ProdReducer<Tidx>(), true) .reverse(reverse); Tensor* output_tensor = nullptr; if (TensorShapeUtils::IsScalar(indices_tensor.shape())) { OP_REQUIRES_OK( ctx, ctx->allocate_output(0, TensorShape({dims_tensor.NumElements()}), &output_tensor)); auto output = output_tensor->vec<Tidx>(); output = output.constant(indices_tensor.scalar<Tidx>()()); output = output.binaryExpr(strides, mod_op<Tidx>()) / strides_shifted; } else { OP_REQUIRES_OK( ctx, ctx->allocate_output(0, TensorShape({dims_tensor.NumElements(), indices_tensor.NumElements()}), &output_tensor)); auto output = output_tensor->matrix<Tidx>(); Eigen::array<Eigen::Index, 2> reshape{ {static_cast<Eigen::Index>(dims_tensor.NumElements()), 1}}; Eigen::array<Eigen::Index, 2> bcast( {1, static_cast<Eigen::Index>(indices_tensor.NumElements())}); Eigen::array<Eigen::Index, 2> indices_reshape{ {1, static_cast<Eigen::Index>(indices_tensor.NumElements())}}; Eigen::array<Eigen::Index, 2> indices_bcast( {static_cast<Eigen::Index>(dims_tensor.NumElements()), 1}); output = indices_tensor.vec<Tidx>() .reshape(indices_reshape) .broadcast(indices_bcast); output = output.binaryExpr(strides.reshape(reshape).broadcast(bcast), mod_op<Tidx>()) / strides_shifted.reshape(reshape).broadcast(bcast); } }
0
460,392
struct hid_field *hidinput_get_led_field(struct hid_device *hid) { struct hid_report *report; struct hid_field *field; int i, j; list_for_each_entry(report, &hid->report_enum[HID_OUTPUT_REPORT].report_list, list) { for (i = 0; i < report->maxfield; i++) { field = report->field[i]; for (j = 0; j < field->maxusage; j++) if (field->usage[j].type == EV_LED) return field; } } return NULL; }
0
410,880
static THEME_SEARCH_REC *theme_search(GSList *list, const char *module) { THEME_SEARCH_REC *rec; while (list != NULL) { rec = list->data; if (g_strcasecmp(rec->short_name, module) == 0) return rec; list = list->next; } return NULL; }
0
316,220
void ChromotingInstance::SendClipboardItem(const std::string& mime_type, const std::string& item) { if (!IsConnected()) { return; } protocol::ClipboardEvent event; event.set_mime_type(mime_type); event.set_data(item); host_connection_->clipboard_stub()->InjectClipboardEvent(event); }
0
487,541
ElectronBrowserClient::GetGeneratedCodeCacheSettings( content::BrowserContext* context) { // TODO(deepak1556): Use platform cache directory. base::FilePath cache_path = context->GetPath(); // If we pass 0 for size, disk_cache will pick a default size using the // heuristics based on available disk size. These are implemented in // disk_cache::PreferredCacheSize in net/disk_cache/cache_util.cc. return content::GeneratedCodeCacheSettings(true, 0, cache_path); }
0
223,167
void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) { if (!DeleteObject(texture)) return; int max_bound_texture_index = -1; for (wtf_size_t i = 0; i < one_plus_max_non_default_texture_unit_; ++i) { if (texture == texture_units_[i].texture2d_binding_) { texture_units_[i].texture2d_binding_ = nullptr; max_bound_texture_index = i; } if (texture == texture_units_[i].texture_cube_map_binding_) { texture_units_[i].texture_cube_map_binding_ = nullptr; max_bound_texture_index = i; } if (IsWebGL2OrHigher()) { if (texture == texture_units_[i].texture3d_binding_) { texture_units_[i].texture3d_binding_ = nullptr; max_bound_texture_index = i; } if (texture == texture_units_[i].texture2d_array_binding_) { texture_units_[i].texture2d_array_binding_ = nullptr; max_bound_texture_index = i; } } } if (framebuffer_binding_) framebuffer_binding_->RemoveAttachmentFromBoundFramebuffer(GL_FRAMEBUFFER, texture); if (GetFramebufferBinding(GL_READ_FRAMEBUFFER)) GetFramebufferBinding(GL_READ_FRAMEBUFFER) ->RemoveAttachmentFromBoundFramebuffer(GL_READ_FRAMEBUFFER, texture); if (one_plus_max_non_default_texture_unit_ == static_cast<wtf_size_t>(max_bound_texture_index + 1)) { FindNewMaxNonDefaultTextureUnit(); } }
0
283,631
void V8TestObject::ActivityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttributeAttributeSetterCallbackForMainWorld( const v8::FunctionCallbackInfo<v8::Value>& info) { RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_activityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttribute_Setter"); v8::Local<v8::Value> v8_value = info[0]; test_object_v8_internal::ActivityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttributeAttributeSetterForMainWorld(v8_value, info); }
0
236,101
WORD32 ih264d_video_decode(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op) { /* ! */ dec_struct_t * ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle); WORD32 i4_err_status = 0; UWORD8 *pu1_buf = NULL; WORD32 buflen; UWORD32 u4_max_ofst, u4_length_of_start_code = 0; UWORD32 bytes_consumed = 0; UWORD32 cur_slice_is_nonref = 0; UWORD32 u4_next_is_aud; UWORD32 u4_first_start_code_found = 0; WORD32 ret = 0,api_ret_value = IV_SUCCESS; WORD32 header_data_left = 0,frame_data_left = 0; UWORD8 *pu1_bitstrm_buf; ivd_video_decode_ip_t *ps_dec_ip; ivd_video_decode_op_t *ps_dec_op; ithread_set_name((void*)"Parse_thread"); ps_dec_ip = (ivd_video_decode_ip_t *)pv_api_ip; ps_dec_op = (ivd_video_decode_op_t *)pv_api_op; ps_dec->pv_dec_out = ps_dec_op; if(ps_dec->init_done != 1) { return IV_FAIL; } /*Data memory barries instruction,so that bitstream write by the application is complete*/ DATA_SYNC(); if(0 == ps_dec->u1_flushfrm) { if(ps_dec_ip->pv_stream_buffer == NULL) { ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; ps_dec_op->u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL; return IV_FAIL; } if(ps_dec_ip->u4_num_Bytes <= 0) { ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; ps_dec_op->u4_error_code |= IVD_DEC_NUMBYTES_INV; return IV_FAIL; } } ps_dec->u1_pic_decode_done = 0; ps_dec_op->u4_num_bytes_consumed = 0; ps_dec->ps_out_buffer = NULL; if(ps_dec_ip->u4_size >= offsetof(ivd_video_decode_ip_t, s_out_buffer)) ps_dec->ps_out_buffer = &ps_dec_ip->s_out_buffer; ps_dec->u4_fmt_conv_cur_row = 0; ps_dec->u4_output_present = 0; ps_dec->s_disp_op.u4_error_code = 1; ps_dec->u4_fmt_conv_num_rows = FMT_CONV_NUM_ROWS; if(0 == ps_dec->u4_share_disp_buf && ps_dec->i4_decode_header == 0) { UWORD32 i; if(ps_dec->ps_out_buffer->u4_num_bufs == 0) { ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUFS; return IV_FAIL; } for(i = 0; i < ps_dec->ps_out_buffer->u4_num_bufs; i++) { if(ps_dec->ps_out_buffer->pu1_bufs[i] == NULL) { ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; ps_dec_op->u4_error_code |= IVD_DISP_FRM_OP_BUF_NULL; return IV_FAIL; } if(ps_dec->ps_out_buffer->u4_min_out_buf_size[i] == 0) { ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUF_SIZE; return IV_FAIL; } } } if(ps_dec->u4_total_frames_decoded >= NUM_FRAMES_LIMIT) { ps_dec_op->u4_error_code = ERROR_FRAME_LIMIT_OVER; return IV_FAIL; } /* ! */ ps_dec->u4_ts = ps_dec_ip->u4_ts; ps_dec_op->u4_error_code = 0; ps_dec_op->e_pic_type = -1; ps_dec_op->u4_output_present = 0; ps_dec_op->u4_frame_decoded_flag = 0; ps_dec->i4_frametype = -1; ps_dec->i4_content_type = -1; /* * For field pictures, set the bottom and top picture decoded u4_flag correctly. */ { if((TOP_FIELD_ONLY | BOT_FIELD_ONLY) == ps_dec->u1_top_bottom_decoded) { ps_dec->u1_top_bottom_decoded = 0; } } ps_dec->u4_slice_start_code_found = 0; /* In case the deocder is not in flush mode(in shared mode), then decoder has to pick up a buffer to write current frame. Check if a frame is available in such cases */ if(ps_dec->u1_init_dec_flag == 1 && ps_dec->u4_share_disp_buf == 1 && ps_dec->u1_flushfrm == 0) { UWORD32 i; WORD32 disp_avail = 0, free_id; /* Check if at least one buffer is available with the codec */ /* If not then return to application with error */ for(i = 0; i < ps_dec->u1_pic_bufs; i++) { if(0 == ps_dec->u4_disp_buf_mapping[i] || 1 == ps_dec->u4_disp_buf_to_be_freed[i]) { disp_avail = 1; break; } } if(0 == disp_avail) { /* If something is queued for display wait for that buffer to be returned */ ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL; ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); return (IV_FAIL); } while(1) { pic_buffer_t *ps_pic_buf; ps_pic_buf = (pic_buffer_t *)ih264_buf_mgr_get_next_free( (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, &free_id); if(ps_pic_buf == NULL) { UWORD32 i, display_queued = 0; /* check if any buffer was given for display which is not returned yet */ for(i = 0; i < (MAX_DISP_BUFS_NEW); i++) { if(0 != ps_dec->u4_disp_buf_mapping[i]) { display_queued = 1; break; } } /* If some buffer is queued for display, then codec has to singal an error and wait for that buffer to be returned. If nothing is queued for display then codec has ownership of all display buffers and it can reuse any of the existing buffers and continue decoding */ if(1 == display_queued) { /* If something is queued for display wait for that buffer to be returned */ ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL; ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); return (IV_FAIL); } } else { /* If the buffer is with display, then mark it as in use and then look for a buffer again */ if(1 == ps_dec->u4_disp_buf_mapping[free_id]) { ih264_buf_mgr_set_status( (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, free_id, BUF_MGR_IO); } else { /** * Found a free buffer for present call. Release it now. * Will be again obtained later. */ ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, free_id, BUF_MGR_IO); break; } } } } if(ps_dec->u1_flushfrm && ps_dec->u1_init_dec_flag) { ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer, &(ps_dec->s_disp_op)); if(0 == ps_dec->s_disp_op.u4_error_code) { ps_dec->u4_fmt_conv_cur_row = 0; ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht; ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op), ps_dec->u4_fmt_conv_cur_row, ps_dec->u4_fmt_conv_num_rows); ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows; ps_dec->u4_output_present = 1; } ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op)); ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width; ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height; ps_dec_op->u4_new_seq = 0; ps_dec_op->u4_output_present = ps_dec->u4_output_present; ps_dec_op->u4_progressive_frame_flag = ps_dec->s_disp_op.u4_progressive_frame_flag; ps_dec_op->e_output_format = ps_dec->s_disp_op.e_output_format; ps_dec_op->s_disp_frm_buf = ps_dec->s_disp_op.s_disp_frm_buf; ps_dec_op->e4_fld_type = ps_dec->s_disp_op.e4_fld_type; ps_dec_op->u4_ts = ps_dec->s_disp_op.u4_ts; ps_dec_op->u4_disp_buf_id = ps_dec->s_disp_op.u4_disp_buf_id; /*In the case of flush ,since no frame is decoded set pic type as invalid*/ ps_dec_op->u4_is_ref_flag = -1; ps_dec_op->e_pic_type = IV_NA_FRAME; ps_dec_op->u4_frame_decoded_flag = 0; if(0 == ps_dec->s_disp_op.u4_error_code) { return (IV_SUCCESS); } else return (IV_FAIL); } if(ps_dec->u1_res_changed == 1) { /*if resolution has changed and all buffers have been flushed, reset decoder*/ ih264d_init_decoder(ps_dec); } ps_dec->u4_prev_nal_skipped = 0; ps_dec->u2_cur_mb_addr = 0; ps_dec->u2_total_mbs_coded = 0; ps_dec->u2_cur_slice_num = 0; ps_dec->cur_dec_mb_num = 0; ps_dec->cur_recon_mb_num = 0; ps_dec->u4_first_slice_in_pic = 2; ps_dec->u1_slice_header_done = 0; ps_dec->u1_dangling_field = 0; ps_dec->u4_dec_thread_created = 0; ps_dec->u4_bs_deblk_thread_created = 0; ps_dec->u4_cur_bs_mb_num = 0; DEBUG_THREADS_PRINTF(" Starting process call\n"); ps_dec->u4_pic_buf_got = 0; do { WORD32 buf_size; pu1_buf = (UWORD8*)ps_dec_ip->pv_stream_buffer + ps_dec_op->u4_num_bytes_consumed; u4_max_ofst = ps_dec_ip->u4_num_Bytes - ps_dec_op->u4_num_bytes_consumed; /* If dynamic bitstream buffer is not allocated and * header decode is done, then allocate dynamic bitstream buffer */ if((NULL == ps_dec->pu1_bits_buf_dynamic) && (ps_dec->i4_header_decoded & 1)) { WORD32 size; void *pv_buf; void *pv_mem_ctxt = ps_dec->pv_mem_ctxt; size = MAX(256000, ps_dec->u2_pic_wd * ps_dec->u2_pic_ht * 3 / 2); pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size); RETURN_IF((NULL == pv_buf), IV_FAIL); ps_dec->pu1_bits_buf_dynamic = pv_buf; ps_dec->u4_dynamic_bits_buf_size = size; } if(ps_dec->pu1_bits_buf_dynamic) { pu1_bitstrm_buf = ps_dec->pu1_bits_buf_dynamic; buf_size = ps_dec->u4_dynamic_bits_buf_size; } else { pu1_bitstrm_buf = ps_dec->pu1_bits_buf_static; buf_size = ps_dec->u4_static_bits_buf_size; } u4_next_is_aud = 0; buflen = ih264d_find_start_code(pu1_buf, 0, u4_max_ofst, &u4_length_of_start_code, &u4_next_is_aud); if(buflen == -1) buflen = 0; /* Ignore bytes beyond the allocated size of intermediate buffer */ buflen = MIN(buflen, buf_size); bytes_consumed = buflen + u4_length_of_start_code; ps_dec_op->u4_num_bytes_consumed += bytes_consumed; { UWORD8 u1_firstbyte, u1_nal_ref_idc; if(ps_dec->i4_app_skip_mode == IVD_SKIP_B) { u1_firstbyte = *(pu1_buf + u4_length_of_start_code); u1_nal_ref_idc = (UWORD8)(NAL_REF_IDC(u1_firstbyte)); if(u1_nal_ref_idc == 0) { /*skip non reference frames*/ cur_slice_is_nonref = 1; continue; } else { if(1 == cur_slice_is_nonref) { /*We have encountered a referenced frame,return to app*/ ps_dec_op->u4_num_bytes_consumed -= bytes_consumed; ps_dec_op->e_pic_type = IV_B_FRAME; ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED; ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); ps_dec_op->u4_frame_decoded_flag = 0; ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t); /*signal the decode thread*/ ih264d_signal_decode_thread(ps_dec); /* close deblock thread if it is not closed yet*/ if(ps_dec->u4_num_cores == 3) { ih264d_signal_bs_deblk_thread(ps_dec); } return (IV_FAIL); } } } } if(buflen) { memcpy(pu1_bitstrm_buf, pu1_buf + u4_length_of_start_code, buflen); /* Decoder may read extra 8 bytes near end of the frame */ if((buflen + 8) < buf_size) { memset(pu1_bitstrm_buf + buflen, 0, 8); } u4_first_start_code_found = 1; } else { /*start code not found*/ if(u4_first_start_code_found == 0) { /*no start codes found in current process call*/ ps_dec->i4_error_code = ERROR_START_CODE_NOT_FOUND; ps_dec_op->u4_error_code |= 1 << IVD_INSUFFICIENTDATA; if(ps_dec->u4_pic_buf_got == 0) { ih264d_fill_output_struct_from_context(ps_dec, ps_dec_op); ps_dec_op->u4_error_code = ps_dec->i4_error_code; ps_dec_op->u4_frame_decoded_flag = 0; return (IV_FAIL); } else { ps_dec->u1_pic_decode_done = 1; continue; } } else { /* a start code has already been found earlier in the same process call*/ frame_data_left = 0; continue; } } ps_dec->u4_return_to_app = 0; ret = ih264d_parse_nal_unit(dec_hdl, ps_dec_op, pu1_bitstrm_buf, buflen); if(ret != OK) { UWORD32 error = ih264d_map_error(ret); ps_dec_op->u4_error_code = error | ret; api_ret_value = IV_FAIL; if((ret == IVD_RES_CHANGED) || (ret == IVD_MEM_ALLOC_FAILED) || (ret == ERROR_UNAVAIL_PICBUF_T) || (ret == ERROR_UNAVAIL_MVBUF_T)) { break; } if((ret == ERROR_INCOMPLETE_FRAME) || (ret == ERROR_DANGLING_FIELD_IN_PIC)) { ps_dec_op->u4_num_bytes_consumed -= bytes_consumed; api_ret_value = IV_FAIL; break; } if(ret == ERROR_IN_LAST_SLICE_OF_PIC) { api_ret_value = IV_FAIL; break; } } if(ps_dec->u4_return_to_app) { /*We have encountered a referenced frame,return to app*/ ps_dec_op->u4_num_bytes_consumed -= bytes_consumed; ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED; ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); ps_dec_op->u4_frame_decoded_flag = 0; ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t); /*signal the decode thread*/ ih264d_signal_decode_thread(ps_dec); /* close deblock thread if it is not closed yet*/ if(ps_dec->u4_num_cores == 3) { ih264d_signal_bs_deblk_thread(ps_dec); } return (IV_FAIL); } header_data_left = ((ps_dec->i4_decode_header == 1) && (ps_dec->i4_header_decoded != 3) && (ps_dec_op->u4_num_bytes_consumed < ps_dec_ip->u4_num_Bytes)); frame_data_left = (((ps_dec->i4_decode_header == 0) && ((ps_dec->u1_pic_decode_done == 0) || (u4_next_is_aud == 1))) && (ps_dec_op->u4_num_bytes_consumed < ps_dec_ip->u4_num_Bytes)); } while(( header_data_left == 1)||(frame_data_left == 1)); if((ps_dec->u4_slice_start_code_found == 1) && (ret != IVD_MEM_ALLOC_FAILED) && ps_dec->u2_total_mbs_coded < ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) { WORD32 num_mb_skipped; WORD32 prev_slice_err; pocstruct_t temp_poc; WORD32 ret1; num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) - ps_dec->u2_total_mbs_coded; if(ps_dec->u4_first_slice_in_pic && (ps_dec->u4_pic_buf_got == 0)) prev_slice_err = 1; else prev_slice_err = 2; ret1 = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, ps_dec->u1_nal_unit_type == IDR_SLICE_NAL, ps_dec->ps_cur_slice->u2_frame_num, &temp_poc, prev_slice_err); if((ret1 == ERROR_UNAVAIL_PICBUF_T) || (ret1 == ERROR_UNAVAIL_MVBUF_T)) { return IV_FAIL; } } if((ret == IVD_RES_CHANGED) || (ret == IVD_MEM_ALLOC_FAILED) || (ret == ERROR_UNAVAIL_PICBUF_T) || (ret == ERROR_UNAVAIL_MVBUF_T)) { /* signal the decode thread */ ih264d_signal_decode_thread(ps_dec); /* close deblock thread if it is not closed yet */ if(ps_dec->u4_num_cores == 3) { ih264d_signal_bs_deblk_thread(ps_dec); } /* dont consume bitstream for change in resolution case */ if(ret == IVD_RES_CHANGED) { ps_dec_op->u4_num_bytes_consumed -= bytes_consumed; } return IV_FAIL; } if(ps_dec->u1_separate_parse) { /* If Format conversion is not complete, complete it here */ if(ps_dec->u4_num_cores == 2) { /*do deblocking of all mbs*/ if((ps_dec->u4_nmb_deblk == 0) &&(ps_dec->u4_start_recon_deblk == 1) && (ps_dec->ps_cur_sps->u1_mb_aff_flag == 0)) { UWORD32 u4_num_mbs,u4_max_addr; tfr_ctxt_t s_tfr_ctxt; tfr_ctxt_t *ps_tfr_cxt = &s_tfr_ctxt; pad_mgr_t *ps_pad_mgr = &ps_dec->s_pad_mgr; /*BS is done for all mbs while parsing*/ u4_max_addr = (ps_dec->u2_frm_wd_in_mbs * ps_dec->u2_frm_ht_in_mbs) - 1; ps_dec->u4_cur_bs_mb_num = u4_max_addr + 1; ih264d_init_deblk_tfr_ctxt(ps_dec, ps_pad_mgr, ps_tfr_cxt, ps_dec->u2_frm_wd_in_mbs, 0); u4_num_mbs = u4_max_addr - ps_dec->u4_cur_deblk_mb_num + 1; DEBUG_PERF_PRINTF("mbs left for deblocking= %d \n",u4_num_mbs); if(u4_num_mbs != 0) ih264d_check_mb_map_deblk(ps_dec, u4_num_mbs, ps_tfr_cxt,1); ps_dec->u4_start_recon_deblk = 0; } } /*signal the decode thread*/ ih264d_signal_decode_thread(ps_dec); /* close deblock thread if it is not closed yet*/ if(ps_dec->u4_num_cores == 3) { ih264d_signal_bs_deblk_thread(ps_dec); } } DATA_SYNC(); if((ps_dec_op->u4_error_code & 0xff) != ERROR_DYNAMIC_RESOLUTION_NOT_SUPPORTED) { ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width; ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height; } if(ps_dec->i4_header_decoded != 3) { ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA); } if(ps_dec->i4_decode_header == 1 && ps_dec->i4_header_decoded != 3) { ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA); } if(ps_dec->u4_prev_nal_skipped) { /*We have encountered a referenced frame,return to app*/ ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED; ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); ps_dec_op->u4_frame_decoded_flag = 0; ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t); /* close deblock thread if it is not closed yet*/ if(ps_dec->u4_num_cores == 3) { ih264d_signal_bs_deblk_thread(ps_dec); } return (IV_FAIL); } if((ps_dec->u4_slice_start_code_found == 1) && (ERROR_DANGLING_FIELD_IN_PIC != i4_err_status)) { /* * For field pictures, set the bottom and top picture decoded u4_flag correctly. */ if(ps_dec->ps_cur_slice->u1_field_pic_flag) { if(1 == ps_dec->ps_cur_slice->u1_bottom_field_flag) { ps_dec->u1_top_bottom_decoded |= BOT_FIELD_ONLY; } else { ps_dec->u1_top_bottom_decoded |= TOP_FIELD_ONLY; } } /* if new frame in not found (if we are still getting slices from previous frame) * ih264d_deblock_display is not called. Such frames will not be added to reference /display */ if((ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) == 0) { /* Calling Function to deblock Picture and Display */ ret = ih264d_deblock_display(ps_dec); if(ret != 0) { return IV_FAIL; } } /*set to complete ,as we dont support partial frame decode*/ if(ps_dec->i4_header_decoded == 3) { ps_dec->u2_total_mbs_coded = ps_dec->ps_cur_sps->u2_max_mb_addr + 1; } /*Update the i4_frametype at the end of picture*/ if(ps_dec->ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL) { ps_dec->i4_frametype = IV_IDR_FRAME; } else if(ps_dec->i4_pic_type == B_SLICE) { ps_dec->i4_frametype = IV_B_FRAME; } else if(ps_dec->i4_pic_type == P_SLICE) { ps_dec->i4_frametype = IV_P_FRAME; } else if(ps_dec->i4_pic_type == I_SLICE) { ps_dec->i4_frametype = IV_I_FRAME; } else { H264_DEC_DEBUG_PRINT("Shouldn't come here\n"); } ps_dec->i4_content_type = ps_dec->ps_cur_slice->u1_field_pic_flag; ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded + 2; ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded - ps_dec->ps_cur_slice->u1_field_pic_flag; } /* close deblock thread if it is not closed yet*/ if(ps_dec->u4_num_cores == 3) { ih264d_signal_bs_deblk_thread(ps_dec); } { /* In case the decoder is configured to run in low delay mode, * then get display buffer and then format convert. * Note in this mode, format conversion does not run paralelly in a thread and adds to the codec cycles */ if((IVD_DECODE_FRAME_OUT == ps_dec->e_frm_out_mode) && ps_dec->u1_init_dec_flag) { ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer, &(ps_dec->s_disp_op)); if(0 == ps_dec->s_disp_op.u4_error_code) { ps_dec->u4_fmt_conv_cur_row = 0; ps_dec->u4_output_present = 1; } } ih264d_fill_output_struct_from_context(ps_dec, ps_dec_op); /* If Format conversion is not complete, complete it here */ if(ps_dec->u4_output_present && (ps_dec->u4_fmt_conv_cur_row < ps_dec->s_disp_frame_info.u4_y_ht)) { ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht - ps_dec->u4_fmt_conv_cur_row; ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op), ps_dec->u4_fmt_conv_cur_row, ps_dec->u4_fmt_conv_num_rows); ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows; } ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op)); } if(ps_dec->i4_decode_header == 1 && (ps_dec->i4_header_decoded & 1) == 1) { ps_dec_op->u4_progressive_frame_flag = 1; if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid))) { if((0 == ps_dec->ps_sps->u1_frame_mbs_only_flag) && (0 == ps_dec->ps_sps->u1_mb_aff_flag)) ps_dec_op->u4_progressive_frame_flag = 0; } } /*Data memory barrier instruction,so that yuv write by the library is complete*/ DATA_SYNC(); H264_DEC_DEBUG_PRINT("The num bytes consumed: %d\n", ps_dec_op->u4_num_bytes_consumed); return api_ret_value; }
0
160,254
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObject *obj) { MONO_ARCH_SAVE_REGS; if ((obj == NULL) || (! (obj->vtable->klass->valuetype))) return obj; else return mono_object_clone (obj); }
0
8,201
static int follow_dotdot_rcu(struct nameidata *nd) { struct inode *inode = nd->inode; if (!nd->root.mnt) set_root_rcu(nd); while (1) { if (path_equal(&nd->path, &nd->root)) break; if (nd->path.dentry != nd->path.mnt->mnt_root) { struct dentry *old = nd->path.dentry; struct dentry *parent = old->d_parent; unsigned seq; inode = parent->d_inode; seq = read_seqcount_begin(&parent->d_seq); if (unlikely(read_seqcount_retry(&old->d_seq, nd->seq))) return -ECHILD; nd->path.dentry = parent; nd->seq = seq; break; } else { struct mount *mnt = real_mount(nd->path.mnt); struct mount *mparent = mnt->mnt_parent; struct dentry *mountpoint = mnt->mnt_mountpoint; struct inode *inode2 = mountpoint->d_inode; unsigned seq = read_seqcount_begin(&mountpoint->d_seq); if (unlikely(read_seqretry(&mount_lock, nd->m_seq))) return -ECHILD; if (&mparent->mnt == nd->path.mnt) break; /* we know that mountpoint was pinned */ nd->path.dentry = mountpoint; nd->path.mnt = &mparent->mnt; inode = inode2; nd->seq = seq; } } while (unlikely(d_mountpoint(nd->path.dentry))) { struct mount *mounted; mounted = __lookup_mnt(nd->path.mnt, nd->path.dentry); if (unlikely(read_seqretry(&mount_lock, nd->m_seq))) return -ECHILD; if (!mounted) break; nd->path.mnt = &mounted->mnt; nd->path.dentry = mounted->mnt.mnt_root; inode = nd->path.dentry->d_inode; nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); } nd->inode = inode; return 0; }
1
258,818
glob_dir_to_array (dir, array, flags) char *dir, **array; int flags; { register unsigned int i, l; int add_slash; char **result, *new; struct stat sb; l = strlen (dir); if (l == 0) { if (flags & GX_MARKDIRS) for (i = 0; array[i]; i++) { if ((stat (array[i], &sb) == 0) && S_ISDIR (sb.st_mode)) { l = strlen (array[i]); new = (char *)realloc (array[i], l + 2); if (new == 0) return NULL; new[l] = '/'; new[l+1] = '\0'; array[i] = new; } } return (array); } add_slash = dir[l - 1] != '/'; i = 0; while (array[i] != NULL) ++i; result = (char **) malloc ((i + 1) * sizeof (char *)); if (result == NULL) return (NULL); for (i = 0; array[i] != NULL; i++) { /* 3 == 1 for NUL, 1 for slash at end of DIR, 1 for GX_MARKDIRS */ result[i] = (char *) malloc (l + strlen (array[i]) + 3); if (result[i] == NULL) { int ind; for (ind = 0; ind < i; ind++) free (result[ind]); free (result); return (NULL); } strcpy (result[i], dir); if (add_slash) result[i][l] = '/'; if (array[i][0]) { strcpy (result[i] + l + add_slash, array[i]); if (flags & GX_MARKDIRS) { if ((stat (result[i], &sb) == 0) && S_ISDIR (sb.st_mode)) { size_t rlen; rlen = strlen (result[i]); result[i][rlen] = '/'; result[i][rlen+1] = '\0'; } } } else result[i][l+add_slash] = '\0'; } result[i] = NULL; /* Free the input array. */ for (i = 0; array[i] != NULL; i++) free (array[i]); free ((char *) array); return (result); }
0
499,159
int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp) { unsigned char *inode_table = NULL, *dir_table = NULL; int j, token_count = 0, ret = 0, metablks_count; struct squashfs_dir_stream *dirs; char **token_list = NULL, *path = NULL; u32 *pos_list = NULL; dirs = calloc(1, sizeof(*dirs)); if (!dirs) return -EINVAL; /* these should be set to NULL to prevent dangling pointers */ dirs->dir_header = NULL; dirs->entry = NULL; dirs->table = NULL; dirs->inode_table = NULL; dirs->dir_table = NULL; ret = sqfs_read_inode_table(&inode_table); if (ret) { ret = -EINVAL; goto out; } metablks_count = sqfs_read_directory_table(&dir_table, &pos_list); if (metablks_count < 1) { ret = -EINVAL; goto out; } /* Tokenize filename */ token_count = sqfs_count_tokens(filename); if (token_count < 0) { ret = -EINVAL; goto out; } path = strdup(filename); if (!path) { ret = -EINVAL; goto out; } token_list = malloc(token_count * sizeof(char *)); if (!token_list) { ret = -EINVAL; goto out; } /* Fill tokens list */ ret = sqfs_tokenize(token_list, token_count, path); if (ret) goto out; /* * ldir's (extended directory) size is greater than dir, so it works as * a general solution for the malloc size, since 'i' is a union. */ dirs->inode_table = inode_table; dirs->dir_table = dir_table; ret = sqfs_search_dir(dirs, token_list, token_count, pos_list, metablks_count); if (ret) goto out; if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE) dirs->size = le16_to_cpu(dirs->i_dir.file_size); else dirs->size = le32_to_cpu(dirs->i_ldir.file_size); /* Setup directory header */ memcpy(dirs->dir_header, dirs->table, SQFS_DIR_HEADER_SIZE); dirs->entry_count = dirs->dir_header->count + 1; dirs->size -= SQFS_DIR_HEADER_SIZE; /* Setup entry */ dirs->entry = NULL; dirs->table += SQFS_DIR_HEADER_SIZE; *dirsp = (struct fs_dir_stream *)dirs; out: for (j = 0; j < token_count; j++) free(token_list[j]); free(token_list); free(pos_list); free(path); if (ret) { free(inode_table); free(dirs); } return ret; }
0
149,184
multi_client_connect_post_plugin(struct multi_context *m, struct multi_instance *mi, const struct plugin_return *pr, unsigned int option_permissions_mask, unsigned int *option_types_found) { struct plugin_return config; plugin_return_get_column(pr, &config, "config"); /* Did script generate a dynamic config file? */ if (plugin_return_defined(&config)) { int i; for (i = 0; i < config.n; ++i) { if (config.list[i] && config.list[i]->value) { options_string_import(&mi->context.options, config.list[i]->value, D_IMPORT_ERRORS|M_OPTERR, option_permissions_mask, option_types_found, mi->context.c2.es); } } /* * If the --client-connect script generates a config file * with an --ifconfig-push directive, it will override any * --ifconfig-push directive from the --client-config-dir * directory or any --ifconfig-pool dynamic address. */ multi_select_virtual_addr(m, mi); multi_set_virtual_addr_env(mi); } }
0
286,779
static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr, struct flowi *fl, struct sock *sk) { struct sctp_association *asoc = t->asoc; struct dst_entry *dst = NULL; struct flowi6 *fl6 = &fl->u.ip6; struct sctp_bind_addr *bp; struct sctp_sockaddr_entry *laddr; union sctp_addr *baddr = NULL; union sctp_addr *daddr = &t->ipaddr; union sctp_addr dst_saddr; __u8 matchlen = 0; __u8 bmatchlen; sctp_scope_t scope; memset(fl6, 0, sizeof(struct flowi6)); fl6->daddr = daddr->v6.sin6_addr; fl6->fl6_dport = daddr->v6.sin6_port; fl6->flowi6_proto = IPPROTO_SCTP; if (ipv6_addr_type(&daddr->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL) fl6->flowi6_oif = daddr->v6.sin6_scope_id; pr_debug("%s: dst=%pI6 ", __func__, &fl6->daddr); if (asoc) fl6->fl6_sport = htons(asoc->base.bind_addr.port); if (saddr) { fl6->saddr = saddr->v6.sin6_addr; fl6->fl6_sport = saddr->v6.sin6_port; pr_debug("src=%pI6 - ", &fl6->saddr); } dst = ip6_dst_lookup_flow(sk, fl6, NULL, false); if (!asoc || saddr) goto out; bp = &asoc->base.bind_addr; scope = sctp_scope(daddr); /* ip6_dst_lookup has filled in the fl6->saddr for us. Check * to see if we can use it. */ if (!IS_ERR(dst)) { /* Walk through the bind address list and look for a bind * address that matches the source address of the returned dst. */ sctp_v6_to_addr(&dst_saddr, &fl6->saddr, htons(bp->port)); rcu_read_lock(); list_for_each_entry_rcu(laddr, &bp->address_list, list) { if (!laddr->valid || (laddr->state != SCTP_ADDR_SRC)) continue; /* Do not compare against v4 addrs */ if ((laddr->a.sa.sa_family == AF_INET6) && (sctp_v6_cmp_addr(&dst_saddr, &laddr->a))) { rcu_read_unlock(); goto out; } } rcu_read_unlock(); /* None of the bound addresses match the source address of the * dst. So release it. */ dst_release(dst); dst = NULL; } /* Walk through the bind address list and try to get the * best source address for a given destination. */ rcu_read_lock(); list_for_each_entry_rcu(laddr, &bp->address_list, list) { if (!laddr->valid) continue; if ((laddr->state == SCTP_ADDR_SRC) && (laddr->a.sa.sa_family == AF_INET6) && (scope <= sctp_scope(&laddr->a))) { bmatchlen = sctp_v6_addr_match_len(daddr, &laddr->a); if (!baddr || (matchlen < bmatchlen)) { baddr = &laddr->a; matchlen = bmatchlen; } } } rcu_read_unlock(); if (baddr) { fl6->saddr = baddr->v6.sin6_addr; fl6->fl6_sport = baddr->v6.sin6_port; dst = ip6_dst_lookup_flow(sk, fl6, NULL, false); } out: if (!IS_ERR_OR_NULL(dst)) { struct rt6_info *rt; rt = (struct rt6_info *)dst; t->dst = dst; t->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0; pr_debug("rt6_dst:%pI6 rt6_src:%pI6\n", &rt->rt6i_dst.addr, &fl6->saddr); } else { t->dst = NULL; pr_debug("no route\n"); } }
1
401,270
static int copy_tx_sa_stats(struct sk_buff *skb, struct macsec_tx_sa_stats __percpu *pstats) { struct macsec_tx_sa_stats sum = {0, }; int cpu; for_each_possible_cpu(cpu) { const struct macsec_tx_sa_stats *stats = per_cpu_ptr(pstats, cpu); sum.OutPktsProtected += stats->OutPktsProtected; sum.OutPktsEncrypted += stats->OutPktsEncrypted; } if (nla_put_u32(skb, MACSEC_SA_STATS_ATTR_OUT_PKTS_PROTECTED, sum.OutPktsProtected) || nla_put_u32(skb, MACSEC_SA_STATS_ATTR_OUT_PKTS_ENCRYPTED, sum.OutPktsEncrypted)) return -EMSGSIZE; return 0; }
0
512,247
void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag) { group->asn1_flag &= ~EC_GROUP_ASN1_FLAG_MASK; group->asn1_flag |= flag & EC_GROUP_ASN1_FLAG_MASK; }
0
337,106
int unix_listen_opts(QemuOpts *opts, Error **errp) { struct sockaddr_un un; const char *path = qemu_opt_get(opts, "path"); int sock, fd; sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { error_setg_errno(errp, errno, "Failed to create Unix socket"); return -1; } memset(&un, 0, sizeof(un)); un.sun_family = AF_UNIX; if (path && strlen(path)) { snprintf(un.sun_path, sizeof(un.sun_path), "%s", path); } else { const char *tmpdir = getenv("TMPDIR"); tmpdir = tmpdir ? tmpdir : "/tmp"; if (snprintf(un.sun_path, sizeof(un.sun_path), "%s/qemu-socket-XXXXXX", tmpdir) >= sizeof(un.sun_path)) { error_setg_errno(errp, errno, "TMPDIR environment variable (%s) too large", tmpdir); goto err; } /* * This dummy fd usage silences the mktemp() unsecure warning. * Using mkstemp() doesn't make things more secure here * though. bind() complains about existing files, so we have * to unlink first and thus re-open the race window. The * worst case possible is bind() failing, i.e. a DoS attack. */ fd = mkstemp(un.sun_path); if (fd < 0) { error_setg_errno(errp, errno, "Failed to make a temporary socket name in %s", tmpdir); goto err; } close(fd); qemu_opt_set(opts, "path", un.sun_path, &error_abort); } if ((access(un.sun_path, F_OK) == 0) && unlink(un.sun_path) < 0) { error_setg_errno(errp, errno, "Failed to unlink socket %s", un.sun_path); goto err; } if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) { error_setg_errno(errp, errno, "Failed to bind socket to %s", un.sun_path); goto err; } if (listen(sock, 1) < 0) { error_setg_errno(errp, errno, "Failed to listen on socket"); goto err; } return sock; err: closesocket(sock); return -1; }
1
33,125
static inline int iskeychar(int c) { return isalnum(c) || c == '-'; }
0
496,140
~Connection() { res.complete_request_handler_ = nullptr; cancel_deadline_timer(); #ifdef CROW_ENABLE_DEBUG connectionCount--; CROW_LOG_DEBUG << "Connection (" << this << ") freed, total: " << connectionCount; #endif }
0
16,445
static void close_detect_cb ( struct evhttp_request * req , void * arg ) { struct evhttp_connection * evcon = arg ; struct timeval tv ; if ( req != NULL && req -> response_code != HTTP_OK ) { fprintf ( stderr , "FAILED\n" ) ; exit ( 1 ) ; } timerclear ( & tv ) ; tv . tv_sec = 3 ; event_once ( - 1 , EV_TIMEOUT , close_detect_launch , evcon , & tv ) ; }
0
195,574
OJPEGReadHeaderInfoSec(TIFF* tif) { static const char module[]="OJPEGReadHeaderInfoSec"; OJPEGState* sp=(OJPEGState*)tif->tif_data; uint8 m; uint16 n; uint8 o; if (sp->file_size==0) sp->file_size=TIFFGetFileSize(tif); if (sp->jpeg_interchange_format!=0) { if (sp->jpeg_interchange_format>=sp->file_size) { sp->jpeg_interchange_format=0; sp->jpeg_interchange_format_length=0; } else { if ((sp->jpeg_interchange_format_length==0) || (sp->jpeg_interchange_format+sp->jpeg_interchange_format_length>sp->file_size)) sp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format; } } sp->in_buffer_source=osibsNotSetYet; sp->in_buffer_next_strile=0; sp->in_buffer_strile_count=tif->tif_dir.td_nstrips; sp->in_buffer_file_togo=0; sp->in_buffer_togo=0; do { if (OJPEGReadBytePeek(sp,&m)==0) return(0); if (m!=255) break; OJPEGReadByteAdvance(sp); do { if (OJPEGReadByte(sp,&m)==0) return(0); } while(m==255); switch(m) { case JPEG_MARKER_SOI: /* this type of marker has no data, and should be skipped */ break; case JPEG_MARKER_COM: case JPEG_MARKER_APP0: case JPEG_MARKER_APP0+1: case JPEG_MARKER_APP0+2: case JPEG_MARKER_APP0+3: case JPEG_MARKER_APP0+4: case JPEG_MARKER_APP0+5: case JPEG_MARKER_APP0+6: case JPEG_MARKER_APP0+7: case JPEG_MARKER_APP0+8: case JPEG_MARKER_APP0+9: case JPEG_MARKER_APP0+10: case JPEG_MARKER_APP0+11: case JPEG_MARKER_APP0+12: case JPEG_MARKER_APP0+13: case JPEG_MARKER_APP0+14: case JPEG_MARKER_APP0+15: /* this type of marker has data, but it has no use to us (and no place here) and should be skipped */ if (OJPEGReadWord(sp,&n)==0) return(0); if (n<2) { if (sp->subsamplingcorrect==0) TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data"); return(0); } if (n>2) OJPEGReadSkip(sp,n-2); break; case JPEG_MARKER_DRI: if (OJPEGReadHeaderInfoSecStreamDri(tif)==0) return(0); break; case JPEG_MARKER_DQT: if (OJPEGReadHeaderInfoSecStreamDqt(tif)==0) return(0); break; case JPEG_MARKER_DHT: if (OJPEGReadHeaderInfoSecStreamDht(tif)==0) return(0); break; case JPEG_MARKER_SOF0: case JPEG_MARKER_SOF1: case JPEG_MARKER_SOF3: if (OJPEGReadHeaderInfoSecStreamSof(tif,m)==0) return(0); if (sp->subsamplingcorrect!=0) return(1); break; case JPEG_MARKER_SOS: if (sp->subsamplingcorrect!=0) return(1); assert(sp->plane_sample_offset==0); if (OJPEGReadHeaderInfoSecStreamSos(tif)==0) return(0); break; default: TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %d in JPEG data",m); return(0); } } while(m!=JPEG_MARKER_SOS); if (sp->subsamplingcorrect) return(1); if (sp->sof_log==0) { if (OJPEGReadHeaderInfoSecTablesQTable(tif)==0) return(0); sp->sof_marker_id=JPEG_MARKER_SOF0; for (o=0; o<sp->samples_per_pixel; o++) sp->sof_c[o]=o; sp->sof_hv[0]=((sp->subsampling_hor<<4)|sp->subsampling_ver); for (o=1; o<sp->samples_per_pixel; o++) sp->sof_hv[o]=17; sp->sof_x=sp->strile_width; sp->sof_y=sp->strile_length_total; sp->sof_log=1; if (OJPEGReadHeaderInfoSecTablesDcTable(tif)==0) return(0); if (OJPEGReadHeaderInfoSecTablesAcTable(tif)==0) return(0); for (o=1; o<sp->samples_per_pixel; o++) sp->sos_cs[o]=o; } return(1); }
0
386,968
static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) { struct usb_usbvision *usbvision = video_drvdata(file); int res; if (mutex_lock_interruptible(&usbvision->v4l2_lock)) return -ERESTARTSYS; res = usbvision_mmap(file, vma); mutex_unlock(&usbvision->v4l2_lock); return res; }
0
514,692
v8::Local<v8::Object> StreamReq::object() { return GetAsyncWrap()->object(); }
0
223,621
static struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb, u32 key) { struct list_head *pos; assert_spin_locked(&ctx->ctx_lock); /* TODO: use a hash or array, this sucks. */ list_for_each(pos, &ctx->active_reqs) { struct kiocb *kiocb = list_kiocb(pos); if (kiocb->ki_obj.user == iocb && kiocb->ki_key == key) return kiocb; } return NULL; }
0
397,535
static void csrhci_out_hci_packet_acl(void *opaque, const uint8_t *data, int len) { struct csrhci_s *s = (struct csrhci_s *) opaque; uint8_t *pkt = csrhci_out_packet(s, (len + 2) & ~1); /* Align */ *pkt ++ = H4_ACL_PKT; pkt[len & ~1] = 0; memcpy(pkt, data, len); csrhci_fifo_wake(s); }
0
510,693
ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share, partition_info *part_info_arg, ha_partition *clone_arg, MEM_ROOT *clone_mem_root_arg) :handler(hton, share) { DBUG_ENTER("ha_partition::ha_partition(clone)"); init_alloc_root(&m_mem_root, 512, 512); init_handler_variables(); m_part_info= part_info_arg; m_create_handler= TRUE; m_is_sub_partitioned= m_part_info->is_sub_partitioned(); m_is_clone_of= clone_arg; m_clone_mem_root= clone_mem_root_arg; m_pkey_is_clustered= clone_arg->primary_key_is_clustered(); DBUG_VOID_RETURN; }
0
235,328
static void createAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { INC_STATS("DOM.TestObj.create._set"); TestObj* imp = V8TestObj::toNative(info.Holder()); bool v = value->BooleanValue(); imp->setCreate(v); return; }
0
363,260
_hb_ot_layout_set_glyph_property (hb_ot_layout_t *layout, hb_codepoint_t glyph, unsigned int property) { hb_ot_layout_glyph_class_t klass; if (property & LookupFlag::MarkAttachmentType) klass = HB_OT_LAYOUT_GLYPH_CLASS_MARK; else klass = (hb_ot_layout_glyph_class_t) property; hb_ot_layout_set_glyph_class (layout, glyph, klass); }
0
219,383
void DidGetUsageAndQuotaForEviction(QuotaStatusCode status, int64 usage, int64 unlimited_usage, int64 quota, int64 available_space) { quota_status_ = status; usage_ = usage; unlimited_usage_ = unlimited_usage; quota_ = quota; available_space_ = available_space; }
0
60,155
static codel_time_t codel_skb_time_func(const struct sk_buff *skb) { const struct ieee80211_tx_info *info; info = (const struct ieee80211_tx_info *)skb->cb; return info->control.enqueue_time; }
0
81,928
flatpak_repo_parse_extra_data_sources (GVariant *extra_data_sources, int index, const char **name, guint64 *download_size, guint64 *installed_size, const guchar **sha256, const char **uri) { g_autoptr(GVariant) sha256_v = NULL; g_variant_get_child (extra_data_sources, index, "(^aytt@ay&s)", name, download_size, installed_size, &sha256_v, uri); if (download_size) *download_size = GUINT64_FROM_BE (*download_size); if (installed_size) *installed_size = GUINT64_FROM_BE (*installed_size); if (sha256) *sha256 = ostree_checksum_bytes_peek (sha256_v); }
0
498,953
static RzList *analysis_graph_to(RzCore *core, ut64 addr, int depth, HtUP *avoid) { RzAnalysisFunction *cur_fcn = rz_analysis_get_fcn_in(core->analysis, core->offset, 0); RzList *list = rz_list_new(); HtUP *state = ht_up_new0(); if (!list || !state || !cur_fcn) { rz_list_free(list); ht_up_free(state); return NULL; } // forward search if (analysis_path_exists(core, core->offset, addr, list, depth - 1, state, avoid)) { ht_up_free(state); return list; } // backward search RzList *xrefs = rz_analysis_xrefs_get_to(core->analysis, cur_fcn->addr); if (xrefs) { RzListIter *iter; RzAnalysisXRef *xref = NULL; rz_list_foreach (xrefs, iter, xref) { if (xref->type == RZ_ANALYSIS_REF_TYPE_CALL) { ut64 offset = core->offset; core->offset = xref->from; rz_list_free(list); list = analysis_graph_to(core, addr, depth - 1, avoid); core->offset = offset; if (list && rz_list_length(list)) { rz_list_free(xrefs); ht_up_free(state); return list; } } } } rz_list_free(xrefs); ht_up_free(state); rz_list_free(list); return NULL; }
0
460,091
proto_find_first_finfo(proto_tree *tree, const int id) { ffdata_t ffdata; ffdata.array = g_ptr_array_new(); ffdata.id = id; proto_tree_traverse_pre_order(tree, find_first_finfo, &ffdata); return ffdata.array; }
0
335,949
static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs, int num_reqs, MultiwriteCB *mcb) { int i, outidx; // Sort requests by start sector qsort(reqs, num_reqs, sizeof(*reqs), &multiwrite_req_compare); // Check if adjacent requests touch the same clusters. If so, combine them, // filling up gaps with zero sectors. outidx = 0; for (i = 1; i < num_reqs; i++) { int merge = 0; int64_t oldreq_last = reqs[outidx].sector + reqs[outidx].nb_sectors; // This handles the cases that are valid for all block drivers, namely // exactly sequential writes and overlapping writes. if (reqs[i].sector <= oldreq_last) { merge = 1; } // The block driver may decide that it makes sense to combine requests // even if there is a gap of some sectors between them. In this case, // the gap is filled with zeros (therefore only applicable for yet // unused space in format like qcow2). if (!merge && bs->drv->bdrv_merge_requests) { merge = bs->drv->bdrv_merge_requests(bs, &reqs[outidx], &reqs[i]); } if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) { merge = 0; } if (merge) { size_t size; QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov)); qemu_iovec_init(qiov, reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1); // Add the first request to the merged one. If the requests are // overlapping, drop the last sectors of the first request. size = (reqs[i].sector - reqs[outidx].sector) << 9; qemu_iovec_concat(qiov, reqs[outidx].qiov, size); // We might need to add some zeros between the two requests if (reqs[i].sector > oldreq_last) { size_t zero_bytes = (reqs[i].sector - oldreq_last) << 9; uint8_t *buf = qemu_blockalign(bs, zero_bytes); memset(buf, 0, zero_bytes); qemu_iovec_add(qiov, buf, zero_bytes); mcb->callbacks[i].free_buf = buf; } // Add the second request qemu_iovec_concat(qiov, reqs[i].qiov, reqs[i].qiov->size); reqs[outidx].nb_sectors += reqs[i].nb_sectors; reqs[outidx].qiov = qiov; mcb->callbacks[i].free_qiov = reqs[outidx].qiov; } else { outidx++; reqs[outidx].sector = reqs[i].sector; reqs[outidx].nb_sectors = reqs[i].nb_sectors; reqs[outidx].qiov = reqs[i].qiov; } } return outidx + 1; }
0
117,692
learn_address_script(const struct multi_context *m, const struct multi_instance *mi, const char *op, const struct mroute_addr *addr) { struct gc_arena gc = gc_new(); struct env_set *es; bool ret = true; struct plugin_list *plugins; /* get environmental variable source */ if (mi && mi->context.c2.es) { es = mi->context.c2.es; } else { es = env_set_create(&gc); } /* get plugin source */ if (mi) { plugins = mi->context.plugins; } else { plugins = m->top.plugins; } if (plugin_defined(plugins, OPENVPN_PLUGIN_LEARN_ADDRESS)) { struct argv argv = argv_new(); argv_printf(&argv, "%s %s", op, mroute_addr_print(addr, &gc)); if (mi) { argv_printf_cat(&argv, "%s", tls_common_name(mi->context.c2.tls_multi, false)); } if (plugin_call(plugins, OPENVPN_PLUGIN_LEARN_ADDRESS, &argv, NULL, es) != OPENVPN_PLUGIN_FUNC_SUCCESS) { msg(M_WARN, "WARNING: learn-address plugin call failed"); ret = false; } argv_free(&argv); } if (m->top.options.learn_address_script) { struct argv argv = argv_new(); setenv_str(es, "script_type", "learn-address"); argv_parse_cmd(&argv, m->top.options.learn_address_script); argv_printf_cat(&argv, "%s %s", op, mroute_addr_print(addr, &gc)); if (mi) { argv_printf_cat(&argv, "%s", tls_common_name(mi->context.c2.tls_multi, false)); } if (!openvpn_run_script(&argv, es, 0, "--learn-address")) { ret = false; } argv_free(&argv); } gc_free(&gc); return ret; }
0
83,214
static int cmp_memslot(const void *slot1, const void *slot2) { struct kvm_memory_slot *s1, *s2; s1 = (struct kvm_memory_slot *)slot1; s2 = (struct kvm_memory_slot *)slot2; if (s1->npages < s2->npages) return 1; if (s1->npages > s2->npages) return -1; return 0; }
0
216,020
HeadlessDevToolsClientMinimizeWindowTest() : HeadlessDevToolsClientChangeWindowStateTest( browser::WindowState::MINIMIZED){};
0
32,298
static void ffprobe_show_program_version(WriterContext *w) { AVBPrint pbuf; av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED); writer_print_section_header(w, SECTION_ID_PROGRAM_VERSION); print_str("version", FFMPEG_VERSION); print_fmt("copyright", "Copyright (c) %d-%d the FFmpeg developers", program_birth_year, CONFIG_THIS_YEAR); print_str("compiler_ident", CC_IDENT); print_str("configuration", FFMPEG_CONFIGURATION); writer_print_section_footer(w); av_bprint_finalize(&pbuf, NULL); }
0
144,553
static BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap) { gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap; UINT32 width = bitmap->right - bitmap->left + 1; UINT32 height = bitmap->bottom - bitmap->top + 1; return gdi_BitBlt(context->gdi->primary->hdc, bitmap->left, bitmap->top, width, height, gdi_bitmap->hdc, 0, 0, GDI_SRCCOPY, &context->gdi->palette); }
0
486,929
symbol_make_alias (symbol *sym, symbol *str, location loc) { if (sym->content->class != token_sym) complain (&loc, complaint, _("nonterminals cannot be given a string alias")); else if (str->alias) complain (&loc, Wother, _("symbol %s used more than once as a literal string"), str->tag); else if (sym->alias) complain (&loc, Wother, _("symbol %s given more than one literal string"), sym->tag); else { symbol_merge_properties (sym, str); sym_content_free (str->content); str->content = sym->content; str->content->symbol = str; str->is_alias = true; str->alias = sym; sym->alias = str; } }
0
428,323
void tcp_send_loss_probe(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); struct sk_buff *skb; int pcount; int mss = tcp_current_mss(sk); skb = tcp_send_head(sk); if (skb && tcp_snd_wnd_test(tp, skb, mss)) { pcount = tp->packets_out; tcp_write_xmit(sk, mss, TCP_NAGLE_OFF, 2, GFP_ATOMIC); if (tp->packets_out > pcount) goto probe_sent; goto rearm_timer; } skb = skb_rb_last(&sk->tcp_rtx_queue); if (unlikely(!skb)) { WARN_ONCE(tp->packets_out, "invalid inflight: %u state %u cwnd %u mss %d\n", tp->packets_out, sk->sk_state, tp->snd_cwnd, mss); inet_csk(sk)->icsk_pending = 0; return; } /* At most one outstanding TLP retransmission. */ if (tp->tlp_high_seq) goto rearm_timer; if (skb_still_in_host_queue(sk, skb)) goto rearm_timer; pcount = tcp_skb_pcount(skb); if (WARN_ON(!pcount)) goto rearm_timer; if ((pcount > 1) && (skb->len > (pcount - 1) * mss)) { if (unlikely(tcp_fragment(sk, TCP_FRAG_IN_RTX_QUEUE, skb, (pcount - 1) * mss, mss, GFP_ATOMIC))) goto rearm_timer; skb = skb_rb_next(skb); } if (WARN_ON(!skb || !tcp_skb_pcount(skb))) goto rearm_timer; if (__tcp_retransmit_skb(sk, skb, 1)) goto rearm_timer; /* Record snd_nxt for loss detection. */ tp->tlp_high_seq = tp->snd_nxt; probe_sent: NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPLOSSPROBES); /* Reset s.t. tcp_rearm_rto will restart timer from now */ inet_csk(sk)->icsk_pending = 0; rearm_timer: tcp_rearm_rto(sk); }
0