idx
int64
func
string
target
int64
274,727
static double arc_length(double dia, double angle) { return M_PI*dia*(angle/360.0); }
0
263,515
static void sco_sock_clear_timer(struct sock *sk) { if (!sco_pi(sk)->conn) return; BT_DBG("sock %p state %d", sk, sk->sk_state); cancel_delayed_work(&sco_pi(sk)->conn->timeout_work); }
0
390,540
_XkbCheckTypeName(Atom name,int typeNdx) { char * str; str= NameForAtom(name); if ((strcmp(str,"ONE_LEVEL")==0)||(strcmp(str,"TWO_LEVEL")==0)|| (strcmp(str,"ALPHABETIC")==0)||(strcmp(str,"KEYPAD")==0)) return False; return True; }
0
265,460
static int sqfs_join(char **strings, char *dest, int start, int end, char separator) { int i, offset = 0; for (i = start; i < end; i++) { strcpy(dest + offset, strings[i]); offset += strlen(strings[i]); if (i < end - 1) dest[offset++] = separator; } return offset; }
0
254,893
intrusive_ptr<DocumentSource> DocumentSourceGroup::createFromBson( BSONElement elem, const intrusive_ptr<ExpressionContext>& pExpCtx) { uassert(15947, "a group's fields must be specified in an object", elem.type() == Object); intrusive_ptr<DocumentSourceGroup> pGroup(new DocumentSourceGroup(pExpCtx)); BSONObj groupObj(elem.Obj()); BSONObjIterator groupIterator(groupObj); VariablesParseState vps = pExpCtx->variablesParseState; while (groupIterator.more()) { BSONElement groupField(groupIterator.next()); StringData pFieldName = groupField.fieldNameStringData(); if (pFieldName == "_id") { uassert( 15948, "a group's _id may only be specified once", pGroup->_idExpressions.empty()); pGroup->setIdExpression(parseIdExpression(pExpCtx, groupField, vps)); invariant(!pGroup->_idExpressions.empty()); } else if (pFieldName == "$doingMerge") { massert(17030, "$doingMerge should be true if present", groupField.Bool()); pGroup->setDoingMerge(true); } else { // Any other field will be treated as an accumulator specification. pGroup->addAccumulator( AccumulationStatement::parseAccumulationStatement(pExpCtx, groupField, vps)); } } uassert(15955, "a group specification must include an _id", !pGroup->_idExpressions.empty()); return pGroup; }
0
512,335
virtual longlong val_int_unsigned_typecast() { return cast_to_int_type_handler()->Item_val_int_unsigned_typecast(this); }
0
267,837
vm_run_module (ecma_module_t *module_p) /**< module to be executed */ { const ecma_value_t module_init_result = ecma_module_initialize (module_p); if (ECMA_IS_VALUE_ERROR (module_init_result)) { return module_init_result; } vm_frame_ctx_shared_t shared; shared.bytecode_header_p = module_p->u.compiled_code_p; shared.function_object_p = &module_p->header.object; shared.status_flags = 0; return vm_run (&shared, ECMA_VALUE_UNDEFINED, module_p->scope_p); } /* vm_run_module */
0
225,947
GF_Err mehd_box_size(GF_Box *s) { GF_MovieExtendsHeaderBox *ptr = (GF_MovieExtendsHeaderBox *)s; ptr->version = (ptr->fragment_duration>0xFFFFFFFF) ? 1 : 0; s->size += (ptr->version == 1) ? 8 : 4; return GF_OK; }
0
336,559
static int reds_agent_state_restore(RedsState *reds, SpiceMigrateDataMain *mig_data) { RedCharDeviceVDIPort *agent_dev = reds->agent_dev.get(); uint32_t chunk_header_remaining; agent_dev->priv->vdi_chunk_header = mig_data->agent2client.chunk_header; spice_assert(mig_data->agent2client.chunk_header_size <= sizeof(VDIChunkHeader)); chunk_header_remaining = sizeof(VDIChunkHeader) - mig_data->agent2client.chunk_header_size; if (chunk_header_remaining) { agent_dev->priv->read_state = VDI_PORT_READ_STATE_READ_HEADER; agent_dev->priv->receive_pos = (uint8_t *)&agent_dev->priv->vdi_chunk_header + mig_data->agent2client.chunk_header_size; agent_dev->priv->receive_len = chunk_header_remaining; } else { agent_dev->priv->message_receive_len = agent_dev->priv->vdi_chunk_header.size; } if (!mig_data->agent2client.msg_header_done) { uint8_t *partial_msg_header; if (!chunk_header_remaining) { uint32_t cur_buf_size; agent_dev->priv->read_state = VDI_PORT_READ_STATE_READ_DATA; agent_dev->priv->current_read_buf = vdi_port_get_read_buf(agent_dev); spice_assert(agent_dev->priv->current_read_buf); partial_msg_header = (uint8_t *)mig_data + mig_data->agent2client.msg_header_ptr - sizeof(SpiceMiniDataHeader); memcpy(agent_dev->priv->current_read_buf->data, partial_msg_header, mig_data->agent2client.msg_header_partial_len); agent_dev->priv->receive_pos = agent_dev->priv->current_read_buf->data + mig_data->agent2client.msg_header_partial_len; cur_buf_size = sizeof(agent_dev->priv->current_read_buf->data) - mig_data->agent2client.msg_header_partial_len; agent_dev->priv->receive_len = MIN(agent_dev->priv->message_receive_len, cur_buf_size); agent_dev->priv->current_read_buf->len = agent_dev->priv->receive_len + mig_data->agent2client.msg_header_partial_len; agent_dev->priv->message_receive_len -= agent_dev->priv->receive_len; } else { spice_assert(mig_data->agent2client.msg_header_partial_len == 0); } } else { agent_dev->priv->read_state = VDI_PORT_READ_STATE_GET_BUFF; agent_dev->priv->current_read_buf.reset(); agent_dev->priv->receive_pos = NULL; agent_dev->priv->read_filter.msg_data_to_read = mig_data->agent2client.msg_remaining; agent_dev->priv->read_filter.result = (AgentMsgFilterResult) mig_data->agent2client.msg_filter_result; } agent_dev->priv->read_filter.discard_all = FALSE; agent_dev->priv->write_filter.discard_all = !mig_data->client_agent_started; agent_dev->priv->client_agent_started = mig_data->client_agent_started; agent_dev->priv->write_filter.msg_data_to_read = mig_data->client2agent.msg_remaining; agent_dev->priv->write_filter.result = (AgentMsgFilterResult) mig_data->client2agent.msg_filter_result; spice_debug("to agent filter: discard all %d, wait_msg %u, msg_filter_result %d", agent_dev->priv->write_filter.discard_all, agent_dev->priv->write_filter.msg_data_to_read, agent_dev->priv->write_filter.result); spice_debug("from agent filter: discard all %d, wait_msg %u, msg_filter_result %d", agent_dev->priv->read_filter.discard_all, agent_dev->priv->read_filter.msg_data_to_read, agent_dev->priv->read_filter.result); return agent_dev->restore(&mig_data->agent_base); }
0
248,758
static char *get_netscape_format(const struct Cookie *co) { return aprintf( "%s" /* httponly preamble */ "%s%s\t" /* domain */ "%s\t" /* tailmatch */ "%s\t" /* path */ "%s\t" /* secure */ "%" CURL_FORMAT_CURL_OFF_T "\t" /* expires */ "%s\t" /* name */ "%s", /* value */ co->httponly?"#HttpOnly_":"", /* * Make sure all domains are prefixed with a dot if they allow * tailmatching. This is Mozilla-style. */ (co->tailmatch && co->domain && co->domain[0] != '.')? ".":"", co->domain?co->domain:"unknown", co->tailmatch?"TRUE":"FALSE", co->path?co->path:"/", co->secure?"TRUE":"FALSE", co->expires, co->name, co->value?co->value:""); }
0
448,927
int ZEXPORT inflateResetKeep(strm) z_streamp strm; { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; strm->total_in = strm->total_out = state->total = 0; strm->msg = Z_NULL; if (state->wrap) /* to support ill-conceived Java test suite */ strm->adler = state->wrap & 1; state->mode = HEAD; state->last = 0; state->havedict = 0; state->flags = -1; state->dmax = 32768U; state->head = Z_NULL; state->hold = 0; state->bits = 0; state->lencode = state->distcode = state->next = state->codes; state->sane = 1; state->back = -1; Tracev((stderr, "inflate: reset\n")); return Z_OK; }
0
252,379
int mz_inflateInit(mz_streamp pStream) { return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS); }
0
486,833
static void gem_register_types(void) { type_register_static(&gem_info); }
0
246,731
static GF_Err do_track_act() { u32 j; for (j=0; j<nb_track_act; j++) { u32 i; GF_Err e = GF_OK; TrackAction *tka = &tracks[j]; u32 track = tka->trackID ? gf_isom_get_track_by_id(file, tka->trackID) : 0; timescale = gf_isom_get_timescale(file); switch (tka->act_type) { case TRAC_ACTION_REM_TRACK: e = gf_isom_remove_track(file, track); if (e) { M4_LOG(GF_LOG_ERROR, ("Error Removing track ID %d: %s\n", tka->trackID, gf_error_to_string(e))); } else { M4_LOG(GF_LOG_INFO, ("Removing track ID %d\n", tka->trackID)); } do_save = GF_TRUE; break; case TRAC_ACTION_SET_LANGUAGE: for (i=0; i<gf_isom_get_track_count(file); i++) { if (track && (track != i+1)) continue; e = gf_isom_set_media_language(file, i+1, tka->lang); if (e) return e; do_save = GF_TRUE; } do_save = GF_TRUE; break; case TRAC_ACTION_SET_KIND: for (i=0; i<gf_isom_get_track_count(file); i++) { if (track && (track != i+1)) continue; e = gf_isom_add_track_kind(file, i+1, tka->kind_scheme, tka->kind_value); if (e) return e; do_save = GF_TRUE; } do_save = GF_TRUE; break; case TRAC_ACTION_REM_KIND: for (i=0; i<gf_isom_get_track_count(file); i++) { if (track && (track != i+1)) continue; e = gf_isom_remove_track_kind(file, i+1, tka->kind_scheme, tka->kind_value); if (e) return e; do_save = GF_TRUE; } do_save = GF_TRUE; break; case TRAC_ACTION_SET_DELAY: if (tka->delay.num && tka->delay.den) { u64 tk_dur; e = gf_isom_remove_edits(file, track); if (e) return e; tk_dur = gf_isom_get_track_duration(file, track); if (gf_isom_get_edits_count(file, track)) do_save = GF_TRUE; if (tka->delay.num>0) { //cast to u64, delay_ms * timescale can be quite big before / 1000 e = gf_isom_append_edit(file, track, ((u64) tka->delay.num) * timescale / tka->delay.den, 0, GF_ISOM_EDIT_EMPTY); if (e) return e; e = gf_isom_append_edit(file, track, tk_dur, 0, GF_ISOM_EDIT_NORMAL); if (e) return e; do_save = GF_TRUE; } else { //cast to u64, delay_ms * timescale can be quite big before / 1000 u64 to_skip = ((u64) -tka->delay.num) * timescale / tka->delay.den; if (to_skip<tk_dur) { //cast to u64, delay_ms * timescale can be quite big before / 1000 u64 media_time = ((u64) -tka->delay.num) * gf_isom_get_media_timescale(file, track) / tka->delay.den; e = gf_isom_append_edit(file, track, tk_dur-to_skip, media_time, GF_ISOM_EDIT_NORMAL); if (e) return e; do_save = GF_TRUE; } else { M4_LOG(GF_LOG_WARNING, ("Warning: request negative delay longer than track duration - ignoring\n")); } } } else if (gf_isom_get_edits_count(file, track)) { e = gf_isom_remove_edits(file, track); if (e) return e; do_save = GF_TRUE; } break; case TRAC_ACTION_SET_KMS_URI: for (i=0; i<gf_isom_get_track_count(file); i++) { if (track && (track != i+1)) continue; if (!gf_isom_is_media_encrypted(file, i+1, 1)) continue; if (!gf_isom_is_ismacryp_media(file, i+1, 1)) continue; e = gf_isom_change_ismacryp_protection(file, i+1, 1, NULL, (char *) tka->kms); if (e) return e; do_save = GF_TRUE; } break; case TRAC_ACTION_SET_ID: if (!tka->trackID && (gf_isom_get_track_count(file) == 1)) { M4_LOG(GF_LOG_WARNING, ("Warning: track id is not specified, but file has only one track - assume that you want to change id for this track\n")); track = 1; } if (track) { u32 newTrack; newTrack = gf_isom_get_track_by_id(file, tka->newTrackID); if (newTrack != 0) { M4_LOG(GF_LOG_WARNING, ("Cannot set track id with value %d because a track already exists - ignoring", tka->newTrackID)); } else { e = gf_isom_set_track_id(file, track, tka->newTrackID); if (e) return e; do_save = GF_TRUE; } } else { M4_LOG(GF_LOG_WARNING, ("Error: Cannot change id for track %d because it does not exist - ignoring", tka->trackID)); } break; case TRAC_ACTION_SWAP_ID: if (track) { u32 tk1, tk2; tk1 = gf_isom_get_track_by_id(file, tka->trackID); tk2 = gf_isom_get_track_by_id(file, tka->newTrackID); if (!tk1 || !tk2) { M4_LOG(GF_LOG_WARNING, ("Error: Cannot swap track IDs because not existing - ignoring")); } else { e = gf_isom_set_track_id(file, tk2, 0); if (e) return e; e = gf_isom_set_track_id(file, tk1, tka->newTrackID); if (e) return e; e = gf_isom_set_track_id(file, tk2, tka->trackID); if (e) return e; do_save = GF_TRUE; } } else { M4_LOG(GF_LOG_WARNING, ("Error: Cannot change id for track %d because it does not exist - ignoring", tka->trackID)); } break; case TRAC_ACTION_SET_PAR: e = gf_media_change_par(file, track, tka->par_num, tka->par_den, tka->force_par, tka->rewrite_bs); do_save = GF_TRUE; break; case TRAC_ACTION_SET_CLAP: e = gf_isom_set_clean_aperture(file, track, 1, tka->clap_wnum, tka->clap_wden, tka->clap_hnum, tka->clap_hden, tka->clap_honum, tka->clap_hoden, tka->clap_vonum, tka->clap_voden); do_save = GF_TRUE; break; case TRAC_ACTION_SET_MX: e = gf_isom_set_track_matrix(file, track, tka->mx); do_save = GF_TRUE; break; case TRAC_ACTION_SET_HANDLER_NAME: e = gf_isom_set_handler_name(file, track, tka->hdl_name); do_save = GF_TRUE; break; case TRAC_ACTION_ENABLE: if (!gf_isom_is_track_enabled(file, track)) { e = gf_isom_set_track_enabled(file, track, GF_TRUE); do_save = GF_TRUE; } break; case TRAC_ACTION_DISABLE: if (gf_isom_is_track_enabled(file, track)) { e = gf_isom_set_track_enabled(file, track, GF_FALSE); do_save = GF_TRUE; } break; case TRAC_ACTION_REFERENCE: e = gf_isom_set_track_reference(file, track, GF_4CC(tka->lang[0], tka->lang[1], tka->lang[2], tka->lang[3]), tka->newTrackID); do_save = GF_TRUE; break; case TRAC_ACTION_REM_NON_RAP: e = gf_media_remove_non_rap(file, track, GF_FALSE); do_save = GF_TRUE; break; case TRAC_ACTION_REM_NON_REFS: e = gf_media_remove_non_rap(file, track, GF_TRUE); do_save = GF_TRUE; break; case TRAC_ACTION_SET_UDTA: e = set_file_udta(file, track, tka->udta_type, tka->string ? tka->string : tka->src_name , tka->sample_num ? GF_TRUE : GF_FALSE, tka->string ? GF_TRUE : GF_FALSE); do_save = GF_TRUE; break; case TRAC_ACTION_SET_EDITS: e = apply_edits(file, track, tka->string); do_save = GF_TRUE; break; case TRAC_ACTION_SET_TIME: if (!tka->trackID) { e = gf_isom_set_creation_time(file, tka->time, tka->time); if (e) return e; for (i=0; i<gf_isom_get_track_count(file); i++) { e = gf_isom_set_track_creation_time(file, i+1, tka->time, tka->time); if (e) return e; } } else { e = gf_isom_set_track_creation_time(file, track, tka->time, tka->time); } do_save = GF_TRUE; break; case TRAC_ACTION_SET_MEDIA_TIME: for (i=0; i<gf_isom_get_track_count(file); i++) { if (track && (track != i+1)) continue; e = gf_isom_set_media_creation_time(file, i+1, tka->time, tka->time); if (e) return e; } do_save = GF_TRUE; break; default: break; } if (e) return e; } return GF_OK; }
0
487,609
asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist) { int i = 0; /* * SMP: Nobody else can change our grouplist. Thus we are * safe. */ if (gidsetsize < 0) return -EINVAL; /* no need to grab task_lock here; it cannot change */ i = current->group_info->ngroups; if (gidsetsize) { if (i > gidsetsize) { i = -EINVAL; goto out; } if (groups_to_user(grouplist, current->group_info)) { i = -EFAULT; goto out; } } out: return i; }
0
225,735
GF_Err stco_box_read(GF_Box *s, GF_BitStream *bs) { u32 entries; GF_ChunkOffsetBox *ptr = (GF_ChunkOffsetBox *)s; ISOM_DECREASE_SIZE(ptr, 4); ptr->nb_entries = gf_bs_read_u32(bs); if (ptr->nb_entries > ptr->size / 4 || (u64)ptr->nb_entries > (u64)SIZE_MAX/sizeof(u32)) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Invalid number of entries %d in stco\n", ptr->nb_entries)); return GF_ISOM_INVALID_FILE; } if (ptr->nb_entries) { ptr->offsets = (u32 *) gf_malloc(ptr->nb_entries * sizeof(u32) ); if (ptr->offsets == NULL) return GF_OUT_OF_MEM; ptr->alloc_size = ptr->nb_entries; for (entries = 0; entries < ptr->nb_entries; entries++) { ptr->offsets[entries] = gf_bs_read_u32(bs); } } return GF_OK; }
0
281,099
void xfrm_garbage_collect(struct net *net) { flow_cache_flush(net); }
0
244,136
GF_Err trep_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_TrackExtensionPropertiesBox *ptr = (GF_TrackExtensionPropertiesBox *) s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u32(bs, ptr->trackID); return GF_OK; }
0
247,632
bool DefaultCertValidator::verifyCertificateHashList( X509* cert, const std::vector<std::vector<uint8_t>>& expected_hashes) { std::vector<uint8_t> computed_hash(SHA256_DIGEST_LENGTH); unsigned int n; X509_digest(cert, EVP_sha256(), computed_hash.data(), &n); RELEASE_ASSERT(n == computed_hash.size(), ""); for (const auto& expected_hash : expected_hashes) { if (computed_hash == expected_hash) { return true; } } return false; }
0
390,549
_XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq *req, char* values) { XkbSrvInfoPtr xkbi; XkbDescPtr xkb; int error; int nTypes = 0, nActions; CARD8 mapWidths[XkbMaxLegalKeyCode + 1]; CARD16 symsPerKey[XkbMaxLegalKeyCode + 1]; xkbi= dev->key->xkbInfo; xkb = xkbi->desc; if ((xkb->min_key_code != req->minKeyCode)|| (xkb->max_key_code != req->maxKeyCode)) { if (client->vMajor!=1) { /* pre 1.0 versions of Xlib have a bug */ req->minKeyCode= xkb->min_key_code; req->maxKeyCode= xkb->max_key_code; } else { if (!XkbIsLegalKeycode(req->minKeyCode)) { client->errorValue = _XkbErrCode3(2, req->minKeyCode, req->maxKeyCode); return BadValue; } if (req->minKeyCode > req->maxKeyCode) { client->errorValue = _XkbErrCode3(3, req->minKeyCode, req->maxKeyCode); return BadMatch; } } } if ((req->present & XkbKeyTypesMask) && (!CheckKeyTypes(client,xkb,req,(xkbKeyTypeWireDesc **)&values, &nTypes,mapWidths))) { client->errorValue = nTypes; return BadValue; } if ((req->present & XkbKeySymsMask) && (!CheckKeySyms(client,xkb,req,nTypes,mapWidths,symsPerKey, (xkbSymMapWireDesc **)&values,&error))) { client->errorValue = error; return BadValue; } if ((req->present & XkbKeyActionsMask) && (!CheckKeyActions(xkb,req,nTypes,mapWidths,symsPerKey, (CARD8 **)&values,&nActions))) { client->errorValue = nActions; return BadValue; } if ((req->present & XkbKeyBehaviorsMask) && (!CheckKeyBehaviors(xkb,req,(xkbBehaviorWireDesc**)&values,&error))) { client->errorValue = error; return BadValue; } if ((req->present & XkbVirtualModsMask) && (!CheckVirtualMods(xkb,req,(CARD8 **)&values,&error))) { client->errorValue= error; return BadValue; } if ((req->present&XkbExplicitComponentsMask) && (!CheckKeyExplicit(xkb,req,(CARD8 **)&values,&error))) { client->errorValue= error; return BadValue; } if ((req->present&XkbModifierMapMask) && (!CheckModifierMap(xkb,req,(CARD8 **)&values,&error))) { client->errorValue= error; return BadValue; } if ((req->present&XkbVirtualModMapMask) && (!CheckVirtualModMap(xkb,req,(xkbVModMapWireDesc **)&values,&error))) { client->errorValue= error; return BadValue; } if (((values-((char *)req))/4)!= req->length) { ErrorF("[xkb] Internal error! Bad length in XkbSetMap (after check)\n"); client->errorValue = values-((char *)&req[1]); return BadLength; } return Success; }
0
359,286
DEFUN (neighbor_local_as, neighbor_local_as_cmd, NEIGHBOR_CMD2 "local-as <1-65535>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Specify a local-as number\n" "AS number used as local AS\n") { struct peer *peer; int ret; peer = peer_and_group_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; ret = peer_local_as_set (peer, atoi (argv[1]), 0); return bgp_vty_return (vty, ret); }
0
294,652
m_real_jd(union DateData *x) { VALUE nth, rjd; int jd; nth = m_nth(x); jd = m_jd(x); encode_jd(nth, jd, &rjd); return rjd; }
0
245,725
static long get_content_length (orderedmap hashofheaders) { char *data; long content_length = -1; data = orderedmap_find (hashofheaders, "content-length"); if (data) content_length = atol (data); return content_length; }
0
466,104
static int em_and(struct x86_emulate_ctxt *ctxt) { emulate_2op_SrcV(ctxt, "and"); return X86EMUL_CONTINUE; }
0
210,378
xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref, const xmlChar **URI, int *tlen) { const xmlChar *localname; const xmlChar *prefix; const xmlChar *attname; const xmlChar *aprefix; const xmlChar *nsname; xmlChar *attvalue; const xmlChar **atts = ctxt->atts; int maxatts = ctxt->maxatts; int nratts, nbatts, nbdef; int i, j, nbNs, attval, oldline, oldcol, inputNr; const xmlChar *base; unsigned long cur; int nsNr = ctxt->nsNr; if (RAW != '<') return(NULL); NEXT1; /* * NOTE: it is crucial with the SAX2 API to never call SHRINK beyond that * point since the attribute values may be stored as pointers to * the buffer and calling SHRINK would destroy them ! * The Shrinking is only possible once the full set of attribute * callbacks have been done. */ reparse: SHRINK; base = ctxt->input->base; cur = ctxt->input->cur - ctxt->input->base; inputNr = ctxt->inputNr; oldline = ctxt->input->line; oldcol = ctxt->input->col; nbatts = 0; nratts = 0; nbdef = 0; nbNs = 0; attval = 0; /* Forget any namespaces added during an earlier parse of this element. */ ctxt->nsNr = nsNr; localname = xmlParseQName(ctxt, &prefix); if (localname == NULL) { xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED, "StartTag: invalid element name\n"); return(NULL); } *tlen = ctxt->input->cur - ctxt->input->base - cur; /* * Now parse the attributes, it ends up with the ending * * (S Attribute)* S? */ SKIP_BLANKS; GROW; if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) goto base_changed; while (((RAW != '>') && ((RAW != '/') || (NXT(1) != '>')) && (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) { const xmlChar *q = CUR_PTR; unsigned int cons = ctxt->input->consumed; int len = -1, alloc = 0; attname = xmlParseAttribute2(ctxt, prefix, localname, &aprefix, &attvalue, &len, &alloc); if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) { if ((attvalue != NULL) && (alloc != 0)) xmlFree(attvalue); attvalue = NULL; goto base_changed; } if ((attname != NULL) && (attvalue != NULL)) { if (len < 0) len = xmlStrlen(attvalue); if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) { const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len); xmlURIPtr uri; if (URL == NULL) { xmlErrMemory(ctxt, "dictionary allocation failure"); if ((attvalue != NULL) && (alloc != 0)) xmlFree(attvalue); return(NULL); } if (*URL != 0) { uri = xmlParseURI((const char *) URL); if (uri == NULL) { xmlNsErr(ctxt, XML_WAR_NS_URI, "xmlns: '%s' is not a valid URI\n", URL, NULL, NULL); } else { if (uri->scheme == NULL) { xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE, "xmlns: URI %s is not absolute\n", URL, NULL, NULL); } xmlFreeURI(uri); } if (URL == ctxt->str_xml_ns) { if (attname != ctxt->str_xml) { xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, "xml namespace URI cannot be the default namespace\n", NULL, NULL, NULL); } goto skip_default_ns; } if ((len == 29) && (xmlStrEqual(URL, BAD_CAST "http://www.w3.org/2000/xmlns/"))) { xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, "reuse of the xmlns namespace name is forbidden\n", NULL, NULL, NULL); goto skip_default_ns; } } /* * check that it's not a defined namespace */ for (j = 1;j <= nbNs;j++) if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL) break; if (j <= nbNs) xmlErrAttributeDup(ctxt, NULL, attname); else if (nsPush(ctxt, NULL, URL) > 0) nbNs++; skip_default_ns: if (alloc != 0) xmlFree(attvalue); if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) break; if (!IS_BLANK_CH(RAW)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "attributes construct error\n"); break; } SKIP_BLANKS; continue; } if (aprefix == ctxt->str_xmlns) { const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len); xmlURIPtr uri; if (attname == ctxt->str_xml) { if (URL != ctxt->str_xml_ns) { xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, "xml namespace prefix mapped to wrong URI\n", NULL, NULL, NULL); } /* * Do not keep a namespace definition node */ goto skip_ns; } if (URL == ctxt->str_xml_ns) { if (attname != ctxt->str_xml) { xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, "xml namespace URI mapped to wrong prefix\n", NULL, NULL, NULL); } goto skip_ns; } if (attname == ctxt->str_xmlns) { xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, "redefinition of the xmlns prefix is forbidden\n", NULL, NULL, NULL); goto skip_ns; } if ((len == 29) && (xmlStrEqual(URL, BAD_CAST "http://www.w3.org/2000/xmlns/"))) { xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, "reuse of the xmlns namespace name is forbidden\n", NULL, NULL, NULL); goto skip_ns; } if ((URL == NULL) || (URL[0] == 0)) { xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, "xmlns:%s: Empty XML namespace is not allowed\n", attname, NULL, NULL); goto skip_ns; } else { uri = xmlParseURI((const char *) URL); if (uri == NULL) { xmlNsErr(ctxt, XML_WAR_NS_URI, "xmlns:%s: '%s' is not a valid URI\n", attname, URL, NULL); } else { if ((ctxt->pedantic) && (uri->scheme == NULL)) { xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE, "xmlns:%s: URI %s is not absolute\n", attname, URL, NULL); } xmlFreeURI(uri); } } /* * check that it's not a defined namespace */ for (j = 1;j <= nbNs;j++) if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname) break; if (j <= nbNs) xmlErrAttributeDup(ctxt, aprefix, attname); else if (nsPush(ctxt, attname, URL) > 0) nbNs++; skip_ns: if (alloc != 0) xmlFree(attvalue); if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) break; if (!IS_BLANK_CH(RAW)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "attributes construct error\n"); break; } SKIP_BLANKS; if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) goto base_changed; continue; } /* * Add the pair to atts */ if ((atts == NULL) || (nbatts + 5 > maxatts)) { if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) { if (attvalue[len] == 0) xmlFree(attvalue); goto failed; } maxatts = ctxt->maxatts; atts = ctxt->atts; } ctxt->attallocs[nratts++] = alloc; atts[nbatts++] = attname; atts[nbatts++] = aprefix; atts[nbatts++] = NULL; /* the URI will be fetched later */ atts[nbatts++] = attvalue; attvalue += len; atts[nbatts++] = attvalue; /* * tag if some deallocation is needed */ if (alloc != 0) attval = 1; } else { if ((attvalue != NULL) && (attvalue[len] == 0)) xmlFree(attvalue); } failed: GROW if (ctxt->instate == XML_PARSER_EOF) break; if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) goto base_changed; if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) break; if (!IS_BLANK_CH(RAW)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "attributes construct error\n"); break; } SKIP_BLANKS; if ((cons == ctxt->input->consumed) && (q == CUR_PTR) && (attname == NULL) && (attvalue == NULL)) { xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "xmlParseStartTag: problem parsing attributes\n"); break; } GROW; if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) goto base_changed; } /* * The attributes defaulting */ if (ctxt->attsDefault != NULL) { xmlDefAttrsPtr defaults; defaults = xmlHashLookup2(ctxt->attsDefault, localname, prefix); if (defaults != NULL) { for (i = 0;i < defaults->nbAttrs;i++) { attname = defaults->values[5 * i]; aprefix = defaults->values[5 * i + 1]; /* * special work for namespaces defaulted defs */ if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) { /* * check that it's not a defined namespace */ for (j = 1;j <= nbNs;j++) if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL) break; if (j <= nbNs) continue; nsname = xmlGetNamespace(ctxt, NULL); if (nsname != defaults->values[5 * i + 2]) { if (nsPush(ctxt, NULL, defaults->values[5 * i + 2]) > 0) nbNs++; } } else if (aprefix == ctxt->str_xmlns) { /* * check that it's not a defined namespace */ for (j = 1;j <= nbNs;j++) if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname) break; if (j <= nbNs) continue; nsname = xmlGetNamespace(ctxt, attname); if (nsname != defaults->values[2]) { if (nsPush(ctxt, attname, defaults->values[5 * i + 2]) > 0) nbNs++; } } else { /* * check that it's not a defined attribute */ for (j = 0;j < nbatts;j+=5) { if ((attname == atts[j]) && (aprefix == atts[j+1])) break; } if (j < nbatts) continue; if ((atts == NULL) || (nbatts + 5 > maxatts)) { if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) { return(NULL); } maxatts = ctxt->maxatts; atts = ctxt->atts; } atts[nbatts++] = attname; atts[nbatts++] = aprefix; if (aprefix == NULL) atts[nbatts++] = NULL; else atts[nbatts++] = xmlGetNamespace(ctxt, aprefix); atts[nbatts++] = defaults->values[5 * i + 2]; atts[nbatts++] = defaults->values[5 * i + 3]; if ((ctxt->standalone == 1) && (defaults->values[5 * i + 4] != NULL)) { xmlValidityError(ctxt, XML_DTD_STANDALONE_DEFAULTED, "standalone: attribute %s on %s defaulted from external subset\n", attname, localname); } nbdef++; } } } } /* * The attributes checkings */ for (i = 0; i < nbatts;i += 5) { /* * The default namespace does not apply to attribute names. */ if (atts[i + 1] != NULL) { nsname = xmlGetNamespace(ctxt, atts[i + 1]); if (nsname == NULL) { xmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE, "Namespace prefix %s for %s on %s is not defined\n", atts[i + 1], atts[i], localname); } atts[i + 2] = nsname; } else nsname = NULL; /* * [ WFC: Unique Att Spec ] * No attribute name may appear more than once in the same * start-tag or empty-element tag. * As extended by the Namespace in XML REC. */ for (j = 0; j < i;j += 5) { if (atts[i] == atts[j]) { if (atts[i+1] == atts[j+1]) { xmlErrAttributeDup(ctxt, atts[i+1], atts[i]); break; } if ((nsname != NULL) && (atts[j + 2] == nsname)) { xmlNsErr(ctxt, XML_NS_ERR_ATTRIBUTE_REDEFINED, "Namespaced Attribute %s in '%s' redefined\n", atts[i], nsname, NULL); break; } } } } nsname = xmlGetNamespace(ctxt, prefix); if ((prefix != NULL) && (nsname == NULL)) { xmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE, "Namespace prefix %s on %s is not defined\n", prefix, localname, NULL); } *pref = prefix; *URI = nsname; /* * SAX: Start of Element ! */ if ((ctxt->sax != NULL) && (ctxt->sax->startElementNs != NULL) && (!ctxt->disableSAX)) { if (nbNs > 0) ctxt->sax->startElementNs(ctxt->userData, localname, prefix, nsname, nbNs, &ctxt->nsTab[ctxt->nsNr - 2 * nbNs], nbatts / 5, nbdef, atts); else ctxt->sax->startElementNs(ctxt->userData, localname, prefix, nsname, 0, NULL, nbatts / 5, nbdef, atts); } /* * Free up attribute allocated strings if needed */ if (attval != 0) { for (i = 3,j = 0; j < nratts;i += 5,j++) if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL)) xmlFree((xmlChar *) atts[i]); } return(localname); base_changed: /* * the attribute strings are valid iif the base didn't changed */ if (attval != 0) { for (i = 3,j = 0; j < nratts;i += 5,j++) if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL)) xmlFree((xmlChar *) atts[i]); } /* * We can't switch from one entity to another in the middle * of a start tag */ if (inputNr != ctxt->inputNr) { xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY, "Start tag doesn't start and stop in the same entity\n"); return(NULL); } ctxt->input->cur = ctxt->input->base + cur; ctxt->input->line = oldline; ctxt->input->col = oldcol; if (ctxt->wellFormed == 1) { goto reparse; } return(NULL); }
1
346,450
source_level(void *cookie) { return ((source_cookie_T *)cookie)->level; }
0
256,441
PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_rpsi( const void *buf, pj_size_t length, pjmedia_rtcp_fb_rpsi *rpsi) { pjmedia_rtcp_fb_common *hdr = (pjmedia_rtcp_fb_common*) buf; pj_uint8_t *p; pj_uint8_t padlen; pj_size_t rpsi_len; PJ_ASSERT_RETURN(buf && rpsi, PJ_EINVAL); PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_fb_common), PJ_ETOOSMALL); /* RPSI uses pt==RTCP_PSFB and FMT==3 */ if (hdr->rtcp_common.pt != RTCP_PSFB || hdr->rtcp_common.count != 3) return PJ_ENOTFOUND; if (hdr->rtcp_common.length < 3) { PJ_PERROR(3, (THIS_FILE, PJ_ETOOSMALL, "Failed parsing FB RPSI, invalid header length")); return PJ_ETOOSMALL; } rpsi_len = (pj_ntohs((pj_uint16_t)hdr->rtcp_common.length)-2) * 4; if (length < rpsi_len + 12) return PJ_ETOOSMALL; p = (pj_uint8_t*)hdr + sizeof(*hdr); padlen = *p++; if (padlen >= 32) { PJ_PERROR(3, (THIS_FILE, PJ_ETOOBIG, "Failed parsing FB RPSI, invalid RPSI padding len")); return PJ_ETOOBIG; } if ((rpsi_len * 8) < (unsigned)(16 + padlen)) { PJ_PERROR(3, (THIS_FILE, PJ_ETOOSMALL, "Failed parsing FB RPSI, invalid RPSI bit len")); return PJ_ETOOSMALL; } rpsi->pt = (*p++ & 0x7F); rpsi->rpsi_bit_len = rpsi_len*8 - 16 - padlen; pj_strset(&rpsi->rpsi, (char*)p, (rpsi->rpsi_bit_len + 7)/8); return PJ_SUCCESS; }
0
442,806
static CURLcode main_init(void) { #ifdef DJGPP /* stop stat() wasting time */ _djstat_flags |= _STAT_INODE | _STAT_EXEC_MAGIC | _STAT_DIRSIZE; #endif return curl_global_init(CURL_GLOBAL_DEFAULT); }
0
459,099
static struct tcf_proto *tcf_chain_tp_find(struct tcf_chain *chain, struct tcf_chain_info *chain_info, u32 protocol, u32 prio, bool prio_allocate) { struct tcf_proto **pprev; struct tcf_proto *tp; /* Check the chain for existence of proto-tcf with this priority */ for (pprev = &chain->filter_chain; (tp = tcf_chain_dereference(*pprev, chain)); pprev = &tp->next) { if (tp->prio >= prio) { if (tp->prio == prio) { if (prio_allocate || (tp->protocol != protocol && protocol)) return ERR_PTR(-EINVAL); } else { tp = NULL; } break; } } chain_info->pprev = pprev; if (tp) { chain_info->next = tp->next; tcf_proto_get(tp); } else { chain_info->next = NULL; } return tp; }
0
405,693
static void xemaclite_aligned_write(void *src_ptr, u32 *dest_ptr, unsigned length) { u32 align_buffer; u32 *to_u32_ptr; u16 *from_u16_ptr, *to_u16_ptr; to_u32_ptr = dest_ptr; from_u16_ptr = src_ptr; align_buffer = 0; for (; length > 3; length -= 4) { to_u16_ptr = (u16 *)&align_buffer; *to_u16_ptr++ = *from_u16_ptr++; *to_u16_ptr++ = *from_u16_ptr++; /* This barrier resolves occasional issues seen around * cases where the data is not properly flushed out * from the processor store buffers to the destination * memory locations. */ wmb(); /* Output a word */ *to_u32_ptr++ = align_buffer; } if (length) { u8 *from_u8_ptr, *to_u8_ptr; /* Set up to output the remaining data */ align_buffer = 0; to_u8_ptr = (u8 *)&align_buffer; from_u8_ptr = (u8 *)from_u16_ptr; /* Output the remaining data */ for (; length > 0; length--) *to_u8_ptr++ = *from_u8_ptr++; /* This barrier resolves occasional issues seen around * cases where the data is not properly flushed out * from the processor store buffers to the destination * memory locations. */ wmb(); *to_u32_ptr = align_buffer; } }
0
369,185
static int io_fallocate_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { if (sqe->ioprio || sqe->buf_index || sqe->rw_flags || sqe->splice_fd_in) return -EINVAL; if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) return -EINVAL; req->sync.off = READ_ONCE(sqe->off); req->sync.len = READ_ONCE(sqe->addr); req->sync.mode = READ_ONCE(sqe->len); return 0; }
0
338,084
bool WasmBinaryBuilder::maybeVisitAtomicFence(Expression*& out, uint8_t code) { if (code != BinaryConsts::AtomicFence) { return false; } auto* curr = allocator.alloc<AtomicFence>(); BYN_TRACE("zz node: AtomicFence\n"); curr->order = getU32LEB(); curr->finalize(); out = curr; return true; }
0
226,960
IRC_PROTOCOL_CALLBACK(numeric) { char *pos_args; IRC_PROTOCOL_MIN_ARGS(3); if (irc_server_strcasecmp (server, server->nick, argv[2]) == 0) { pos_args = (argc > 3) ? ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; } else { pos_args = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]; } weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL), date, irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s", weechat_prefix ("network"), pos_args); return WEECHAT_RC_OK; }
0
328,915
R_API ut64 r_bin_java_parse_methods(RBinJavaObj *bin, const ut64 offset, const ut8 *buf, const ut64 len) { int i = 0; ut64 adv = 0; RBinJavaField *method; const ut8 *fm_buf = buf + offset; r_list_free (bin->methods_list); bin->methods_list = r_list_newf (r_bin_java_fmtype_free); if (offset + 2 >= len) { return 0LL; } bin->methods_offset = offset; bin->methods_count = R_BIN_JAVA_USHORT (fm_buf, 0); adv += 2; IFDBG eprintf ("Methods count: %d 0x%"PFMT64x "\n", bin->methods_count, bin->methods_offset); bin->main = NULL; bin->entrypoint = NULL; bin->main_code_attr = NULL; bin->entrypoint_code_attr = NULL; for (i = 0; i < bin->methods_count; i++, bin->method_idx++) { method = r_bin_java_read_next_method (bin, offset + adv, buf, len); if (method) { adv += method->size; r_list_append (bin->methods_list, method); } // Update Main, Init, or Class Init if (method && !strcmp ((const char *) method->name, "main")) { bin->main = method; // get main code attr bin->main_code_attr = r_bin_java_get_attr_from_field (method, R_BIN_JAVA_ATTR_TYPE_CODE_ATTR, 0); } else if (method && (!strcmp ((const char *) method->name, "<init>") || !strcmp ((const char *) method->name, "init"))) { IFDBG eprintf ("Found an init function.\n"); bin->entrypoint = method; bin->entrypoint_code_attr = r_bin_java_get_attr_from_field (method, R_BIN_JAVA_ATTR_TYPE_CODE_ATTR, 0); } else if (method && (!strcmp ((const char *) method->name, "<cinit>") || !strcmp ((const char *) method->name, "cinit"))) { bin->cf2.this_class_entrypoint = method; bin->cf2.this_class_entrypoint_code_attr = r_bin_java_get_attr_from_field (method, R_BIN_JAVA_ATTR_TYPE_CODE_ATTR, 0); } if (adv + offset > len) { eprintf ("[X] r_bin_java: Error unable to parse remainder of classfile after Method: %d.\n", i); break; } IFDBG r_bin_java_print_field_summary(method); } bin->methods_size = adv; return adv; }
0
218,750
static MagickBooleanType ReadPSDChannelZip(Image *image,const size_t channels, const ssize_t type,const PSDCompressionType compression, const size_t compact_size,ExceptionInfo *exception) { MagickBooleanType status; unsigned char *p; size_t count, length, packet_size, row_size; ssize_t y; unsigned char *compact_pixels, *pixels; z_stream stream; if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " layer data is ZIP compressed"); if ((MagickSizeType) compact_size > GetBlobSize(image)) ThrowBinaryException(CorruptImageError,"UnexpectedEndOfFile", image->filename); compact_pixels=(unsigned char *) AcquireQuantumMemory(compact_size, sizeof(*compact_pixels)); if (compact_pixels == (unsigned char *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); packet_size=GetPSDPacketSize(image); row_size=image->columns*packet_size; count=image->rows*row_size; pixels=(unsigned char *) AcquireQuantumMemory(count,sizeof(*pixels)); if (pixels == (unsigned char *) NULL) { compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels); ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); } if (ReadBlob(image,compact_size,compact_pixels) != (ssize_t) compact_size) { pixels=(unsigned char *) RelinquishMagickMemory(pixels); compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels); ThrowBinaryException(CorruptImageError,"UnexpectedEndOfFile", image->filename); } memset(&stream,0,sizeof(stream)); stream.data_type=Z_BINARY; stream.next_in=(Bytef *)compact_pixels; stream.avail_in=(uInt) compact_size; stream.next_out=(Bytef *)pixels; stream.avail_out=(uInt) count; if (inflateInit(&stream) == Z_OK) { int ret; while (stream.avail_out > 0) { ret=inflate(&stream,Z_SYNC_FLUSH); if ((ret != Z_OK) && (ret != Z_STREAM_END)) { (void) inflateEnd(&stream); compact_pixels=(unsigned char *) RelinquishMagickMemory( compact_pixels); pixels=(unsigned char *) RelinquishMagickMemory(pixels); return(MagickFalse); } if (ret == Z_STREAM_END) break; } (void) inflateEnd(&stream); } if (compression == ZipWithPrediction) { p=pixels; while (count > 0) { length=image->columns; while (--length) { if (packet_size == 2) { p[2]+=p[0]+((p[1]+p[3]) >> 8); p[3]+=p[1]; } else *(p+1)+=*p; p+=packet_size; } p+=packet_size; count-=row_size; } } status=MagickTrue; p=pixels; for (y=0; y < (ssize_t) image->rows; y++) { status=ReadPSDChannelPixels(image,channels,y,type,p,exception); if (status == MagickFalse) break; p+=row_size; } compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels); pixels=(unsigned char *) RelinquishMagickMemory(pixels); return(status); }
0
359,544
zlog (struct zlog *zl, int priority, const char *format, ...) { va_list args; va_start(args, format); vzlog (zl, priority, format, args); va_end (args); }
0
446,055
LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { register LZWCodecState *sp = EncoderState(tif); register long fcode; register hash_t *hp; register int h, c; hcode_t ent; long disp; long incount, outcount, checkpoint; unsigned long nextdata; long nextbits; int free_ent, maxcode, nbits; uint8* op; uint8* limit; (void) s; if (sp == NULL) return (0); assert(sp->enc_hashtab != NULL); /* * Load local state. */ incount = sp->enc_incount; outcount = sp->enc_outcount; checkpoint = sp->enc_checkpoint; nextdata = sp->lzw_nextdata; nextbits = sp->lzw_nextbits; free_ent = sp->lzw_free_ent; maxcode = sp->lzw_maxcode; nbits = sp->lzw_nbits; op = tif->tif_rawcp; limit = sp->enc_rawlimit; ent = (hcode_t)sp->enc_oldcode; if (ent == (hcode_t) -1 && cc > 0) { /* * NB: This is safe because it can only happen * at the start of a strip where we know there * is space in the data buffer. */ PutNextCode(op, CODE_CLEAR); ent = *bp++; cc--; incount++; } while (cc > 0) { c = *bp++; cc--; incount++; fcode = ((long)c << BITS_MAX) + ent; h = (c << HSHIFT) ^ ent; /* xor hashing */ #ifdef _WINDOWS /* * Check hash index for an overflow. */ if (h >= HSIZE) h -= HSIZE; #endif hp = &sp->enc_hashtab[h]; if (hp->hash == fcode) { ent = hp->code; continue; } if (hp->hash >= 0) { /* * Primary hash failed, check secondary hash. */ disp = HSIZE - h; if (h == 0) disp = 1; do { /* * Avoid pointer arithmetic because of * wraparound problems with segments. */ if ((h -= disp) < 0) h += HSIZE; hp = &sp->enc_hashtab[h]; if (hp->hash == fcode) { ent = hp->code; goto hit; } } while (hp->hash >= 0); } /* * New entry, emit code and add to table. */ /* * Verify there is space in the buffer for the code * and any potential Clear code that might be emitted * below. The value of limit is setup so that there * are at least 4 bytes free--room for 2 codes. */ if (op > limit) { tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata); if( !TIFFFlushData1(tif) ) return 0; op = tif->tif_rawdata; } PutNextCode(op, ent); ent = (hcode_t)c; hp->code = (hcode_t)(free_ent++); hp->hash = fcode; if (free_ent == CODE_MAX-1) { /* table is full, emit clear code and reset */ cl_hash(sp); sp->enc_ratio = 0; incount = 0; outcount = 0; free_ent = CODE_FIRST; PutNextCode(op, CODE_CLEAR); nbits = BITS_MIN; maxcode = MAXCODE(BITS_MIN); } else { /* * If the next entry is going to be too big for * the code size, then increase it, if possible. */ if (free_ent > maxcode) { nbits++; assert(nbits <= BITS_MAX); maxcode = (int) MAXCODE(nbits); } else if (incount >= checkpoint) { long rat; /* * Check compression ratio and, if things seem * to be slipping, clear the hash table and * reset state. The compression ratio is a * 24+8-bit fractional number. */ checkpoint = incount+CHECK_GAP; CALCRATIO(sp, rat); if (rat <= sp->enc_ratio) { cl_hash(sp); sp->enc_ratio = 0; incount = 0; outcount = 0; free_ent = CODE_FIRST; PutNextCode(op, CODE_CLEAR); nbits = BITS_MIN; maxcode = MAXCODE(BITS_MIN); } else sp->enc_ratio = rat; } } hit: ; } /* * Restore global state. */ sp->enc_incount = incount; sp->enc_outcount = outcount; sp->enc_checkpoint = checkpoint; sp->enc_oldcode = ent; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; sp->lzw_free_ent = (unsigned short)free_ent; sp->lzw_maxcode = (unsigned short)maxcode; sp->lzw_nbits = (unsigned short)nbits; tif->tif_rawcp = op; return (1); }
0
343,287
static int _dlmap_remap(DLHandler * const dlhandler) { size_t min_dlmap_size; off_t remaining; if (dlhandler->map_data != NULL) { if (dlhandler->cur_pos >= dlhandler->dlmap_pos && dlhandler->cur_pos + dlhandler->chunk_size <= dlhandler->dlmap_pos + (off_t) dlhandler->dlmap_size) { if (dlhandler->cur_pos < dlhandler->dlmap_pos || dlhandler->cur_pos - dlhandler->dlmap_pos > (off_t) dlhandler->dlmap_size) { addreply_noformat(451, "remap"); return -1; } dlhandler->map_data = dlhandler->map + dlhandler->cur_pos - dlhandler->dlmap_pos; return 0; } } if (dlhandler->file_size - dlhandler->cur_pos < dlhandler->chunk_size) { dlhandler->chunk_size = dlhandler->file_size - dlhandler->cur_pos; } if (dlhandler->chunk_size <= 0) { return 1; } dlhandler->dlmap_pos = dlhandler->cur_pos; min_dlmap_size = dlhandler->chunk_size; if (dlhandler->dlmap_size < min_dlmap_size) { dlhandler->dlmap_size = min_dlmap_size; } dlhandler->dlmap_size = (dlhandler->dlmap_size + page_size - (size_t) 1U) & ~(page_size - (size_t) 1U); if (dlhandler->dlmap_size < page_size) { dlhandler->dlmap_size = page_size; } remaining = dlhandler->file_size - dlhandler->dlmap_pos; if ((off_t) dlhandler->dlmap_size > remaining) { dlhandler->dlmap_size = (off_t) remaining; } if (_dlmap_read(dlhandler) != 0) { error(451, MSG_DATA_READ_FAILED); return -1; } dlhandler->map_data = dlhandler->map; return 0; }
0
450,824
static void st21nfca_se_activation_timeout(struct timer_list *t) { struct st21nfca_hci_info *info = from_timer(info, t, se_info.se_active_timer); info->se_info.se_active = false; complete(&info->se_info.req_completion); }
0
317,076
static int selinux_ismaclabel(const char *name) { return (strcmp(name, XATTR_SELINUX_SUFFIX) == 0); }
0
195,341
int64_t OpLevelCostEstimator::CalculateOutputSize(const OpInfo& op_info, bool* found_unknown_shapes) { int64_t total_output_size = 0; // Use float as default for calculations. for (const auto& output : op_info.outputs()) { DataType dt = output.dtype(); const auto& original_output_shape = output.shape(); int64_t output_size = DataTypeSize(BaseType(dt)); int num_dims = std::max(1, original_output_shape.dim_size()); auto output_shape = MaybeGetMinimumShape(original_output_shape, num_dims, found_unknown_shapes); for (const auto& dim : output_shape.dim()) { output_size *= dim.size(); } total_output_size += output_size; VLOG(1) << "Output Size: " << output_size << " Total Output Size:" << total_output_size; } return total_output_size; }
1
252,353
static void CompressZip(unsigned char *dst, tinyexr::tinyexr_uint64 &compressedSize, const unsigned char *src, unsigned long src_size) { std::vector<unsigned char> tmpBuf(src_size); // // Apply EXR-specific? postprocess. Grabbed from OpenEXR's // ImfZipCompressor.cpp // // // Reorder the pixel data. // const char *srcPtr = reinterpret_cast<const char *>(src); { char *t1 = reinterpret_cast<char *>(&tmpBuf.at(0)); char *t2 = reinterpret_cast<char *>(&tmpBuf.at(0)) + (src_size + 1) / 2; const char *stop = srcPtr + src_size; for (;;) { if (srcPtr < stop) *(t1++) = *(srcPtr++); else break; if (srcPtr < stop) *(t2++) = *(srcPtr++); else break; } } // // Predictor. // { unsigned char *t = &tmpBuf.at(0) + 1; unsigned char *stop = &tmpBuf.at(0) + src_size; int p = t[-1]; while (t < stop) { int d = int(t[0]) - p + (128 + 256); p = t[0]; t[0] = static_cast<unsigned char>(d); ++t; } } #if TINYEXR_USE_MINIZ // // Compress the data using miniz // miniz::mz_ulong outSize = miniz::mz_compressBound(src_size); int ret = miniz::mz_compress( dst, &outSize, static_cast<const unsigned char *>(&tmpBuf.at(0)), src_size); assert(ret == miniz::MZ_OK); (void)ret; compressedSize = outSize; #else uLong outSize = compressBound(static_cast<uLong>(src_size)); int ret = compress(dst, &outSize, static_cast<const Bytef *>(&tmpBuf.at(0)), src_size); assert(ret == Z_OK); compressedSize = outSize; #endif // Use uncompressed data when compressed data is larger than uncompressed. // (Issue 40) if (compressedSize >= src_size) { compressedSize = src_size; memcpy(dst, src, src_size); } }
0
371,188
ut64 get_code_object_addr(RzBinPycObj *pyc, RzBuffer *buffer, ut32 magic) { pyc->magic_int = magic; pyc_object *co = get_code_object(pyc, buffer); ut64 result = 0; if (!co) { return 0; } pyc_code_object *cobj = co->data; result = cobj->start_offset; free_object(co); return result; }
0
273,892
static void handle_CDUP(ctrl_t *ctrl, char *path) { handle_CWD(ctrl, ".."); }
0
248,316
static int cfg_print_pff_indent(cfg_t *cfg, FILE *fp, cfg_print_filter_func_t fb_pff, int indent) { int i, result = CFG_SUCCESS; for (i = 0; cfg->opts[i].name; i++) { cfg_print_filter_func_t pff = cfg->pff ? cfg->pff : fb_pff; if (pff && pff(cfg, &cfg->opts[i])) continue; result += cfg_opt_print_pff_indent(&cfg->opts[i], fp, pff, indent); } return result; }
0
309,871
_nc_cookie_init(SCREEN *sp) { bool support_cookies = USE_XMC_SUPPORT; TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) (sp->_term); if (sp == 0 || !ENSURE_TINFO(sp)) return; #if USE_XMC_SUPPORT /* * If we have no magic-cookie support compiled-in, or if it is suppressed * in the environment, reset the support-flag. */ if (magic_cookie_glitch >= 0) { if (getenv("NCURSES_NO_MAGIC_COOKIE") != 0) { support_cookies = FALSE; } } #endif if (!support_cookies && magic_cookie_glitch >= 0) { T(("will disable attributes to work w/o magic cookies")); } if (magic_cookie_glitch > 0) { /* tvi, wyse */ sp->_xmc_triggers = sp->_ok_attributes & XMC_CONFLICT; #if 0 /* * We "should" treat colors as an attribute. The wyse350 (and its * clones) appear to be the only ones that have both colors and magic * cookies. */ if (has_colors()) { sp->_xmc_triggers |= A_COLOR; } #endif sp->_xmc_suppress = sp->_xmc_triggers & (chtype) ~(A_BOLD); T(("magic cookie attributes %s", _traceattr(sp->_xmc_suppress))); /* * Supporting line-drawing may be possible. But make the regular * video attributes work first. */ acs_chars = ABSENT_STRING; ena_acs = ABSENT_STRING; enter_alt_charset_mode = ABSENT_STRING; exit_alt_charset_mode = ABSENT_STRING; #if USE_XMC_SUPPORT /* * To keep the cookie support simple, suppress all of the optimization * hooks except for clear_screen and the cursor addressing. */ if (support_cookies) { clr_eol = ABSENT_STRING; clr_eos = ABSENT_STRING; set_attributes = ABSENT_STRING; } #endif } else if (magic_cookie_glitch == 0) { /* hpterm */ } /* * If magic cookies are not supported, cancel the strings that set * video attributes. */ if (!support_cookies && magic_cookie_glitch >= 0) { magic_cookie_glitch = ABSENT_NUMERIC; set_attributes = ABSENT_STRING; enter_blink_mode = ABSENT_STRING; enter_bold_mode = ABSENT_STRING; enter_dim_mode = ABSENT_STRING; enter_reverse_mode = ABSENT_STRING; enter_standout_mode = ABSENT_STRING; enter_underline_mode = ABSENT_STRING; } /* initialize normal acs before wide, since we use mapping in the latter */ #if !USE_WIDEC_SUPPORT if (_nc_unicode_locale() && _nc_locale_breaks_acs(sp->_term)) { acs_chars = NULL; ena_acs = NULL; enter_alt_charset_mode = NULL; exit_alt_charset_mode = NULL; set_attributes = NULL; } #endif }
0
219,917
static void ReorderSDP(char *sdp_text, Bool is_movie_sdp) { char *cur; GF_List *lines = gf_list_new(); cur = sdp_text; while (cur) { char b; char *st = strstr(cur, "\r\n"); assert(st); st += 2; if (!st[0]) { AddSDPLine(lines, gf_strdup(cur), is_movie_sdp); break; } b = st[0]; st[0] = 0; AddSDPLine(lines, gf_strdup(cur), is_movie_sdp); st[0] = b; cur = st; } strcpy(sdp_text, ""); while (gf_list_count(lines)) { cur = (char *)gf_list_get(lines, 0); gf_list_rem(lines, 0); strcat(sdp_text, cur); gf_free(cur); } gf_list_del(lines); }
0
273,059
net_evhttp_bind(struct evhttp *evhttp, short unsigned port, const char *log_service_name) { const char *bind_address; bool v6_enabled; int ret; bind_address = cfg_getstr(cfg_getsec(cfg, "general"), "bind_address"); if (bind_address) evhttp_bind_socket(evhttp, bind_address, port); // For Linux, we could just do evhttp_bind_socket() for "::", and both the // ipv4 and v6 port would be bound. However, for bsd it seems it is necessary // to do like below. v6_enabled = cfg_getbool(cfg_getsec(cfg, "general"), "ipv6"); if (v6_enabled) { ret = evhttp_bind_socket(evhttp, "::", port); if (ret < 0) { DPRINTF(E_LOG, L_MISC, "Could not bind service '%s' to port %d with IPv6, falling back to IPv4\n", log_service_name, port); v6_enabled = 0; } } ret = evhttp_bind_socket(evhttp, "0.0.0.0", port); if (ret < 0) { if (!v6_enabled) return -1; #ifndef __linux__ DPRINTF(E_LOG, L_MISC, "Could not bind service '%s' to port %d with IPv4, listening on IPv6 only\n", log_service_name, port); #endif } return 0; }
0
462,228
PJ_DEF(pj_status_t) pj_stun_msg_add_errcode_attr(pj_pool_t *pool, pj_stun_msg *msg, int err_code, const pj_str_t *err_reason) { pj_stun_errcode_attr *err_attr = NULL; pj_status_t status; status = pj_stun_errcode_attr_create(pool, err_code, err_reason, &err_attr); if (status != PJ_SUCCESS) return status; return pj_stun_msg_add_attr(msg, &err_attr->hdr); }
0
366,308
static void mount_setattr_commit(struct mount_kattr *kattr, struct mount *mnt, struct mount *last, int err) { struct mount *m = mnt; do { if (!err) { unsigned int flags; do_idmap_mount(kattr, m); flags = recalc_flags(kattr, m); WRITE_ONCE(m->mnt.mnt_flags, flags); } /* * We either set MNT_READONLY above so make it visible * before ~MNT_WRITE_HOLD or we failed to recursively * apply mount options. */ if ((kattr->attr_set & MNT_READONLY) && (m->mnt.mnt_flags & MNT_WRITE_HOLD)) mnt_unhold_writers(m); if (!err && kattr->propagation) change_mnt_propagation(m, kattr->propagation); /* * On failure, only cleanup until we found the first mount * we failed to handle. */ if (err && m == last) break; } while (kattr->recurse && (m = next_mnt(m, mnt))); if (!err) touch_mnt_namespace(mnt->mnt_ns); }
0
309,881
NCURSES_SP_NAME(can_change_color) (NCURSES_SP_DCL) { int result = FALSE; T((T_CALLED("can_change_color(%p)"), (void *) SP_PARM)); if (HasTerminal(SP_PARM) && (CanChange != 0)) { result = TRUE; } returnCode(result); }
0
459,401
get_tags(list_T *list, char_u *pat, char_u *buf_fname) { int num_matches, i, ret; char_u **matches, *p; char_u *full_fname; dict_T *dict; tagptrs_T tp; long is_static; ret = find_tags(pat, &num_matches, &matches, TAG_REGEXP | TAG_NOIC, (int)MAXCOL, buf_fname); if (ret == OK && num_matches > 0) { for (i = 0; i < num_matches; ++i) { if (parse_match(matches[i], &tp) == FAIL) { vim_free(matches[i]); continue; } is_static = test_for_static(&tp); // Skip pseudo-tag lines. if (STRNCMP(tp.tagname, "!_TAG_", 6) == 0) { vim_free(matches[i]); continue; } if ((dict = dict_alloc()) == NULL) { ret = FAIL; vim_free(matches[i]); break; } if (list_append_dict(list, dict) == FAIL) ret = FAIL; full_fname = tag_full_fname(&tp); if (add_tag_field(dict, "name", tp.tagname, tp.tagname_end) == FAIL || add_tag_field(dict, "filename", full_fname, NULL) == FAIL || add_tag_field(dict, "cmd", tp.command, tp.command_end) == FAIL || add_tag_field(dict, "kind", tp.tagkind, tp.tagkind_end) == FAIL || dict_add_number(dict, "static", is_static) == FAIL) ret = FAIL; vim_free(full_fname); if (tp.command_end != NULL) { for (p = tp.command_end + 3; *p != NUL && *p != '\n' && *p != '\r'; MB_PTR_ADV(p)) { if (p == tp.tagkind || (p + 5 == tp.tagkind && STRNCMP(p, "kind:", 5) == 0)) // skip "kind:<kind>" and "<kind>" p = tp.tagkind_end - 1; else if (STRNCMP(p, "file:", 5) == 0) // skip "file:" (static tag) p += 4; else if (!VIM_ISWHITE(*p)) { char_u *s, *n; int len; // Add extra field as a dict entry. Fields are // separated by Tabs. n = p; while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':') ++p; len = (int)(p - n); if (*p == ':' && len > 0) { s = ++p; while (*p != NUL && *p >= ' ') ++p; n[len] = NUL; if (add_tag_field(dict, (char *)n, s, p) == FAIL) ret = FAIL; n[len] = ':'; } else // Skip field without colon. while (*p != NUL && *p >= ' ') ++p; if (*p == NUL) break; } } } vim_free(matches[i]); } vim_free(matches); } return ret; }
0
369,311
static __cold int io_unregister_iowq_aff(struct io_ring_ctx *ctx) { struct io_uring_task *tctx = current->io_uring; if (!tctx || !tctx->io_wq) return -EINVAL; return io_wq_cpu_affinity(tctx->io_wq, NULL);
0
221,692
void Socket::cleanSsl() { // called when failure in ssl set up functions and from stopSsl if (ssl != NULL) { SSL_free(ssl); ssl = NULL; } if (ctx != NULL ) { SSL_CTX_free(ctx); ctx = NULL; } issslserver = false; isssl = false; }
0
229,320
Status ValidateOp(EagerOperation* op) { const NodeDef& node_def = op->MutableAttrs()->BuildNodeDef(); const OpDef* op_def; TF_RETURN_IF_ERROR(OpRegistry::Global()->LookUpOpDef(node_def.op(), &op_def)); return ValidateNodeDef(node_def, *op_def); }
0
252,343
static mz_bool mz_zip_get_file_modified_time(const char *pFilename, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) { #ifdef MINIZ_NO_TIME (void)pFilename; *pDOS_date = *pDOS_time = 0; #else struct MZ_FILE_STAT_STRUCT file_stat; // On Linux with x86 glibc, this call will fail on large files (>= 0x80000000 // bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh. if (MZ_FILE_STAT(pFilename, &file_stat) != 0) return MZ_FALSE; mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date); #endif // #ifdef MINIZ_NO_TIME return MZ_TRUE; }
0
513,185
static const char *item_val_str(struct st_mysql_value *value, char *buffer, int *length) { String str(buffer, *length, system_charset_info), *res; if (!(res= ((st_item_value_holder*)value)->item->val_str(&str))) return NULL; *length= res->length(); if (res->c_ptr_quick() == buffer) return buffer; /* Lets be nice and create a temporary string since the buffer was too small */ return current_thd->strmake(res->ptr(), res->length()); }
0
261,410
static int decode_intra_chroma_pred_mode(thread_context* tctx) { logtrace(LogSlice,"# intra_chroma_pred_mode\n"); int prefix = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE]); int mode; if (prefix==0) { mode=4; } else { mode = decode_CABAC_FL_bypass(&tctx->cabac_decoder, 2); } logtrace(LogSlice,"> intra_chroma_pred_mode = %d\n",mode); logtrace(LogSymbols,"$1 intra_chroma_pred_mode=%d\n",mode); return mode; }
0
294,381
commercial_to_jd(VALUE y, int w, int d, double sg, VALUE *nth, int *ry, int *rjd, int *ns) { double style = guess_style(y, sg); if (style == 0) { int jd; c_commercial_to_jd(FIX2INT(y), w, d, sg, &jd, ns); decode_jd(INT2FIX(jd), nth, rjd); if (f_zero_p(*nth)) *ry = FIX2INT(y); else { VALUE nth2; decode_year(y, *ns ? -1 : +1, &nth2, ry); } } else { decode_year(y, style, nth, ry); c_commercial_to_jd(*ry, w, d, style, rjd, ns); } }
0
437,284
compile_length_enclosure_node(EnclosureNode* node, regex_t* reg) { int len; int tlen; if (node->type == ENCLOSURE_OPTION) return compile_length_option_node(node, reg); if (NODE_ENCLOSURE_BODY(node)) { tlen = compile_length_tree(NODE_ENCLOSURE_BODY(node), reg); if (tlen < 0) return tlen; } else tlen = 0; switch (node->type) { case ENCLOSURE_MEMORY: #ifdef USE_CALL if (node->m.regnum == 0 && NODE_IS_CALLED(node)) { len = tlen + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN; return len; } if (NODE_IS_CALLED(node)) { len = SIZE_OP_MEMORY_START_PUSH + tlen + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN; if (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum)) len += (NODE_IS_RECURSION(node) ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH); else len += (NODE_IS_RECURSION(node) ? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END); } else if (NODE_IS_RECURSION(node)) { len = SIZE_OP_MEMORY_START_PUSH; len += tlen + (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum) ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_REC); } else #endif { if (MEM_STATUS_AT0(reg->bt_mem_start, node->m.regnum)) len = SIZE_OP_MEMORY_START_PUSH; else len = SIZE_OP_MEMORY_START; len += tlen + (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum) ? SIZE_OP_MEMORY_END_PUSH : SIZE_OP_MEMORY_END); } break; case ENCLOSURE_STOP_BACKTRACK: if (NODE_IS_STOP_BT_SIMPLE_REPEAT(node)) { int v; QuantNode* qn; qn = QUANT_(NODE_ENCLOSURE_BODY(node)); tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg); if (tlen < 0) return tlen; v = onig_positive_int_multiply(qn->lower, tlen); if (v < 0) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE; len = v + SIZE_OP_PUSH + tlen + SIZE_OP_POP_OUT + SIZE_OP_JUMP; } else { len = SIZE_OP_ATOMIC_START + tlen + SIZE_OP_ATOMIC_END; } break; case ENCLOSURE_IF_ELSE: { Node* cond = NODE_ENCLOSURE_BODY(node); Node* Then = node->te.Then; Node* Else = node->te.Else; len = compile_length_tree(cond, reg); if (len < 0) return len; len += SIZE_OP_PUSH; len += SIZE_OP_ATOMIC_START + SIZE_OP_ATOMIC_END; if (IS_NOT_NULL(Then)) { tlen = compile_length_tree(Then, reg); if (tlen < 0) return tlen; len += tlen; } if (IS_NOT_NULL(Else)) { len += SIZE_OP_JUMP; tlen = compile_length_tree(Else, reg); if (tlen < 0) return tlen; len += tlen; } } break; default: return ONIGERR_TYPE_BUG; break; } return len; }
0
447,063
DataBuf readFile(const std::wstring& wpath) { FileIo file(wpath); if (file.open("rb") != 0) { throw WError(10, wpath, "rb", strError().c_str()); } struct _stat st; if (0 != ::_wstat(wpath.c_str(), &st)) { throw WError(2, wpath, strError().c_str(), "::_wstat"); } DataBuf buf(st.st_size); long len = file.read(buf.pData_, buf.size_); if (len != buf.size_) { throw WError(2, wpath, strError().c_str(), "FileIo::read"); } return buf; }
0
484,047
setup_key_sizes(void) { memset(&keySizes, 0, sizeof(struct key_sizes)); keySizes.sym_sig_keyLen = DEFAULT_SYM_SIGNING_KEY_LENGTH; keySizes.sym_enc_blockSize = DEFAULT_SYM_ENCRYPTION_BLOCK_SIZE; keySizes.sym_enc_keyLen = DEFAULT_SYM_ENCRYPTION_KEY_LENGTH; keySizes.sym_sig_size = DEFAULT_SYM_SIGNATURE_SIZE; keySizes.asym_lcl_sig_size = DEFAULT_ASYM_LOCAL_SIGNATURE_SIZE; keySizes.asym_rmt_sig_size = DEFAULT_ASYM_REMOTE_SIGNATURE_SIZE; keySizes.asym_rmt_ptext_blocksize = DEFAULT_ASYM_REMOTE_PLAINTEXT_BLOCKSIZE; keySizes.asym_rmt_blocksize = DEFAULT_ASYM_REMOTE_BLOCKSIZE; keySizes.asym_rmt_enc_key_size = 2048; keySizes.asym_lcl_enc_key_size = 1024; }
0
309,940
parse_delay_value(const char *src, double *delays, int *always) { int star = 0; *delays = 0.0; if (always) *always = 0; while (isdigit(UChar(*src))) { (*delays) = (*delays) * 10 + (*src++ - '0'); } if (*src == '.') { int gotdot = 1; ++src; while (isdigit(UChar(*src))) { gotdot *= 10; (*delays) += (*src++ - '0') / gotdot; } } while (*src == '*' || *src == '/') { if (always == 0 && *src == '/') break; if (*src++ == '*') { star = 1; } else { *always = 1; } } if (star) *delays = -(*delays); return src; }
0
226,209
GF_Box *url_box_new() { ISOM_DECL_BOX_ALLOC(GF_DataEntryURLBox, GF_ISOM_BOX_TYPE_URL); return (GF_Box *)tmp; }
0
453,010
static int nft_flow_block_chain(struct nft_base_chain *basechain, const struct net_device *this_dev, enum flow_block_command cmd) { struct net_device *dev; struct nft_hook *hook; int err, i = 0; list_for_each_entry(hook, &basechain->hook_list, list) { dev = hook->ops.dev; if (this_dev && this_dev != dev) continue; err = nft_chain_offload_cmd(basechain, dev, cmd); if (err < 0 && cmd == FLOW_BLOCK_BIND) { if (!this_dev) goto err_flow_block; return err; } i++; } return 0; err_flow_block: list_for_each_entry(hook, &basechain->hook_list, list) { if (i-- <= 0) break; dev = hook->ops.dev; nft_chain_offload_cmd(basechain, dev, FLOW_BLOCK_UNBIND); } return err; }
0
229,345
Status CreateUnshapedOutput( const KernelAndDevice& kernel, const int output_num, Device* output_device, const DataType& output_dtype, const absl::optional<EagerFunctionParams>& eager_func_params, EagerContext* ctx, TensorHandle** output) { #if defined(IS_MOBILE_PLATFORM) return errors::Unimplemented( "Remote outputs are not available on mobile devices."); #else // !IS_MOBILE_PLATFORM int64_t op_id; if (eager_func_params.has_value()) { op_id = eager_func_params.value().op_id; } else { return errors::InvalidArgument( "Unable to find a remote op id for a remote output of ", kernel.name()); } string remote_task; if (!DeviceNameUtils::GetTaskName(output_device->parsed_name(), &remote_task)) { return errors::InvalidArgument( "Unable to find remote task corresponding to device ", output_device->name()); } if (ctx->RemoteMgr()->IsMaster()) { *output = TensorHandle::CreateUnshapedRemoteHandle( op_id, output_num, remote_task, output_dtype, output_device, ctx); } else { *output = TensorHandle::CreateLazyRemoteHandle(op_id, output_num, output_dtype, output_device, /*is_ready=*/false, ctx); } return Status::OK(); #endif // !IS_MOBILE_PLATFORM }
0
506,699
static int run_cert(X509 *crt, const char *nameincert, const struct set_name_fn *fn) { const char *const *pname = names; int failed = 0; for (; *pname != NULL; ++pname) { int samename = strcasecmp(nameincert, *pname) == 0; size_t namelen = strlen(*pname); char *name = OPENSSL_malloc(namelen + 1); int match, ret; memcpy(name, *pname, namelen + 1); match = -1; if (!TEST_int_ge(ret = X509_check_host(crt, name, namelen, 0, NULL), 0)) { failed = 1; } else if (fn->host) { if (ret == 1 && !samename) match = 1; if (ret == 0 && samename) match = 0; } else if (ret == 1) match = 1; if (!TEST_true(check_message(fn, "host", nameincert, match, *pname))) failed = 1; match = -1; if (!TEST_int_ge(ret = X509_check_host(crt, name, namelen, X509_CHECK_FLAG_NO_WILDCARDS, NULL), 0)) { failed = 1; } else if (fn->host) { if (ret == 1 && !samename) match = 1; if (ret == 0 && samename) match = 0; } else if (ret == 1) match = 1; if (!TEST_true(check_message(fn, "host-no-wildcards", nameincert, match, *pname))) failed = 1; match = -1; ret = X509_check_email(crt, name, namelen, 0); if (fn->email) { if (ret && !samename) match = 1; if (!ret && samename && strchr(nameincert, '@') != NULL) match = 0; } else if (ret) match = 1; if (!TEST_true(check_message(fn, "email", nameincert, match, *pname))) failed = 1; OPENSSL_free(name); } return failed == 0; }
0
432,280
int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len) { #if 0 CPUWatchpoint *wp; int ret = 0; QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (watchpoint_address_matches(wp, addr, TARGET_PAGE_SIZE)) { ret |= wp->flags; } } return ret; #endif return 0; }
0
391,669
static NTSTATUS open_mode_check(connection_struct *conn, struct share_mode_lock *lck, uint32 access_mask, uint32 share_access) { int i; if(lck->data->num_share_modes == 0) { return NT_STATUS_OK; } if (is_stat_open(access_mask)) { /* Stat open that doesn't trigger oplock breaks or share mode * checks... ! JRA. */ return NT_STATUS_OK; } /* * Check if the share modes will give us access. */ #if defined(DEVELOPER) for(i = 0; i < lck->data->num_share_modes; i++) { validate_my_share_entries(conn->sconn, i, &lck->data->share_modes[i]); } #endif /* Now we check the share modes, after any oplock breaks. */ for(i = 0; i < lck->data->num_share_modes; i++) { if (!is_valid_share_mode_entry(&lck->data->share_modes[i])) { continue; } /* someone else has a share lock on it, check to see if we can * too */ if (share_conflict(&lck->data->share_modes[i], access_mask, share_access)) { if (share_mode_stale_pid(lck->data, i)) { continue; } return NT_STATUS_SHARING_VIOLATION; } } return NT_STATUS_OK; }
0
512,365
Item *get_copy(THD *thd) { return get_item_copy<Item_float>(thd, this); }
0
234,233
fetch_indexed_string (dwarf_vma idx, struct cu_tu_set * this_set, dwarf_vma offset_size, bool dwo, dwarf_vma str_offsets_base) { enum dwarf_section_display_enum str_sec_idx = dwo ? str_dwo : str; enum dwarf_section_display_enum idx_sec_idx = dwo ? str_index_dwo : str_index; struct dwarf_section *index_section = &debug_displays [idx_sec_idx].section; struct dwarf_section *str_section = &debug_displays [str_sec_idx].section; dwarf_vma index_offset; dwarf_vma str_offset; const char * ret; if (index_section->start == NULL) return (dwo ? _("<no .debug_str_offsets.dwo section>") : _("<no .debug_str_offsets section>")); if (str_section->start == NULL) return (dwo ? _("<no .debug_str.dwo section>") : _("<no .debug_str section>")); index_offset = idx * offset_size; if (this_set != NULL) index_offset += this_set->section_offsets [DW_SECT_STR_OFFSETS]; index_offset += str_offsets_base; if (index_offset + offset_size > index_section->size) { warn (_("string index of %s converts to an offset of 0x%s which is too big for section %s"), dwarf_vmatoa ("d", idx), dwarf_vmatoa ("x", index_offset), str_section->name); return _("<string index too big>"); } /* FIXME: If we are being paranoid then we should also check to see if IDX references an entry beyond the end of the string table pointed to by STR_OFFSETS_BASE. (Since there can be more than one string table in a DWARF string section). */ str_offset = byte_get (index_section->start + index_offset, offset_size); str_offset -= str_section->address; if (str_offset >= str_section->size) { warn (_("indirect offset too big: 0x%s\n"), dwarf_vmatoa ("x", str_offset)); return _("<indirect index offset is too big>"); } ret = (const char *) str_section->start + str_offset; /* Unfortunately we cannot rely upon str_section ending with a NUL byte. Since our caller is expecting to receive a well formed C string we test for the lack of a terminating byte here. */ if (strnlen (ret, str_section->size - str_offset) == str_section->size - str_offset) return _("<no NUL byte at end of section>"); return ret; }
0
261,229
int MqttClient_Unsubscribe(MqttClient *client, MqttUnsubscribe *unsubscribe) { int rc, len; /* Validate required arguments */ if (client == NULL || unsubscribe == NULL) { return MQTT_CODE_ERROR_BAD_ARG; } #ifdef WOLFMQTT_V5 /* Use specified protocol version if set */ unsubscribe->protocol_level = client->protocol_level; #endif if (unsubscribe->stat == MQTT_MSG_BEGIN) { #ifdef WOLFMQTT_MULTITHREAD /* Lock send socket mutex */ rc = wm_SemLock(&client->lockSend); if (rc != 0) { return rc; } #endif /* Encode the subscribe packet */ rc = MqttEncode_Unsubscribe(client->tx_buf, client->tx_buf_len, unsubscribe); #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d, QoS %d", rc, MqttPacket_TypeDesc(MQTT_PACKET_TYPE_UNSUBSCRIBE), MQTT_PACKET_TYPE_UNSUBSCRIBE, unsubscribe->packet_id, 0); #endif if (rc <= 0) { #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif return rc; } len = rc; #ifdef WOLFMQTT_MULTITHREAD rc = wm_SemLock(&client->lockClient); if (rc == 0) { /* inform other threads of expected response */ rc = MqttClient_RespList_Add(client, MQTT_PACKET_TYPE_UNSUBSCRIBE_ACK, unsubscribe->packet_id, &unsubscribe->pendResp, &unsubscribe->ack); wm_SemUnlock(&client->lockClient); } if (rc != 0) { wm_SemUnlock(&client->lockSend); /* Error locking client */ return rc; } #endif /* Send unsubscribe packet */ rc = MqttPacket_Write(client, client->tx_buf, len); #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif if (rc != len) { #ifdef WOLFMQTT_MULTITHREAD if (wm_SemLock(&client->lockClient) == 0) { MqttClient_RespList_Remove(client, &unsubscribe->pendResp); wm_SemUnlock(&client->lockClient); } #endif return rc; } unsubscribe->stat = MQTT_MSG_WAIT; } /* Wait for unsubscribe ack packet */ rc = MqttClient_WaitType(client, &unsubscribe->ack, MQTT_PACKET_TYPE_UNSUBSCRIBE_ACK, unsubscribe->packet_id, client->cmd_timeout_ms); #ifdef WOLFMQTT_NONBLOCK if (rc == MQTT_CODE_CONTINUE) return rc; #endif #ifdef WOLFMQTT_MULTITHREAD if (wm_SemLock(&client->lockClient) == 0) { MqttClient_RespList_Remove(client, &unsubscribe->pendResp); wm_SemUnlock(&client->lockClient); } #endif #ifdef WOLFMQTT_V5 if (unsubscribe->ack.props != NULL) { /* Release the allocated properties */ MqttClient_PropsFree(unsubscribe->ack.props); } #endif /* reset state */ unsubscribe->stat = MQTT_MSG_BEGIN; return rc; }
0
336,561
static void reds_update_agent_properties(RedsState *reds) { if (!reds->agent_dev || reds->config == NULL) { return; } /* copy & paste */ reds->agent_dev->priv->write_filter.copy_paste_enabled = reds->config->agent_copypaste; reds->agent_dev->priv->read_filter.copy_paste_enabled = reds->config->agent_copypaste; /* file transfer */ reds->agent_dev->priv->write_filter.file_xfer_enabled = reds->config->agent_file_xfer; reds->agent_dev->priv->read_filter.file_xfer_enabled = reds->config->agent_file_xfer; }
0
366,287
static void delayed_mntput(struct work_struct *unused) { struct llist_node *node = llist_del_all(&delayed_mntput_list); struct mount *m, *t; llist_for_each_entry_safe(m, t, node, mnt_llist) cleanup_mnt(m); }
0
253,710
static int ccp_copy_to_from_sb(struct ccp_cmd_queue *cmd_q, struct ccp_dm_workarea *wa, u32 jobid, u32 sb, u32 byte_swap, bool from) { struct ccp_op op; memset(&op, 0, sizeof(op)); op.cmd_q = cmd_q; op.jobid = jobid; op.eom = 1; if (from) { op.soc = 1; op.src.type = CCP_MEMTYPE_SB; op.src.u.sb = sb; op.dst.type = CCP_MEMTYPE_SYSTEM; op.dst.u.dma.address = wa->dma.address; op.dst.u.dma.length = wa->length; } else { op.src.type = CCP_MEMTYPE_SYSTEM; op.src.u.dma.address = wa->dma.address; op.src.u.dma.length = wa->length; op.dst.type = CCP_MEMTYPE_SB; op.dst.u.sb = sb; } op.u.passthru.byte_swap = byte_swap; return cmd_q->ccp->vdata->perform->passthru(&op); }
0
261,414
static int decode_split_cu_flag(thread_context* tctx, int x0, int y0, int ctDepth) { // check if neighbors are available int availableL = check_CTB_available(tctx->img, x0,y0, x0-1,y0); int availableA = check_CTB_available(tctx->img, x0,y0, x0,y0-1); int condL = 0; int condA = 0; if (availableL && tctx->img->get_ctDepth(x0-1,y0) > ctDepth) condL=1; if (availableA && tctx->img->get_ctDepth(x0,y0-1) > ctDepth) condA=1; int contextOffset = condL + condA; int context = contextOffset; // decode bit logtrace(LogSlice,"# split_cu_flag context=%d R=%x\n", context, tctx->cabac_decoder.range); int bit = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_SPLIT_CU_FLAG + context]); logtrace(LogSlice,"> split_cu_flag R=%x, ctx=%d, bit=%d\n", tctx->cabac_decoder.range,context,bit); logtrace(LogSymbols,"$1 split_cu_flag=%d\n",bit); return bit; }
0
230,455
uip_nd6_rs_output(void) { UIP_IP_BUF->vtc = 0x60; UIP_IP_BUF->tcflow = 0; UIP_IP_BUF->flow = 0; UIP_IP_BUF->proto = UIP_PROTO_ICMP6; UIP_IP_BUF->ttl = UIP_ND6_HOP_LIMIT; uip_create_linklocal_allrouters_mcast(&UIP_IP_BUF->destipaddr); uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr); UIP_ICMP_BUF->type = ICMP6_RS; UIP_ICMP_BUF->icode = 0; if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) { UIP_IP_BUF->len[1] = UIP_ICMPH_LEN + UIP_ND6_RS_LEN; uip_len = uip_l3_icmp_hdr_len + UIP_ND6_RS_LEN; } else { uip_len = uip_l3_icmp_hdr_len + UIP_ND6_RS_LEN + UIP_ND6_OPT_LLAO_LEN; uipbuf_set_len_field(UIP_IP_BUF, UIP_ICMPH_LEN + UIP_ND6_RS_LEN + UIP_ND6_OPT_LLAO_LEN); create_llao(&uip_buf[uip_l3_icmp_hdr_len + UIP_ND6_RS_LEN], UIP_ND6_OPT_SLLAO); } UIP_ICMP_BUF->icmpchksum = 0; UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum(); UIP_STAT(++uip_stat.nd6.sent); LOG_INFO("Sending RS to "); LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr); LOG_INFO_(" from "); LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr); LOG_INFO_("\n"); return; }
0
309,885
skip_DECSCNM(const char *value, int *flag) { *flag = -1; if (value != 0) { int skip = csi_length(value); if (skip > 0 && value[skip++] == '?' && value[skip++] == '5') { if (value[skip] == 'h') { *flag = 1; } else if (value[skip] == 'l') { *flag = 0; } value += skip + 1; } } return value; }
0
225,000
ldapServiceLookup(const char *purl, PQconninfoOption *options, PQExpBuffer errorMessage) { int port = LDAP_DEF_PORT, scope, rc, size, state, oldstate, i; #ifndef WIN32 int msgid; #endif bool found_keyword; char *url, *hostname, *portstr, *endptr, *dn, *scopestr, *filter, *result, *p, *p1 = NULL, *optname = NULL, *optval = NULL; char *attrs[2] = {NULL, NULL}; LDAP *ld = NULL; LDAPMessage *res, *entry; struct berval **values; LDAP_TIMEVAL time = {PGLDAP_TIMEOUT, 0}; if ((url = strdup(purl)) == NULL) { appendPQExpBufferStr(errorMessage, libpq_gettext("out of memory\n")); return 3; } /* * Parse URL components, check for correctness. Basically, url has '\0' * placed at component boundaries and variables are pointed at each * component. */ if (pg_strncasecmp(url, LDAP_URL, strlen(LDAP_URL)) != 0) { appendPQExpBuffer(errorMessage, libpq_gettext("invalid LDAP URL \"%s\": scheme must be ldap://\n"), purl); free(url); return 3; } /* hostname */ hostname = url + strlen(LDAP_URL); if (*hostname == '/') /* no hostname? */ hostname = DefaultHost; /* the default */ /* dn, "distinguished name" */ p = strchr(url + strlen(LDAP_URL), '/'); if (p == NULL || *(p + 1) == '\0' || *(p + 1) == '?') { appendPQExpBuffer(errorMessage, libpq_gettext("invalid LDAP URL \"%s\": missing distinguished name\n"), purl); free(url); return 3; } *p = '\0'; /* terminate hostname */ dn = p + 1; /* attribute */ if ((p = strchr(dn, '?')) == NULL || *(p + 1) == '\0' || *(p + 1) == '?') { appendPQExpBuffer(errorMessage, libpq_gettext("invalid LDAP URL \"%s\": must have exactly one attribute\n"), purl); free(url); return 3; } *p = '\0'; attrs[0] = p + 1; /* scope */ if ((p = strchr(attrs[0], '?')) == NULL || *(p + 1) == '\0' || *(p + 1) == '?') { appendPQExpBuffer(errorMessage, libpq_gettext("invalid LDAP URL \"%s\": must have search scope (base/one/sub)\n"), purl); free(url); return 3; } *p = '\0'; scopestr = p + 1; /* filter */ if ((p = strchr(scopestr, '?')) == NULL || *(p + 1) == '\0' || *(p + 1) == '?') { appendPQExpBuffer(errorMessage, libpq_gettext("invalid LDAP URL \"%s\": no filter\n"), purl); free(url); return 3; } *p = '\0'; filter = p + 1; if ((p = strchr(filter, '?')) != NULL) *p = '\0'; /* port number? */ if ((p1 = strchr(hostname, ':')) != NULL) { long lport; *p1 = '\0'; portstr = p1 + 1; errno = 0; lport = strtol(portstr, &endptr, 10); if (*portstr == '\0' || *endptr != '\0' || errno || lport < 0 || lport > 65535) { appendPQExpBuffer(errorMessage, libpq_gettext("invalid LDAP URL \"%s\": invalid port number\n"), purl); free(url); return 3; } port = (int) lport; } /* Allow only one attribute */ if (strchr(attrs[0], ',') != NULL) { appendPQExpBuffer(errorMessage, libpq_gettext("invalid LDAP URL \"%s\": must have exactly one attribute\n"), purl); free(url); return 3; } /* set scope */ if (pg_strcasecmp(scopestr, "base") == 0) scope = LDAP_SCOPE_BASE; else if (pg_strcasecmp(scopestr, "one") == 0) scope = LDAP_SCOPE_ONELEVEL; else if (pg_strcasecmp(scopestr, "sub") == 0) scope = LDAP_SCOPE_SUBTREE; else { appendPQExpBuffer(errorMessage, libpq_gettext("invalid LDAP URL \"%s\": must have search scope (base/one/sub)\n"), purl); free(url); return 3; } /* initialize LDAP structure */ if ((ld = ldap_init(hostname, port)) == NULL) { appendPQExpBufferStr(errorMessage, libpq_gettext("could not create LDAP structure\n")); free(url); return 3; } /* * Perform an explicit anonymous bind. * * LDAP does not require that an anonymous bind is performed explicitly, * but we want to distinguish between the case where LDAP bind does not * succeed within PGLDAP_TIMEOUT seconds (return 2 to continue parsing the * service control file) and the case where querying the LDAP server fails * (return 1 to end parsing). * * Unfortunately there is no way of setting a timeout that works for both * Windows and OpenLDAP. */ #ifdef WIN32 /* the nonstandard ldap_connect function performs an anonymous bind */ if (ldap_connect(ld, &time) != LDAP_SUCCESS) { /* error or timeout in ldap_connect */ free(url); ldap_unbind(ld); return 2; } #else /* !WIN32 */ /* in OpenLDAP, use the LDAP_OPT_NETWORK_TIMEOUT option */ if (ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &time) != LDAP_SUCCESS) { free(url); ldap_unbind(ld); return 3; } /* anonymous bind */ if ((msgid = ldap_simple_bind(ld, NULL, NULL)) == -1) { /* error or network timeout */ free(url); ldap_unbind(ld); return 2; } /* wait some time for the connection to succeed */ res = NULL; if ((rc = ldap_result(ld, msgid, LDAP_MSG_ALL, &time, &res)) == -1 || res == NULL) { /* error or timeout */ if (res != NULL) ldap_msgfree(res); free(url); ldap_unbind(ld); return 2; } ldap_msgfree(res); /* reset timeout */ time.tv_sec = -1; if (ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &time) != LDAP_SUCCESS) { free(url); ldap_unbind(ld); return 3; } #endif /* WIN32 */ /* search */ res = NULL; if ((rc = ldap_search_st(ld, dn, scope, filter, attrs, 0, &time, &res)) != LDAP_SUCCESS) { if (res != NULL) ldap_msgfree(res); appendPQExpBuffer(errorMessage, libpq_gettext("lookup on LDAP server failed: %s\n"), ldap_err2string(rc)); ldap_unbind(ld); free(url); return 1; } /* complain if there was not exactly one result */ if ((rc = ldap_count_entries(ld, res)) != 1) { appendPQExpBufferStr(errorMessage, rc ? libpq_gettext("more than one entry found on LDAP lookup\n") : libpq_gettext("no entry found on LDAP lookup\n")); ldap_msgfree(res); ldap_unbind(ld); free(url); return 1; } /* get entry */ if ((entry = ldap_first_entry(ld, res)) == NULL) { /* should never happen */ appendPQExpBufferStr(errorMessage, libpq_gettext("no entry found on LDAP lookup\n")); ldap_msgfree(res); ldap_unbind(ld); free(url); return 1; } /* get values */ if ((values = ldap_get_values_len(ld, entry, attrs[0])) == NULL) { appendPQExpBufferStr(errorMessage, libpq_gettext("attribute has no values on LDAP lookup\n")); ldap_msgfree(res); ldap_unbind(ld); free(url); return 1; } ldap_msgfree(res); free(url); if (values[0] == NULL) { appendPQExpBufferStr(errorMessage, libpq_gettext("attribute has no values on LDAP lookup\n")); ldap_value_free_len(values); ldap_unbind(ld); return 1; } /* concatenate values into a single string with newline terminators */ size = 1; /* for the trailing null */ for (i = 0; values[i] != NULL; i++) size += values[i]->bv_len + 1; if ((result = malloc(size)) == NULL) { appendPQExpBufferStr(errorMessage, libpq_gettext("out of memory\n")); ldap_value_free_len(values); ldap_unbind(ld); return 3; } p = result; for (i = 0; values[i] != NULL; i++) { memcpy(p, values[i]->bv_val, values[i]->bv_len); p += values[i]->bv_len; *(p++) = '\n'; } *p = '\0'; ldap_value_free_len(values); ldap_unbind(ld); /* parse result string */ oldstate = state = 0; for (p = result; *p != '\0'; ++p) { switch (state) { case 0: /* between entries */ if (!ld_is_sp_tab(*p) && !ld_is_nl_cr(*p)) { optname = p; state = 1; } break; case 1: /* in option name */ if (ld_is_sp_tab(*p)) { *p = '\0'; state = 2; } else if (ld_is_nl_cr(*p)) { appendPQExpBuffer(errorMessage, libpq_gettext("missing \"=\" after \"%s\" in connection info string\n"), optname); free(result); return 3; } else if (*p == '=') { *p = '\0'; state = 3; } break; case 2: /* after option name */ if (*p == '=') { state = 3; } else if (!ld_is_sp_tab(*p)) { appendPQExpBuffer(errorMessage, libpq_gettext("missing \"=\" after \"%s\" in connection info string\n"), optname); free(result); return 3; } break; case 3: /* before option value */ if (*p == '\'') { optval = p + 1; p1 = p + 1; state = 5; } else if (ld_is_nl_cr(*p)) { optval = optname + strlen(optname); /* empty */ state = 0; } else if (!ld_is_sp_tab(*p)) { optval = p; state = 4; } break; case 4: /* in unquoted option value */ if (ld_is_sp_tab(*p) || ld_is_nl_cr(*p)) { *p = '\0'; state = 0; } break; case 5: /* in quoted option value */ if (*p == '\'') { *p1 = '\0'; state = 0; } else if (*p == '\\') state = 6; else *(p1++) = *p; break; case 6: /* in quoted option value after escape */ *(p1++) = *p; state = 5; break; } if (state == 0 && oldstate != 0) { found_keyword = false; for (i = 0; options[i].keyword; i++) { if (strcmp(options[i].keyword, optname) == 0) { if (options[i].val == NULL) { options[i].val = strdup(optval); if (!options[i].val) { appendPQExpBufferStr(errorMessage, libpq_gettext("out of memory\n")); free(result); return 3; } } found_keyword = true; break; } } if (!found_keyword) { appendPQExpBuffer(errorMessage, libpq_gettext("invalid connection option \"%s\"\n"), optname); free(result); return 1; } optname = NULL; optval = NULL; } oldstate = state; } free(result); if (state == 5 || state == 6) { appendPQExpBufferStr(errorMessage, libpq_gettext("unterminated quoted string in connection info string\n")); return 3; } return 0; }
0
226,055
void gnra_box_del(GF_Box *s) { GF_GenericAudioSampleEntryBox *ptr = (GF_GenericAudioSampleEntryBox *)s; gf_isom_sample_entry_predestroy((GF_SampleEntryBox *)ptr); if (ptr->data) gf_free(ptr->data); gf_free(ptr); }
0
220,850
inline LutOutT lut_lookup_with_interpolation(int16_t value, const LutOutT* lut) { static_assert(std::is_same<LutOutT, int8_t>::value || std::is_same<LutOutT, int16_t>::value, "Only LUTs with int8 or int16 outputs are supported."); // 512 base values, lut[513] is only used to calculate the slope const uint16_t index = static_cast<uint16_t>(256 + (value >> 7)); assert(index < 512 && "LUT index out of range."); const int16_t offset = value & 0x7f; // Base and slope are Q0.x const LutOutT base = lut[index]; const LutOutT slope = lut[index + 1] - lut[index]; // Q0.x * Q0.7 = Q0.(x + 7) // Round and convert from Q0.(x + 7) to Q0.x const int delta = (slope * offset + 64) >> 7; // Q0.15 + Q0.15 return static_cast<LutOutT>(base + delta); }
0
424,897
static void iwl_pcie_alloc_fw_monitor_block(struct iwl_trans *trans, u8 max_power, u8 min_power) { void *cpu_addr = NULL; dma_addr_t phys = 0; u32 size = 0; u8 power; for (power = max_power; power >= min_power; power--) { size = BIT(power); cpu_addr = dma_alloc_coherent(trans->dev, size, &phys, GFP_KERNEL | __GFP_NOWARN); if (!cpu_addr) continue; IWL_INFO(trans, "Allocated 0x%08x bytes for firmware monitor.\n", size); break; } if (WARN_ON_ONCE(!cpu_addr)) return; if (power != max_power) IWL_ERR(trans, "Sorry - debug buffer is only %luK while you requested %luK\n", (unsigned long)BIT(power - 10), (unsigned long)BIT(max_power - 10)); trans->dbg.fw_mon[trans->dbg.num_blocks].block = cpu_addr; trans->dbg.fw_mon[trans->dbg.num_blocks].physical = phys; trans->dbg.fw_mon[trans->dbg.num_blocks].size = size; trans->dbg.num_blocks++; }
0
225,779
GF_Err srpp_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem) { GF_SRTPProcessBox *ptr = (GF_SRTPProcessBox *)s; switch(a->type) { case GF_ISOM_BOX_TYPE_SCHI: BOX_FIELD_ASSIGN(info, GF_SchemeInformationBox) return GF_OK; case GF_ISOM_BOX_TYPE_SCHM: BOX_FIELD_ASSIGN(scheme_type, GF_SchemeTypeBox) return GF_OK; } return GF_OK; }
0
293,733
static void r_rebase_info_free(RRebaseInfo *info) { if (!info) { return; } if (info->ranges) { R_FREE (info->ranges); info->ranges = NULL; } R_FREE (info); }
0
432,263
static bool addrrange_contains(AddrRange range, Int128 addr) { return int128_ge(addr, range.start) && int128_lt(addr, addrrange_end(range)); }
0
384,211
static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set, const struct nlattr *attr) { struct nlattr *nla[NFTA_SET_ELEM_MAX + 1]; struct nft_set_ext_tmpl tmpl; struct nft_set_elem elem; struct nft_set_ext *ext; struct nft_trans *trans; u32 flags = 0; int err; err = nla_parse_nested_deprecated(nla, NFTA_SET_ELEM_MAX, attr, nft_set_elem_policy, NULL); if (err < 0) return err; err = nft_setelem_parse_flags(set, nla[NFTA_SET_ELEM_FLAGS], &flags); if (err < 0) return err; if (!nla[NFTA_SET_ELEM_KEY] && !(flags & NFT_SET_ELEM_CATCHALL)) return -EINVAL; if (!nft_setelem_valid_key_end(set, nla, flags)) return -EINVAL; nft_set_ext_prepare(&tmpl); if (flags != 0) { err = nft_set_ext_add(&tmpl, NFT_SET_EXT_FLAGS); if (err < 0) return err; } if (nla[NFTA_SET_ELEM_KEY]) { err = nft_setelem_parse_key(ctx, set, &elem.key.val, nla[NFTA_SET_ELEM_KEY]); if (err < 0) return err; err = nft_set_ext_add_length(&tmpl, NFT_SET_EXT_KEY, set->klen); if (err < 0) goto fail_elem; } if (nla[NFTA_SET_ELEM_KEY_END]) { err = nft_setelem_parse_key(ctx, set, &elem.key_end.val, nla[NFTA_SET_ELEM_KEY_END]); if (err < 0) goto fail_elem; err = nft_set_ext_add_length(&tmpl, NFT_SET_EXT_KEY_END, set->klen); if (err < 0) goto fail_elem_key_end; } err = -ENOMEM; elem.priv = nft_set_elem_init(set, &tmpl, elem.key.val.data, elem.key_end.val.data, NULL, 0, 0, GFP_KERNEL_ACCOUNT); if (IS_ERR(elem.priv)) { err = PTR_ERR(elem.priv); goto fail_elem_key_end; } ext = nft_set_elem_ext(set, elem.priv); if (flags) *nft_set_ext_flags(ext) = flags; trans = nft_trans_elem_alloc(ctx, NFT_MSG_DELSETELEM, set); if (trans == NULL) goto fail_trans; err = nft_setelem_deactivate(ctx->net, set, &elem, flags); if (err < 0) goto fail_ops; nft_setelem_data_deactivate(ctx->net, set, &elem); nft_trans_elem(trans) = elem; nft_trans_commit_list_add_tail(ctx->net, trans); return 0; fail_ops: kfree(trans); fail_trans: kfree(elem.priv); fail_elem_key_end: nft_data_release(&elem.key_end.val, NFT_DATA_VALUE); fail_elem: nft_data_release(&elem.key.val, NFT_DATA_VALUE); return err; }
0
343,294
void doallo(const off_t size) { int ret = -1; #ifdef QUOTAS Quota quota; #endif if (size <= 0) { ret = 0; } else if (ul_check_free_space(wd, (double) size) != 0) { ret = 0; } #ifdef QUOTAS if (quota_update(&quota, 0LL, 0LL, NULL) == 0) { if (quota.files >= user_quota_files || quota.size >= user_quota_size || (unsigned long long) size > user_quota_size - quota.size) { ret = -1; } } #endif if (ret == 0) { #ifdef DISABLE_HUMOR addreply_noformat(200, "OK"); #else addreply_noformat(200, "A L'HUILE"); #endif } else { addreply_noformat(552, MSG_NO_DISK_SPACE); } }
0
274,698
callbacks_quit_activate (GtkMenuItem *menuitem, gpointer user_data) { gboolean layers_dirty = FALSE; gint idx; for (idx = 0; idx<=mainProject->last_loaded; idx++) { if (mainProject->file[idx] == NULL) break; layers_dirty = layers_dirty || mainProject->file[idx]->layer_dirty; } if (layers_dirty && !interface_get_alert_dialog_response( _("Do you want to close all open layers and quit the program?"), _("Quitting the program will cause any unsaved changes " "to be lost."), FALSE, NULL, GTK_STOCK_QUIT, GTK_STOCK_CANCEL)) { return TRUE; // stop propagation of the delete_event. // this would destroy the gui but not return from the gtk event loop. } /* Save background color */ if (screen.settings && !screen.background_is_from_project) { guint clr; GdkColor *bg = &mainProject->background; clr = bg->red/257<<16 | bg->green/257<<8 | bg->blue/257; g_settings_set_uint (screen.settings, "background-color", clr); } /* Save main window size and postion */ if (screen.settings) { GtkWindow *win = GTK_WINDOW(screen.win.topLevelWindow); gint32 xy[2]; GVariant *var; gboolean is_max; is_max = FALSE != (GDK_WINDOW_STATE_MAXIMIZED & gdk_window_get_state ( gtk_widget_get_window (GTK_WIDGET(win)))); g_settings_set_boolean (screen.settings, "window-maximized", is_max); if (!is_max) { gtk_window_get_size (win, (gint *)xy, (gint *)(xy+1)); var = g_variant_new_fixed_array (G_VARIANT_TYPE_INT32, xy, 2, sizeof (xy[0])); g_settings_set_value (screen.settings, "window-size", var); gtk_window_get_position (win, (gint *)xy, (gint *)(xy+1)); var = g_variant_new_fixed_array (G_VARIANT_TYPE_INT32, xy, 2, sizeof (xy[0])); g_settings_set_value (screen.settings, "window-position", var); } } gerbv_unload_all_layers (mainProject); gtk_main_quit(); return FALSE; }
0
508,337
static my_bool close_cached_tables_callback(TDC_element *element, close_cached_tables_arg *arg) { mysql_mutex_lock(&element->LOCK_table_share); if (element->share && element->flushed && element->version < arg->refresh_version) { /* wait_for_old_version() will unlock mutex and free share */ arg->element= element; return TRUE; } mysql_mutex_unlock(&element->LOCK_table_share); return FALSE; }
0
252,412
size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) { tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); if (!pOut_buf) return 0; out_buf.m_pBuf = (mz_uint8 *)pOut_buf; out_buf.m_capacity = out_buf_len; if (!tdefl_compress_mem_to_output( pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return 0; return out_buf.m_size; }
0
432,209
AddressSpaceDispatch *address_space_dispatch_new(struct uc_struct *uc, FlatView *fv) { AddressSpaceDispatch *d = g_new0(AddressSpaceDispatch, 1); #ifndef NDEBUG uint16_t n; n = dummy_section(uc, &d->map, fv, &(uc->io_mem_unassigned)); assert(n == PHYS_SECTION_UNASSIGNED); #else dummy_section(uc, &d->map, fv, &(uc->io_mem_unassigned)); #endif d->phys_map = (PhysPageEntry) { .ptr = PHYS_MAP_NODE_NIL, .skip = 1 }; d->uc = uc; return d; }
0
294,437
c_find_fdoy(int y, double sg, int *rjd, int *ns) { int d, rm, rd; for (d = 1; d < 31; d++) if (c_valid_civil_p(y, 1, d, sg, &rm, &rd, rjd, ns)) return 1; return 0; }
0
482,692
gst_flxdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) { GstCaps *caps; guint avail; GstFlowReturn res = GST_FLOW_OK; GstFlxDec *flxdec; FlxHeader *flxh; g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR); flxdec = (GstFlxDec *) parent; g_return_val_if_fail (flxdec != NULL, GST_FLOW_ERROR); gst_adapter_push (flxdec->adapter, buf); avail = gst_adapter_available (flxdec->adapter); if (flxdec->state == GST_FLXDEC_READ_HEADER) { if (avail >= FlxHeaderSize) { const guint8 *data = gst_adapter_map (flxdec->adapter, FlxHeaderSize); GstCaps *templ; memcpy ((gchar *) & flxdec->hdr, data, FlxHeaderSize); FLX_HDR_FIX_ENDIANNESS (&(flxdec->hdr)); gst_adapter_unmap (flxdec->adapter); gst_adapter_flush (flxdec->adapter, FlxHeaderSize); flxh = &flxdec->hdr; /* check header */ if (flxh->type != FLX_MAGICHDR_FLI && flxh->type != FLX_MAGICHDR_FLC && flxh->type != FLX_MAGICHDR_FLX) goto wrong_type; GST_LOG ("size : %d", flxh->size); GST_LOG ("frames : %d", flxh->frames); GST_LOG ("width : %d", flxh->width); GST_LOG ("height : %d", flxh->height); GST_LOG ("depth : %d", flxh->depth); GST_LOG ("speed : %d", flxh->speed); flxdec->next_time = 0; if (flxh->type == FLX_MAGICHDR_FLI) { flxdec->frame_time = JIFFIE * flxh->speed; } else if (flxh->speed == 0) { flxdec->frame_time = GST_SECOND / 70; } else { flxdec->frame_time = flxh->speed * GST_MSECOND; } flxdec->duration = flxh->frames * flxdec->frame_time; GST_LOG ("duration : %" GST_TIME_FORMAT, GST_TIME_ARGS (flxdec->duration)); templ = gst_pad_get_pad_template_caps (flxdec->srcpad); caps = gst_caps_copy (templ); gst_caps_unref (templ); gst_caps_set_simple (caps, "width", G_TYPE_INT, flxh->width, "height", G_TYPE_INT, flxh->height, "framerate", GST_TYPE_FRACTION, (gint) GST_MSECOND, (gint) flxdec->frame_time / 1000, NULL); gst_pad_set_caps (flxdec->srcpad, caps); gst_caps_unref (caps); if (flxh->depth <= 8) flxdec->converter = flx_colorspace_converter_new (flxh->width, flxh->height); if (flxh->type == FLX_MAGICHDR_FLC || flxh->type == FLX_MAGICHDR_FLX) { GST_LOG ("(FLC) aspect_dx : %d", flxh->aspect_dx); GST_LOG ("(FLC) aspect_dy : %d", flxh->aspect_dy); GST_LOG ("(FLC) oframe1 : 0x%08x", flxh->oframe1); GST_LOG ("(FLC) oframe2 : 0x%08x", flxh->oframe2); } flxdec->size = ((guint) flxh->width * (guint) flxh->height); /* create delta and output frame */ flxdec->frame_data = g_malloc (flxdec->size); flxdec->delta_data = g_malloc (flxdec->size); flxdec->state = GST_FLXDEC_PLAYING; } } else if (flxdec->state == GST_FLXDEC_PLAYING) { GstBuffer *out; /* while we have enough data in the adapter */ while (avail >= FlxFrameChunkSize && res == GST_FLOW_OK) { FlxFrameChunk flxfh; guchar *chunk; const guint8 *data; GstMapInfo map; chunk = NULL; data = gst_adapter_map (flxdec->adapter, FlxFrameChunkSize); memcpy (&flxfh, data, FlxFrameChunkSize); FLX_FRAME_CHUNK_FIX_ENDIANNESS (&flxfh); gst_adapter_unmap (flxdec->adapter); switch (flxfh.id) { case FLX_FRAME_TYPE: /* check if we have the complete frame */ if (avail < flxfh.size) goto need_more_data; /* flush header */ gst_adapter_flush (flxdec->adapter, FlxFrameChunkSize); chunk = gst_adapter_take (flxdec->adapter, flxfh.size - FlxFrameChunkSize); FLX_FRAME_TYPE_FIX_ENDIANNESS ((FlxFrameType *) chunk); if (((FlxFrameType *) chunk)->chunks == 0) break; /* create 32 bits output frame */ // res = gst_pad_alloc_buffer_and_set_caps (flxdec->srcpad, // GST_BUFFER_OFFSET_NONE, // flxdec->size * 4, GST_PAD_CAPS (flxdec->srcpad), &out); // if (res != GST_FLOW_OK) // break; out = gst_buffer_new_and_alloc (flxdec->size * 4); /* decode chunks */ if (!flx_decode_chunks (flxdec, ((FlxFrameType *) chunk)->chunks, chunk + FlxFrameTypeSize, flxdec->frame_data)) { GST_ELEMENT_ERROR (flxdec, STREAM, DECODE, ("%s", "Could not decode chunk"), NULL); return GST_FLOW_ERROR; } /* save copy of the current frame for possible delta. */ memcpy (flxdec->delta_data, flxdec->frame_data, flxdec->size); gst_buffer_map (out, &map, GST_MAP_WRITE); /* convert current frame. */ flx_colorspace_convert (flxdec->converter, flxdec->frame_data, map.data); gst_buffer_unmap (out, &map); GST_BUFFER_TIMESTAMP (out) = flxdec->next_time; flxdec->next_time += flxdec->frame_time; res = gst_pad_push (flxdec->srcpad, out); break; default: /* check if we have the complete frame */ if (avail < flxfh.size) goto need_more_data; gst_adapter_flush (flxdec->adapter, flxfh.size); break; } g_free (chunk); avail = gst_adapter_available (flxdec->adapter); } } need_more_data: return res; /* ERRORS */ wrong_type: { GST_ELEMENT_ERROR (flxdec, STREAM, WRONG_TYPE, (NULL), ("not a flx file (type %x)", flxh->type)); return GST_FLOW_ERROR; } }
0
452,991
static int nft_flow_offload_bind(struct flow_block_offload *bo, struct nft_base_chain *basechain) { list_splice(&bo->cb_list, &basechain->flow_block.cb_list); return 0; }
0
336,124
static int ip6gre_tunnel_init_common(struct net_device *dev) { struct ip6_tnl *tunnel; int ret; int t_hlen; tunnel = netdev_priv(dev); tunnel->dev = dev; tunnel->net = dev_net(dev); strcpy(tunnel->parms.name, dev->name); dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); if (!dev->tstats) return -ENOMEM; ret = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL); if (ret) { free_percpu(dev->tstats); dev->tstats = NULL; return ret; } tunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags); tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen; t_hlen = tunnel->hlen + sizeof(struct ipv6hdr); dev->hard_header_len = LL_MAX_HEADER + t_hlen; dev->mtu = ETH_DATA_LEN - t_hlen; if (dev->type == ARPHRD_ETHER) dev->mtu -= ETH_HLEN; if (!(tunnel->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) dev->mtu -= 8; return 0; }
0
405,697
static void xemaclite_tx_handler(struct net_device *dev) { struct net_local *lp = netdev_priv(dev); dev->stats.tx_packets++; if (!lp->deferred_skb) return; if (xemaclite_send_data(lp, (u8 *)lp->deferred_skb->data, lp->deferred_skb->len)) return; dev->stats.tx_bytes += lp->deferred_skb->len; dev_consume_skb_irq(lp->deferred_skb); lp->deferred_skb = NULL; netif_trans_update(dev); /* prevent tx timeout */ netif_wake_queue(dev); }
0
247,690
TEST_P(SslSocketTest, RsaPrivateKeyProviderAsyncDecryptCompleteFailure) { const std::string server_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem" private_key_provider: provider_name: test typed_config: "@type": type.googleapis.com/google.protobuf.Struct value: private_key_file: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem" expected_operation: decrypt async_method_error: true mode: rsa validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.pem" crl: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.crl" )EOF"; const std::string failing_client_ctx_yaml = R"EOF( common_tls_context: tls_params: cipher_suites: - TLS_RSA_WITH_AES_128_GCM_SHA256 )EOF"; TestUtilOptions failing_test_options(failing_client_ctx_yaml, server_ctx_yaml, false, GetParam()); testUtil(failing_test_options.setPrivateKeyMethodExpected(true) .setExpectedServerCloseEvent(Network::ConnectionEvent::LocalClose) .setExpectedServerStats("ssl.connection_error") .setExpectedTransportFailureReasonContains("system library") .setNotExpectedClientStats("ssl.connection_error")); }
0
275,971
uECC_VLI_API void uECC_vli_modSquare(uECC_word_t *result, const uECC_word_t *left, const uECC_word_t *mod, wordcount_t num_words) { uECC_vli_modMult(result, left, left, mod, num_words); }
0
369,430
*/ static void io_submit_state_start(struct io_submit_state *state, unsigned int max_ios) { state->plug_started = false; state->need_plug = max_ios > 2; state->submit_nr = max_ios; /* set only head, no need to init link_last in advance */ state->link.head = NULL;
0
473,943
utf16be_get_case_fold_codes_by_str(OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[], OnigEncoding enc) { return onigenc_unicode_get_case_fold_codes_by_str(enc, flag, p, end, items); }
0