functionSource
stringlengths
20
97.4k
CWE-119
bool
2 classes
CWE-120
bool
2 classes
CWE-469
bool
2 classes
CWE-476
bool
2 classes
CWE-other
bool
2 classes
combine
int64
0
1
ntfs_flush_dcache_pages(struct page **pages, unsigned nr_pages) { BUG_ON(!nr_pages); /* * Warning: Do not do the decrement at the same time as the call to * flush_dcache_page() because it is a NULL macro on i386 and hence the * decrement never happens so the loop never terminates. */ do { --nr_pages; flush_dcache_page(pages[nr_pages]); } while (nr_pages > 0); }
false
false
false
false
false
0
Java_org_gdal_osr_osrJNI_GetWellKnownGeogCSAsWKT_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jstring jarg1, jobjectArray jarg2) { jint jresult = 0 ; char *arg1 = (char *) 0 ; char **arg2 = (char **) 0 ; char *argout2 = 0 ; OGRErr result; (void)jenv; (void)jcls; arg1 = 0; if (jarg1) { arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); if (!arg1) return 0; } { /* %typemap(in) (char **argout2) */ arg2 = &argout2; } { if (!arg1) { { SWIG_JavaException(jenv, SWIG_ValueError, "Received a NULL pointer."); return 0; }; } } result = (OGRErr)GetWellKnownGeogCSAsWKT((char const *)arg1,arg2); { /* %typemap(out) OGRErr */ if (result != 0 && bUseExceptions) { SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, OGRErrMessages(result)); return 0; } jresult = (jint)result; } { /* %typemap(argout) (char **argout) */ jstring temp_string; if(jarg2 != NULL && (int)jenv->GetArrayLength(jarg2) >= 1) { temp_string = jenv->NewStringUTF(argout2); jenv->SetObjectArrayElement(jarg2, 0, temp_string); jenv->DeleteLocalRef(temp_string); } } if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1); { /* %typemap(freearg) (char **argout) */ if(arg2) { CPLFree((void *)argout2); } } { /* %typemap(ret) OGRErr */ } return jresult; }
false
false
false
false
false
0
chain_new_from_iterable(PyTypeObject *type, PyObject *arg) { PyObject *source; source = PyObject_GetIter(arg); if (source == NULL) return NULL; return chain_new_internal(type, source); }
false
false
false
false
false
0
CopyTABFeatureBase(TABFeature *poDestFeature) { /*----------------------------------------------------------------- * Copy fields only if OGRFeatureDefn is the same *----------------------------------------------------------------*/ OGRFeatureDefn *poThisDefnRef = GetDefnRef(); if (poThisDefnRef == poDestFeature->GetDefnRef()) { for( int i = 0; i < poThisDefnRef->GetFieldCount(); i++ ) { poDestFeature->SetField( i, GetRawFieldRef( i ) ); } } /*----------------------------------------------------------------- * Copy the geometry *----------------------------------------------------------------*/ poDestFeature->SetGeometry( GetGeometryRef() ); double dXMin, dYMin, dXMax, dYMax; GetMBR(dXMin, dYMin, dXMax, dYMax); poDestFeature->SetMBR(dXMin, dYMin, dXMax, dYMax); GInt32 nXMin, nYMin, nXMax, nYMax; GetIntMBR(nXMin, nYMin, nXMax, nYMax); poDestFeature->SetIntMBR(nXMin, nYMin, nXMax, nYMax); // m_nMapInfoType is not carried but it is not required anyways. // it will default to TAB_GEOM_NONE }
false
false
false
false
false
0
_PLfuse_setxattr (const char *file, const char *name, const char *buf, size_t buflen, int flags) { #endif int rv; FUSE_CONTEXT_PRE; DEBUGf("setxattr begin\n"); ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newSVpv(file,0))); XPUSHs(sv_2mortal(newSVpv(name,0))); XPUSHs(sv_2mortal(newSVpvn(buf,buflen))); XPUSHs(sv_2mortal(newSViv(flags))); PUTBACK; rv = call_sv(MY_CXT.callback[21],G_SCALAR); SPAGAIN; rv = (rv ? POPi : 0); FREETMPS; LEAVE; PUTBACK; DEBUGf("setxattr end: %i\n",rv); FUSE_CONTEXT_POST; return rv; }
false
false
false
false
false
0
AddMark(int line, int markerNum, int lines) { handleCurrent++; if (!markers.Length()) { // No existing markers so allocate one element per line markers.InsertValue(0, lines, 0); } if (line >= markers.Length()) { return -1; } if (!markers[line]) { // Need new structure to hold marker handle markers[line] = new MarkerHandleSet(); } markers[line]->InsertHandle(handleCurrent, markerNum); return handleCurrent; }
false
false
false
false
false
0
multiplexer_setWakeupThreshold (Multiplexer* self, guint seconds, guint waitms, GError** error) { guint _tmp0_ = 0U; guint _tmp4_ = 0U; guint _tmp5_ = 0U; g_return_if_fail (self != NULL); _tmp0_ = seconds; if (_tmp0_ == ((guint) 0)) { _g_timer_destroy0 (self->priv->idle_wakeup_timer); self->priv->idle_wakeup_timer = NULL; } else { GTimer* _tmp1_ = NULL; _tmp1_ = self->priv->idle_wakeup_timer; if (_tmp1_ == NULL) { GTimer* _tmp2_ = NULL; GTimer* _tmp3_ = NULL; _tmp2_ = g_timer_new (); _g_timer_destroy0 (self->priv->idle_wakeup_timer); self->priv->idle_wakeup_timer = _tmp2_; _tmp3_ = self->priv->idle_wakeup_timer; g_timer_start (_tmp3_); } } _tmp4_ = seconds; self->priv->idle_wakeup_threshold = _tmp4_; _tmp5_ = waitms; self->priv->idle_wakeup_waitms = _tmp5_; }
false
false
false
false
false
0
set_toolbar_hide(bool hide) { toolbar_hide = hide; if(toolbar_hide){ toolbar->hide(); menu_tool_box->hide(); } else{ toolbar->show(); menu_tool_box->show(); } Glib::RefPtr<Gtk::ToggleAction> menu = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("ViewShowToolbar")); menu->set_active(toolbar_hide); }
false
false
false
false
false
0
neb2_post_level_init() { int idx; // standalone servers can bail here if (Game_mode & GM_STANDALONE_SERVER) { return; } // if the mission is not a fullneb mission, skip if ( !((The_mission.flags & MISSION_FLAG_FULLNEB) || Nebula_sexp_used) ) { Neb2_render_mode = NEB2_RENDER_NONE; Neb2_awacs = -1.0f; return; } if ( (Cmdline_nohtl || Fred_running) && (The_mission.flags & MISSION_FLAG_FULLNEB) ) { // by default we'll use pof rendering Neb2_render_mode = NEB2_RENDER_POF; stars_set_background_model(BACKGROUND_MODEL_FILENAME, Neb2_texture_name); stars_set_background_orientation(); } else { // Set a default colour just in case something goes wrong Neb2_fog_color_r = 30; Neb2_fog_color_g = 52; Neb2_fog_color_b = 157; // OK, lets try something a bit more interesting if (strlen(Neb2_texture_name)) { Neb2_htl_fog_data = new ubyte[768]; if ((Neb2_htl_fog_data != NULL) && (pcx_read_header(Neb2_texture_name, NULL, NULL, NULL, NULL, Neb2_htl_fog_data) == PCX_ERROR_NONE)) { // based on the palette, get an average color value (this doesn't really account for actual pixel usage though) ushort r = 0, g = 0, b = 0, pcount = 0; for (idx = 0; idx < 768; idx += 3) { if (Neb2_htl_fog_data[idx] || Neb2_htl_fog_data[idx+1] || Neb2_htl_fog_data[idx+2]) { r = r + Neb2_htl_fog_data[idx]; g = g + Neb2_htl_fog_data[idx+1]; b = b + Neb2_htl_fog_data[idx+2]; pcount++; } } if (pcount > 0) { Neb2_fog_color_r = (ubyte)(r / pcount); Neb2_fog_color_g = (ubyte)(g / pcount); Neb2_fog_color_b = (ubyte)(b / pcount); } else { // it's just black Neb2_fog_color_r = Neb2_fog_color_g = Neb2_fog_color_b = 0; } // done, now free up the palette data if ( Neb2_htl_fog_data != NULL ) { delete[] Neb2_htl_fog_data; Neb2_htl_fog_data = NULL; } } } Neb2_render_mode = NEB2_RENDER_HTL; } // load in all nebula bitmaps for (idx=0; idx<Neb2_poof_count; idx++) { if (Neb2_poofs[idx] < 0) { Neb2_poofs[idx] = bm_load(Neb2_poof_filenames[idx]); } } pneb_tried = 0; pneb_tossed_alpha = 0; pneb_tossed_dot = 0; neb_tried = 0; neb_tossed_alpha = 0; neb_tossed_dot = 0; neb_tossed_count = 0; // setup proper fogging values Neb_backg_fog_near = NEB_BACKG_FOG_NEAR_D3D; Neb_backg_fog_far = NEB_BACKG_FOG_FAR_D3D; // regen the nebula neb2_eye_changed(); // if we are going to use fullneb, but aren't fullneb yet, then be sure to reset our mode if ( !(The_mission.flags & MISSION_FLAG_FULLNEB) ) { Neb2_render_mode = NEB2_RENDER_NONE; Neb2_awacs = -1.0f; } }
false
false
false
false
false
0
bdrv_pwrite_em(BlockDriverState *bs, int64_t offset, const uint8_t *buf, int count1) { uint8_t tmp_buf[SECTOR_SIZE]; int len, nb_sectors, count; int64_t sector_num; count = count1; /* first write to align to sector start */ len = (SECTOR_SIZE - offset) & (SECTOR_SIZE - 1); if (len > count) len = count; sector_num = offset >> SECTOR_BITS; if (len > 0) { if (bdrv_read(bs, sector_num, tmp_buf, 1) < 0) return -EIO; memcpy(tmp_buf + (offset & (SECTOR_SIZE - 1)), buf, len); if (bdrv_write(bs, sector_num, tmp_buf, 1) < 0) return -EIO; count -= len; if (count == 0) return count1; sector_num++; buf += len; } /* write the sectors "in place" */ nb_sectors = count >> SECTOR_BITS; if (nb_sectors > 0) { if (bdrv_write(bs, sector_num, buf, nb_sectors) < 0) return -EIO; sector_num += nb_sectors; len = nb_sectors << SECTOR_BITS; buf += len; count -= len; } /* add data from the last sector */ if (count > 0) { if (bdrv_read(bs, sector_num, tmp_buf, 1) < 0) return -EIO; memcpy(tmp_buf, buf, count); if (bdrv_write(bs, sector_num, tmp_buf, 1) < 0) return -EIO; } return count1; }
false
true
false
false
false
1
a8293_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct a8293_dev *dev; struct a8293_platform_data *pdata = client->dev.platform_data; struct dvb_frontend *fe = pdata->dvb_frontend; int ret; u8 buf[2]; dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { ret = -ENOMEM; goto err; } dev->client = client; /* check if the SEC is there */ ret = i2c_master_recv(client, buf, 2); if (ret < 0) goto err_kfree; /* override frontend ops */ fe->ops.set_voltage = a8293_set_voltage; fe->sec_priv = dev; i2c_set_clientdata(client, dev); dev_info(&client->dev, "Allegro A8293 SEC successfully attached\n"); return 0; err_kfree: kfree(dev); err: dev_dbg(&client->dev, "failed=%d\n", ret); return ret; }
false
false
false
false
false
0
mxt_get_object(struct mxt_data *data, u8 type) { struct mxt_object *object; int i; for (i = 0; i < data->info.object_num; i++) { object = data->object_table + i; if (object->type == type) return object; } dev_warn(&data->client->dev, "Invalid object type T%u\n", type); return NULL; }
false
false
false
false
false
0
cr_statement_at_page_rule_set_declarations (CRStatement * a_this, CRDeclaration * a_decl_list) { g_return_val_if_fail (a_this && a_this->type == AT_PAGE_RULE_STMT && a_this->kind.page_rule, CR_BAD_PARAM_ERROR); if (a_this->kind.page_rule->decl_list) { cr_declaration_unref (a_this->kind.page_rule->decl_list); } a_this->kind.page_rule->decl_list = a_decl_list; if (a_decl_list) { cr_declaration_ref (a_decl_list); } return CR_OK; }
false
false
false
false
false
0
autodir_option_timeout( char ch, char *arg, int valid ) { if( ! valid ) autodir.time_out = DFLT_TIME_OUT; else if( ! string_to_number( arg, &autodir.time_out ) ) msglog( MSG_FATAL, "invalid argument for timeout -%c option", ch ); }
false
false
false
false
false
0
convert_schema_name(text *schemaname) { char *nspname; Oid oid; nspname = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(schemaname))); oid = GetSysCacheOid(NAMESPACENAME, CStringGetDatum(nspname), 0, 0, 0); if (!OidIsValid(oid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_SCHEMA), errmsg("schema \"%s\" does not exist", nspname))); return oid; }
false
false
false
false
false
0
init_timer (Uint32 dt) { inittimer_gl117 += dt; initsynchrotimer += dt; if (initsynchrotimer > 20) { initsynchrotimer -= 20; dt = 20; } else return; int r = myrandom (100); if (r == 50) r = myrandom (100); // do not optimize this: random number generator initialization tl.x = 6.0 * pow (1.5, -(5 + tl.z)); tl.y = (tl.z + 3) * (tl.z + 3) * 0.02 - 0.8; //0.9 * tl.x; tl.z += 0.14; tl2.y = 0.3F; if (initexplode1 == -1 && tl2.z < 3) { tl2.z += 0.25; } if (tl2.z < 3) { rot2.b -= 20; if (rot2.b < 0) rot2.b += 360; } if (tl.z > -4.0) { rot.b ++; } if (inittimer == 0) { memset (heat, 0, maxfx * maxfy * sizeof (int)); memset (heat2, 0, maxfx * maxfy * sizeof (int)); } genFireLine (); proceedFire (); if (inittimer >= 75) { initexplode1 = -1; } if (inittimer >= 350) { initexplode += dt; } if (inittimer >= 400) { init_key (27, 0, 0); // switch to menu } inittimer ++; #ifdef USE_GLUT glutPostRedisplay(); #else sdldisplay = true; #endif }
false
false
false
false
false
0
print_ni_name(struct iface_data *idata, const u_char *pktdata, struct pcap_pkthdr * pkthdr){ struct ether_header *pkt_ether; struct ip6_hdr *pkt_ipv6; struct icmp6_nodeinfo *pkt_ni; unsigned char *pkt_end; struct ni_reply_name *pkt_nidata; unsigned char *start, *next; pkt_ether = (struct ether_header *) pktdata; pkt_ipv6 = (struct ip6_hdr *)((char *) pkt_ether + idata->linkhsize); pkt_ni= (struct icmp6_nodeinfo *) ((char *) pkt_ipv6 + sizeof(struct ip6_hdr)); pkt_end = (unsigned char *) pktdata + pkthdr->caplen; if( pkt_end > ((unsigned char *)pkt_ni + pkt_ipv6->ip6_plen) ) pkt_end = (unsigned char *)pkt_ni + pkt_ipv6->ip6_plen; if(!is_eq_in6_addr(&(pkt_ipv6->ip6_dst), &(idata->srcaddr))) return 0; if(inet_ntop(AF_INET6, &(pkt_ipv6->ip6_src), pv6addr, sizeof(pv6addr)) == NULL){ if(idata->verbose_f) puts("inet_ntop(): Error converting IPv6 Address to presentation format"); return(-1); } printf("Response from: %s\n", pv6addr); switch(pkt_ni->ni_code){ case 0: puts("\tCode: 0 (Successful reply)"); break; case 1: puts("\tCode: 1 (Node refuses to supply the answer)"); break; case 2: puts("\tCode: 2 (Qtype unknown to the responder)"); break; default: printf("\tCode: %u (Qtype unknown)\n", pkt_ni->ni_code); break; } pkt_nidata= (struct ni_reply_name *) ((char *)pkt_ni + sizeof(struct icmp6_nodeinfo)); start= (unsigned char *) pkt_nidata; next= (unsigned char *) &(pkt_nidata->ni_name_name); while(next != NULL && dns_decode(start, pkt_end-start, next, domain, sizeof(domain), &next) == 0){ printf("\t%s (TTL: %lu%s)\n", domain, (LUI) pkt_nidata->ni_name_ttl,\ (pkt_nidata->ni_name_ttl==0xffffffff)?" (infinity)":""); } puts(""); return(0); }
false
false
false
false
false
0
savenwgame( tnstream* strm, const GameMap* gamemap ) { PackageManager::storeData( gamemap ); spfld = const_cast<GameMap*>(gamemap); // yes, this is bad, but spfld can't be made constant because it is also used for loading stream = strm; stream->writepchar ( getFullVersionString() ); // description is not used any more stream->writeWord ( fileterminator ); stream->writeInt ( actnetworkversion ); writemap (); writemessages(); stream->writeInt ( actnetworkversion ); writefields ( ); writedissections(); if ( spfld->replayinfo ) spfld->replayinfo->write ( *stream ); // the AI must be the last data of the file writeAI(); stream->writeInt ( actnetworkversion ); spfld = NULL; return 0; }
false
false
false
false
false
0
gmbus_wait_hw_status(struct drm_i915_private *dev_priv, u32 gmbus2_status, u32 gmbus4_irq_en) { int i; u32 gmbus2 = 0; DEFINE_WAIT(wait); if (!HAS_GMBUS_IRQ(dev_priv->dev)) gmbus4_irq_en = 0; /* Important: The hw handles only the first bit, so set only one! Since * we also need to check for NAKs besides the hw ready/idle signal, we * need to wake up periodically and check that ourselves. */ I915_WRITE(GMBUS4, gmbus4_irq_en); for (i = 0; i < msecs_to_jiffies_timeout(50); i++) { prepare_to_wait(&dev_priv->gmbus_wait_queue, &wait, TASK_UNINTERRUPTIBLE); gmbus2 = I915_READ_NOTRACE(GMBUS2); if (gmbus2 & (GMBUS_SATOER | gmbus2_status)) break; schedule_timeout(1); } finish_wait(&dev_priv->gmbus_wait_queue, &wait); I915_WRITE(GMBUS4, 0); if (gmbus2 & GMBUS_SATOER) return -ENXIO; if (gmbus2 & gmbus2_status) return 0; return -ETIMEDOUT; }
false
false
false
false
false
0
gtf_visitor_feature_node(GtNodeVisitor *nv, GtFeatureNode *fn, GtError *err) { GtGTFVisitor *gtf_visitor; int had_err; gt_error_check(err); gtf_visitor = gtf_visitor_cast(nv); had_err = gt_feature_node_traverse_children(fn, gtf_visitor, gtf_show_feature_node, false, err); return had_err; }
false
false
false
false
false
0
list_all_inner_loop_index(Block *block, IntSet index_list){ Block *bpt; for(bpt = block; bpt != NULL; bpt = bpt->next){ if (bpt->inner != NULL){ list_all_inner_loop_index(bpt->inner, index_list); } if (bpt->kind == LOOP || bpt->kind == DOALL || bpt->kind == DOACR || bpt->kind == DOSUM ) { add1_IntSet(index_list, get_loop_index_operand(bpt)->entry); } } }
false
false
false
false
false
0
buildPreBlockStatements(vector<const string*>* preBlockStatements, int fileType) { preBlockStatements->push_back(&AS_CLASS); if (fileType == C_TYPE) { preBlockStatements->push_back(&AS_STRUCT); preBlockStatements->push_back(&AS_UNION); preBlockStatements->push_back(&AS_NAMESPACE); } if (fileType == JAVA_TYPE) { preBlockStatements->push_back(&AS_INTERFACE); preBlockStatements->push_back(&AS_THROWS); } if (fileType == SHARP_TYPE) { preBlockStatements->push_back(&AS_INTERFACE); preBlockStatements->push_back(&AS_NAMESPACE); preBlockStatements->push_back(&AS_WHERE); preBlockStatements->push_back(&AS_STRUCT); } sort(preBlockStatements->begin(), preBlockStatements->end(), sortOnName); }
false
false
false
false
false
0
k_version(const char** extra, const char** git) { uint32_t maj = 0, min = 0, plev = 0; const char* s = __libk_version_string; const char* e = 0, *g = 0; while (*s) { if (*s == '-') e = s+1; if (*s == '+') g = s+1; s++; } if (git) { memset(__libk_git_ver, 0, 256); if (g) strncpy(__libk_git_ver, g, 255); *git = __libk_git_ver; } if (extra) { memset(__libk_extra_ver, 0, 256); if (e) strncpy(__libk_extra_ver, e, 255); char* ms = __libk_extra_ver; while (*ms) { if (*ms == '+') { *ms = 0; break; } ms++; } *extra = __libk_extra_ver; } sscanf(__libk_version_string, "%u.%u.%u", &maj, &min, &plev); return (maj*10000) + (min*100) + plev; }
false
false
false
false
false
0
CollectGarbage(AllocationSpace space, GarbageCollector collector) { // The VM is in the GC state until exiting this function. VMState state(GC); #ifdef DEBUG // Reset the allocation timeout to the GC interval, but make sure to // allow at least a few allocations after a collection. The reason // for this is that we have a lot of allocation sequences and we // assume that a garbage collection will allow the subsequent // allocation attempts to go through. allocation_timeout_ = Max(6, FLAG_gc_interval); #endif bool next_gc_likely_to_collect_more = false; { GCTracer tracer; GarbageCollectionPrologue(); // The GC count was incremented in the prologue. Tell the tracer about // it. tracer.set_gc_count(gc_count_); // Tell the tracer which collector we've selected. tracer.set_collector(collector); HistogramTimer* rate = (collector == SCAVENGER) ? &Counters::gc_scavenger : &Counters::gc_compactor; rate->Start(); next_gc_likely_to_collect_more = PerformGarbageCollection(collector, &tracer); rate->Stop(); GarbageCollectionEpilogue(); } #ifdef ENABLE_LOGGING_AND_PROFILING if (FLAG_log_gc) HeapProfiler::WriteSample(); #endif return next_gc_likely_to_collect_more; }
false
false
false
false
false
0
send_blast(unsigned int delay ) { common_flow_header_t *header; nfprof_t profile_data; int i, ret; u_long usec, sec; double fps; peer.send_buffer = malloc(1400); if ( !peer.send_buffer ) { perror("Memory allocation error"); close(peer.sockfd); return; } header = (common_flow_header_t *)peer.send_buffer; header->version = htons(255); nfprof_start(&profile_data); for ( i = 0; i < 65535; i++ ) { header->count = htons(i); ret = sendto(peer.sockfd, peer.send_buffer, 1400, 0, (struct sockaddr *)&peer.addr, peer.addrlen); if ( ret < 0 || ret != 1400 ) { perror("Error sending data"); } if ( delay ) { // sleep as specified usleep(delay); } } nfprof_end(&profile_data, 8*65535*1400); usec = profile_data.used.ru_utime.tv_usec + profile_data.used.ru_stime.tv_usec; sec = profile_data.used.ru_utime.tv_sec + profile_data.used.ru_stime.tv_sec; if (usec > 1000000) usec -= 1000000, ++sec; if (profile_data.tend.tv_usec < profile_data.tstart.tv_usec) profile_data.tend.tv_usec += 1000000, --profile_data.tend.tv_sec; usec = profile_data.tend.tv_usec - profile_data.tstart.tv_usec; sec = profile_data.tend.tv_sec - profile_data.tstart.tv_sec; fps = (double)profile_data.numflows / ((double)sec + ((double)usec/1000000)); fprintf(stdout, "Wall: %lu.%-3.3lus bps: %-10.1f\n", sec, usec/1000, fps); }
false
false
false
false
true
1
score_full_house_kismet(int field) { int i = find_n_of_a_kind (3, 0); if (i) { if (find_n_of_a_kind (2, i) || find_n_of_a_kind (5, 0)) return 15 + add_dice (); } return 0; }
false
false
false
false
false
0
LogAllLocked() { RAW_CHECK(LockIsHeld(), "should be held (by this thread)"); RAW_LOG(INFO, "List of regions:"); uintptr_t previous = 0; for (RegionSet::const_iterator r = regions_->begin(); r != regions_->end(); ++r) { RAW_LOG(INFO, "Memory region 0x%" PRIxPTR "..0x%" PRIxPTR " " "from 0x%" PRIxPTR " stack=%d", r->start_addr, r->end_addr, r->caller(), r->is_stack); RAW_CHECK(previous < r->end_addr, "wow, we messed up the set order"); // this must be caused by uncontrolled recursive operations on regions_ previous = r->end_addr; } RAW_LOG(INFO, "End of regions list"); }
false
false
false
false
false
0
_e_smart_reconfigure(Evas_Object *obj) { Smart_Data *sd = evas_object_smart_data_get(obj); if (sd->idle_enter) return; sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj); }
false
false
false
false
false
0
liblo10k1_con_del(liblo10k1_connection_t *conn, int type, int patch, int io, int *ci) { ld10k1_fnc_connection_t connection_fnc; int err; int conn_id; connection_fnc.what = FNC_CONNECTION_DEL; connection_fnc.from_type = type; connection_fnc.from_patch = patch; connection_fnc.from_io = io; connection_fnc.to_type = -1; connection_fnc.to_patch = -1; connection_fnc.to_io = -1; if ((err = send_request(*conn, FNC_CONNECTION_DEL, &connection_fnc, sizeof(ld10k1_fnc_connection_t))) < 0) return err; if ((err = receive_response_data_check(*conn, &conn_id, sizeof(conn_id))) < 0) return err; if (ci) *ci = conn_id; return 0; }
false
false
false
false
false
0
Getlogin(void) { #ifdef HAVE_GETLOGIN { char *user; if ((user = getlogin()) != NULL) return user; } #endif #ifdef HAVE_GETPWUID { struct passwd *pw; if ((pw = getpwuid(getuid())) == NULL) return NULL; else return pw->pw_name; } #endif return NULL; }
false
false
false
false
false
0
cx18_streams_register(struct cx18 *cx) { int type; int err; int ret = 0; /* Register V4L2 devices */ for (type = 0; type < CX18_MAX_STREAMS; type++) { err = cx18_reg_dev(cx, type); if (err && ret == 0) ret = err; } if (ret == 0) return 0; /* One or more streams could not be initialized. Clean 'em all up. */ cx18_streams_cleanup(cx, 1); return ret; }
false
false
false
false
false
0
dapodometerpoints(Dapodometer* odom) { unsigned int i,rank = odom->rank; size_t count = 1; DCEslice* slice = odom->slices; for(i=0;i<rank;i++,slice++) { size_t slicecount = (slice->length/slice->stride); count *= slicecount; } return count; }
false
false
false
false
false
0
WriteVarint32(uint32 value) { if (buffer_size_ >= kMaxVarint32Bytes) { // Fast path: We have enough bytes left in the buffer to guarantee that // this write won't cross the end, so we can skip the checks. uint8* target = buffer_; uint8* end = WriteVarint32FallbackToArrayInline(value, target); int size = end - target; Advance(size); } else { // Slow path: This write might cross the end of the buffer, so we // compose the bytes first then use WriteRaw(). uint8 bytes[kMaxVarint32Bytes]; int size = 0; while (value > 0x7F) { bytes[size++] = (static_cast<uint8>(value) & 0x7F) | 0x80; value >>= 7; } bytes[size++] = static_cast<uint8>(value) & 0x7F; WriteRaw(bytes, size); } }
false
false
false
false
false
0
sample_endpoints(ESL_RANDOMNESS *r, const P7_PROFILE *gm, int *ret_kstart, int *ret_kend) { float *pstart = NULL; int k; int kstart, kend; int status; /* We have to backcalculate a probability distribution from the * lod B->Mk scores in a local model; this is a little time consuming, * but we don't have to do it often. */ ESL_ALLOC(pstart, sizeof(float) * (gm->M+1)); pstart[0] = 0.0f; for (k = 1; k <= gm->M; k++) pstart[k] = exp(p7P_TSC(gm, k-1, p7P_BM)) * (gm->M - k + 1); /* multiply p_ij by the number of exits j */ kstart = esl_rnd_FChoose(r, pstart, gm->M+1); /* sample the starting position from that distribution */ kend = kstart + esl_rnd_Roll(r, gm->M-kstart+1); /* and the exit uniformly from possible exits for it */ free(pstart); *ret_kstart = kstart; *ret_kend = kend; return eslOK; ERROR: if (pstart != NULL) free(pstart); *ret_kstart = 0; *ret_kend = 0; return status; }
false
false
false
false
false
0
xsh_irplib_imagelist_get_clean_mean_levels(const cpl_imagelist* iml, const double kappa, const int nclip, const double tolerance) { const cpl_image* img=NULL; int size=0; int i=0; cpl_vector* levels=NULL; double* pval=NULL; double mean=0; double stdev=0; cpl_error_ensure(iml != NULL, CPL_ERROR_NULL_INPUT, return(levels), "Null input image list"); cpl_error_ensure(kappa >= 0, CPL_ERROR_ILLEGAL_INPUT, return(levels), "Must be kappa>0"); size=cpl_imagelist_get_size(iml); levels=cpl_vector_new(size); pval=cpl_vector_get_data(levels); for(i=0;i<size;i++) { img=cpl_imagelist_get_const(iml,i); xsh_ksigma_clip(img,1,1, cpl_image_get_size_x(img), cpl_image_get_size_y(img), nclip,kappa,tolerance,&mean,&stdev); //cpl_msg_info(cpl_func,"Ima %d mean level: %g",i+1,mean); pval[i]=mean; } return levels; }
false
false
false
false
false
0
GetConfigurations(std::vector<std::string>& configs, bool single) const { if(this->LocalGenerator->GetGlobalGenerator()->IsMultiConfig()) { if(const char* configTypes = this->GetDefinition("CMAKE_CONFIGURATION_TYPES")) { cmSystemTools::ExpandListArgument(configTypes, configs); } return 0; } else { const char* buildType = this->GetDefinition("CMAKE_BUILD_TYPE"); if(single && buildType && *buildType) { configs.push_back(buildType); } return buildType; } }
false
false
false
false
false
0
xmlSchemaCheckGroupDefCircular(xmlSchemaModelGroupDefPtr item, xmlSchemaParserCtxtPtr ctxt) { /* * Schema Component Constraint: Model Group Correct * 2 Circular groups are disallowed. That is, within the {particles} * of a group there must not be at any depth a particle whose {term} * is the group itself. */ if ((item == NULL) || (item->type != XML_SCHEMA_TYPE_GROUP) || (item->children == NULL)) return; { xmlSchemaTreeItemPtr circ; circ = xmlSchemaGetCircModelGrDefRef(item, item->children->children); if (circ != NULL) { xmlChar *str = NULL; /* * TODO: The error report is not adequate: this constraint * is defined for model groups but not definitions, but since * there cannot be any circular model groups without a model group * definition (if not using a construction API), we check those * defintions only. */ xmlSchemaPCustomErr(ctxt, XML_SCHEMAP_MG_PROPS_CORRECT_2, NULL, WXS_ITEM_NODE(circ), "Circular reference to the model group definition '%s' " "defined", xmlSchemaFormatQName(&str, item->targetNamespace, item->name)); FREE_AND_NULL(str) /* * NOTE: We will cut the reference to avoid further * confusion of the processor. This is a fatal error. */ circ->children = NULL; } } }
false
false
false
false
false
0
dump() const { return "<number>" + QString::number( m_value ) + "</number>"; }
false
false
false
false
false
0
mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) { struct mmc_command cmd = {0}; int i, err = 0; BUG_ON(!host); cmd.opcode = SD_APP_OP_COND; if (mmc_host_is_spi(host)) cmd.arg = ocr & (1 << 30); /* SPI only defines one bit */ else cmd.arg = ocr; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR; for (i = 100; i; i--) { err = mmc_wait_for_app_cmd(host, NULL, &cmd, MMC_CMD_RETRIES); if (err) break; /* if we're just probing, do a single pass */ if (ocr == 0) break; /* otherwise wait until reset completes */ if (mmc_host_is_spi(host)) { if (!(cmd.resp[0] & R1_SPI_IDLE)) break; } else { if (cmd.resp[0] & MMC_CARD_BUSY) break; } err = -ETIMEDOUT; mmc_delay(10); } if (!i) pr_err("%s: card never left busy state\n", mmc_hostname(host)); if (rocr && !mmc_host_is_spi(host)) *rocr = cmd.resp[0]; return err; }
false
false
false
false
false
0
PKIX_PL_X500Name_CreateFromCERTName( SECItem *derName, CERTName *name, PKIX_PL_X500Name **pName, void *plContext) { PLArenaPool *arena = NULL; SECStatus rv = SECFailure; PKIX_PL_X500Name *x500Name = NULL; PKIX_ENTER(X500NAME, "PKIX_PL_X500Name_CreateFromCERTName"); PKIX_NULLCHECK_ONE(pName); if (derName == NULL && name == NULL) { PKIX_ERROR(PKIX_NULLARGUMENT); } arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); if (arena == NULL) { PKIX_ERROR(PKIX_OUTOFMEMORY); } PKIX_CHECK(PKIX_PL_Object_Alloc (PKIX_X500NAME_TYPE, sizeof (PKIX_PL_X500Name), (PKIX_PL_Object **)&x500Name, plContext), PKIX_COULDNOTCREATEX500NAMEOBJECT); x500Name->arena = arena; x500Name->nssDN.arena = NULL; if (derName != NULL) { rv = SECITEM_CopyItem(arena, &x500Name->derName, derName); if (rv == SECFailure) { PKIX_ERROR(PKIX_OUTOFMEMORY); } } if (name != NULL) { rv = CERT_CopyName(arena, &x500Name->nssDN, name); if (rv == SECFailure) { PKIX_ERROR(PKIX_CERTCOPYNAMEFAILED); } } else { rv = SEC_QuickDERDecodeItem(arena, &x500Name->nssDN, CERT_NameTemplate, &x500Name->derName); if (rv == SECFailure) { PKIX_ERROR(PKIX_SECQUICKDERDECODERFAILED); } } *pName = x500Name; cleanup: if (PKIX_ERROR_RECEIVED) { if (x500Name) { PKIX_PL_Object_DecRef((PKIX_PL_Object*)x500Name, plContext); } else if (arena) { PORT_FreeArena(arena, PR_FALSE); } } PKIX_RETURN(X500NAME); }
false
false
false
false
false
0
copytoks (int tindex, int ntokens) { int i; for (i = 0; i < ntokens; ++i) { addtok(dfa->tokens[tindex + i]); /* Update index into multibyte csets. */ if (MB_CUR_MAX > 1 && dfa->tokens[tindex + i] == MBCSET) dfa->multibyte_prop[dfa->tindex - 1] = dfa->multibyte_prop[tindex + i]; } }
false
false
false
false
false
0
handle_vector_size_attribute (tree *node, tree name, tree args, int ARG_UNUSED (flags), bool *no_add_attrs) { unsigned HOST_WIDE_INT vecsize, nunits; enum machine_mode orig_mode; tree type = *node, new_type, size; *no_add_attrs = true; size = TREE_VALUE (args); if (!host_integerp (size, 1)) { warning (OPT_Wattributes, "%qE attribute ignored", name); return NULL_TREE; } /* Get the vector size (in bytes). */ vecsize = tree_low_cst (size, 1); /* We need to provide for vector pointers, vector arrays, and functions returning vectors. For example: __attribute__((vector_size(16))) short *foo; In this case, the mode is SI, but the type being modified is HI, so we need to look further. */ while (POINTER_TYPE_P (type) || TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE || TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == OFFSET_TYPE) type = TREE_TYPE (type); /* Get the mode of the type being modified. */ orig_mode = TYPE_MODE (type); if ((!INTEGRAL_TYPE_P (type) && !SCALAR_FLOAT_TYPE_P (type) && !FIXED_POINT_TYPE_P (type)) || (!SCALAR_FLOAT_MODE_P (orig_mode) && GET_MODE_CLASS (orig_mode) != MODE_INT && !ALL_SCALAR_FIXED_POINT_MODE_P (orig_mode)) || !host_integerp (TYPE_SIZE_UNIT (type), 1) || TREE_CODE (type) == BOOLEAN_TYPE) { error ("invalid vector type for attribute %qE", name); return NULL_TREE; } if (vecsize % tree_low_cst (TYPE_SIZE_UNIT (type), 1)) { error ("vector size not an integral multiple of component size"); return NULL; } if (vecsize == 0) { error ("zero vector size"); return NULL; } /* Calculate how many units fit in the vector. */ nunits = vecsize / tree_low_cst (TYPE_SIZE_UNIT (type), 1); if (nunits & (nunits - 1)) { error ("number of components of the vector not a power of two"); return NULL_TREE; } new_type = build_vector_type (type, nunits); /* Build back pointers if needed. */ *node = lang_hooks.types.reconstruct_complex_type (*node, new_type); return NULL_TREE; }
false
false
false
false
false
0
tio_flush_nonblock(TFILE *fp) { struct timeval tv; fd_set fdset; int rv; /* prepare our filedescriptorset */ FD_ZERO(&fdset); FD_SET(fp->fd,&fdset); /* set the timeout to 0 to poll */ tv.tv_sec=0; tv.tv_usec=0; /* wait for activity */ rv=select(FD_SETSIZE,NULL,&fdset,NULL,&tv); /* check if any file descriptors were ready (timeout) or we were interrupted */ if ((rv==0)||((rv<0)&&(errno==EINTR))) return 0; /* any other errors? */ if (rv<0) return -1; /* so file descriptor will accept writes */ return tio_writebuf(fp); }
false
false
false
false
false
0
init_mad_qp(struct ib_mad_port_private *port_priv, struct ib_mad_qp_info *qp_info) { qp_info->port_priv = port_priv; init_mad_queue(qp_info, &qp_info->send_queue); init_mad_queue(qp_info, &qp_info->recv_queue); INIT_LIST_HEAD(&qp_info->overflow_list); spin_lock_init(&qp_info->snoop_lock); qp_info->snoop_table = NULL; qp_info->snoop_table_size = 0; atomic_set(&qp_info->snoop_count, 0); }
false
false
false
false
false
0
getDocDefaultLangDescription(std::string & s) { const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet(); UT_return_if_fail(pSS); pSS->getValueUTF8(XAP_STRING_ID_DLG_ULANG_DefaultLangLabel, s); s += m_docLang; }
false
false
false
false
false
0
__pci_complete_power_transition(struct pci_dev *dev, pci_power_t state) { int ret; if (state <= PCI_D0) return -EINVAL; ret = pci_platform_power_transition(dev, state); /* Power off the bridge may power off the whole hierarchy */ if (!ret && state == PCI_D3cold) __pci_bus_set_current_state(dev->subordinate, PCI_D3cold); return ret; }
false
false
false
false
false
0
encode(const std::string &uri) { string ret; const unsigned char *ptr = (const unsigned char *)uri.c_str(); ret.reserve(uri.length()); for (; *ptr ; ++ptr) { if (!safe[*ptr]) { char buf[5]; memset(buf, 0, 5); snprintf(buf, 5, "%%%X", (*ptr)); ret.append(buf); } else { ret += *ptr; } } return ret; }
false
false
false
false
false
0
prot_resettimeout(struct protstream *s) { assert(!s->write); s->timeout_mark = time(NULL) + s->read_timeout; return 0; }
false
false
false
false
false
0
mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, struct host_cmd_ds_command *resp) { struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg; struct mwifiex_rate_scope *rate_scope; struct mwifiex_ie_types_header *head; u16 tlv, tlv_buf_len, tlv_buf_left; u8 *tlv_buf; u32 i; tlv_buf = ((u8 *)rate_cfg) + sizeof(struct host_cmd_ds_tx_rate_cfg); tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*rate_cfg); while (tlv_buf_left >= sizeof(*head)) { head = (struct mwifiex_ie_types_header *)tlv_buf; tlv = le16_to_cpu(head->type); tlv_buf_len = le16_to_cpu(head->len); if (tlv_buf_left < (sizeof(*head) + tlv_buf_len)) break; switch (tlv) { case TLV_TYPE_RATE_SCOPE: rate_scope = (struct mwifiex_rate_scope *) tlv_buf; priv->bitmap_rates[0] = le16_to_cpu(rate_scope->hr_dsss_rate_bitmap); priv->bitmap_rates[1] = le16_to_cpu(rate_scope->ofdm_rate_bitmap); for (i = 0; i < sizeof(rate_scope->ht_mcs_rate_bitmap) / sizeof(u16); i++) priv->bitmap_rates[2 + i] = le16_to_cpu(rate_scope-> ht_mcs_rate_bitmap[i]); if (priv->adapter->fw_api_ver == MWIFIEX_FW_V15) { for (i = 0; i < ARRAY_SIZE(rate_scope-> vht_mcs_rate_bitmap); i++) priv->bitmap_rates[10 + i] = le16_to_cpu(rate_scope-> vht_mcs_rate_bitmap[i]); } break; /* Add RATE_DROP tlv here */ } tlv_buf += (sizeof(*head) + tlv_buf_len); tlv_buf_left -= (sizeof(*head) + tlv_buf_len); } priv->is_data_rate_auto = mwifiex_is_rate_auto(priv); if (priv->is_data_rate_auto) priv->data_rate = 0; else return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_TX_RATE_QUERY, HostCmd_ACT_GEN_GET, 0, NULL, false); return 0; }
false
false
false
false
false
0
av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len){ int i, j; j= ctx->len & 63; ctx->len += len; for( i = 0; i < len; i++ ){ ctx->block[j++] = src[i]; if( 64 == j ){ body(ctx->ABCD, (uint32_t*) ctx->block); j = 0; } } }
false
false
false
false
false
0
nn_SpatialConvolution_forward(lua_State *L) { THTensor *input = luaT_checkudata(L, 2, torch_Tensor_id); int kW = luaT_getfieldcheckint(L, 1, "kW"); int kH = luaT_getfieldcheckint(L, 1, "kH"); int dW = luaT_getfieldcheckint(L, 1, "dW"); int dH = luaT_getfieldcheckint(L, 1, "dH"); int nInputPlane = luaT_getfieldcheckint(L, 1, "nInputPlane"); int nOutputPlane = luaT_getfieldcheckint(L, 1, "nOutputPlane"); THTensor *weight = luaT_getfieldcheckudata(L, 1, "weight", torch_Tensor_id); THTensor *bias = luaT_getfieldcheckudata(L, 1, "bias", torch_Tensor_id); THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor_id); THTensor *outputPlane, *inputPlane, *weightPlane, *unfoldedInputPlane; int i, k; luaL_argcheck(L, input->nDimension == 3, 2, "3D tensor expected"); luaL_argcheck(L, input->size[2] == nInputPlane, 2, "invalid number of input planes"); luaL_argcheck(L, input->size[0] >= kW && input->size[1] >= kH, 2, "input image smaller than kernel size"); THTensor_resize3d(output, (input->size[0] - kW) / dW + 1, (input->size[1] - kH) / dH + 1, nOutputPlane); inputPlane = THTensor_new(); weightPlane = THTensor_new(); outputPlane = THTensor_new(); unfoldedInputPlane = THTensor_new(); for(k = 0; k < nOutputPlane; k++) { THTensor_select(outputPlane, output, 2, k); /* Initialize to the bias */ THTensor_fill(outputPlane, THTensor_get1d(bias, k)); /* Go! */ for(i = 0; i < nInputPlane; i++) { THTensor_select(inputPlane, input, 2, i); /* Get the good mask for (k,i) (k out, i in) */ THTensor_select(weightPlane, weight, 3, k); THTensor_select(weightPlane, NULL, 2, i); /* Get the input image */ THTensor_unfold(unfoldedInputPlane, inputPlane, 0, kW, dW); THTensor_unfold(unfoldedInputPlane, NULL, 1, kH, dH); THTensor_addT4dotT2(outputPlane, 1, unfoldedInputPlane, weightPlane); } } THTensor_free(inputPlane); THTensor_free(weightPlane); THTensor_free(outputPlane); THTensor_free(unfoldedInputPlane); return 1; }
false
false
false
false
false
0
cui_agent_set_selected_service(const char *path, const char *name) { g_free(service.path); service.path = g_strdup(path); g_free(service.name); if (name == NULL) service.name = g_strdup("Hidden"); else service.name = g_strdup(name); }
false
false
false
false
false
0
sanei_write_tiff_header (SANE_Frame format, int width, int height, int depth, int resolution, const char *icc_profile, FILE *ofp) { #ifdef __EMX__ /* OS2 - write in binary mode. */ _fsetmode(ofp, "b"); #endif switch (format) { case SANE_FRAME_RED: case SANE_FRAME_GREEN: case SANE_FRAME_BLUE: case SANE_FRAME_RGB: write_tiff_color_header (ofp, width, height, depth, resolution, icc_profile); break; default: if (depth == 1) write_tiff_bw_header (ofp, width, height, resolution); else write_tiff_grey_header (ofp, width, height, depth, resolution, icc_profile); break; } }
false
false
false
false
false
0
main(void) { int gridID, zaxisID1, zaxisID2, taxisID; int vlistID, varID1, varID2, streamID, tsID; int i, nmiss = 0; double lons[nlon] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330}; double lats[nlat] = {-75, -45, -15, 15, 45, 75}; double levs[nlev] = {101300, 92500, 85000, 50000, 20000}; double var1[nlon*nlat]; double var2[nlon*nlat*nlev]; // Create a regular lon/lat grid gridID = gridCreate(GRID_LONLAT, nlon*nlat); gridDefXsize(gridID, nlon); gridDefYsize(gridID, nlat); gridDefXvals(gridID, lons); gridDefYvals(gridID, lats); // Create a surface level Z-axis zaxisID1 = zaxisCreate(ZAXIS_SURFACE, 1); // Create a pressure level Z-axis zaxisID2 = zaxisCreate(ZAXIS_PRESSURE, nlev); zaxisDefLevels(zaxisID2, levs); // Create a variable list vlistID = vlistCreate(); // Define the variables varID1 = vlistDefVar(vlistID, gridID, zaxisID1, TIME_VARIABLE); varID2 = vlistDefVar(vlistID, gridID, zaxisID2, TIME_VARIABLE); // Define the variable names vlistDefVarName(vlistID, varID1, "varname1"); vlistDefVarName(vlistID, varID2, "varname2"); // Create a Time axis taxisID = taxisCreate(TAXIS_ABSOLUTE); // Assign the Time axis to the variable list vlistDefTaxis(vlistID, taxisID); // Create a dataset in netCDF format streamID = streamOpenWrite("example.nc", FILETYPE_NC); if ( streamID < 0 ) { fprintf(stderr, "%s\n", cdiStringError(streamID)); return(1); } // Assign the variable list to the dataset streamDefVlist(streamID, vlistID); // Loop over the number of time steps for ( tsID = 0; tsID < nts; tsID++ ) { // Set the verification date to 1985-01-01 + tsID taxisDefVdate(taxisID, 19850101+tsID); // Set the verification time to 12:00:00 taxisDefVtime(taxisID, 120000); // Define the time step streamDefTimestep(streamID, tsID); // Init var1 and var2 for ( i = 0; i < nlon*nlat; i++ ) var1[i] = 1.1; for ( i = 0; i < nlon*nlat*nlev; i++ ) var2[i] = 2.2; // Write var1 and var2 streamWriteVar(streamID, varID1, var1, nmiss); streamWriteVar(streamID, varID2, var2, nmiss); } // Close the output stream streamClose(streamID); // Destroy the objects vlistDestroy(vlistID); taxisDestroy(taxisID); zaxisDestroy(zaxisID1); zaxisDestroy(zaxisID2); gridDestroy(gridID); return 0; }
false
false
false
false
false
0
master(int m, ErrorHandler *errh) { AmfmMaster &master = _masters[m]; if (!master.loaded) { master.loaded = true; DirectoryMetricsFinder directory_finder(_directory); _finder->add_finder(&directory_finder); Metrics *afm = _finder->find_metrics(master.font_name); if (!afm) { if (errh) errh->error("%s: can't find AFM file for master `%s'", _font_name.c_str(), master.font_name.c_str()); } else if (!strcompat(afm->font_name(), master.font_name) || !strcompat(afm->family(), master.family) || !strcompat(afm->full_name(), master.full_name) || !strcompat(afm->version(), master.version)) { if (errh) errh->error("%s: AFM for master `%s' doesn't match AMFM", _font_name.c_str(), master.font_name.c_str()); } else if (!_sanity_afm) { master.afm = afm; _sanity_afm = afm; afm->use(); } else { PairProgram *sanity_pairp = _sanity_afm->pair_program(); PairProgram *pairp = afm->pair_program(); char buf[1024]; buf[0] = 0; if (afm->nglyphs() != _sanity_afm->nglyphs()) sprintf(buf, "glyph count (%d vs. %d)", afm->nglyphs(), _sanity_afm->nglyphs()); if (afm->nfd() != _sanity_afm->nfd()) sprintf(buf, "fd count (%d vs. %d)", afm->nfd(), _sanity_afm->nfd()); if (afm->nkv() != _sanity_afm->nkv()) sprintf(buf, "kv count (%d vs. %d)", afm->nkv(), _sanity_afm->nkv()); if (pairp->op_count() != sanity_pairp->op_count()) sprintf(buf, "pair op count (%d vs. %d)", pairp->op_count(), sanity_pairp->op_count()); if (!buf[0]) { master.afm = afm; afm->use(); } else if (errh) errh->error("%s: AFM for master `%s' failed sanity checks (%s)", _font_name.c_str(), master.font_name.c_str(), buf); } } return master.afm; }
false
false
false
false
false
0
method_84(const int *account, int *weight) { // exception "Ausnahme f. Sachkonten" if (9 == account[2]) return method_51_exception(account,weight); // Methode A number2Array("0000654320", weight); if (AccountNumberCheck::OK == algo01(11, weight, false, 10, account)) return AccountNumberCheck::OK; // Methode B if (AccountNumberCheck::OK == algo01(7, weight, false, 10, account)) return AccountNumberCheck::OK; // Methode C number2Array("0000212120", weight); return algo01(10, weight, false, 10, account); }
false
false
false
false
false
0
setoption(int flag, int val) { int i; for (i = 0; i < NOPTS; i++) if (optletters[i] == flag) { optlist[i] = val; if (val) { /* #%$ hack for ksh semantics */ if (flag == 'V') Eflag = 0; else if (flag == 'E') Vflag = 0; } return; } sh_error("Illegal option -%c", flag); /* NOTREACHED */ }
false
false
false
false
false
0
via_set_state(u32 devices, u8 state) { /* TODO: Can we enable/disable these devices? How? if (devices & VIA_LDVP0) if (devices & VIA_LDVP1) */ if (devices & VIA_DVP0) set_dvp0_state(state); if (devices & VIA_CRT) set_crt_state(state); if (devices & VIA_DVP1) set_dvp1_state(state); if (devices & VIA_LVDS1) set_lvds1_state(state); if (devices & VIA_LVDS2) set_lvds2_state(state); }
false
false
false
false
false
0
analyse_status(struct gnutella_node *n, int *code) { struct gnutella_socket *s = n->socket; const char *status; int ack_code; uint major = 0, minor = 0; const char *ack_message = ""; bool ack_ok = FALSE; bool incoming = (n->flags & NODE_F_INCOMING) ? TRUE : FALSE; const char *what = incoming ? "acknowledgment" : "reply"; socket_check(s); status = getline_str(s->getline); ack_code = http_status_parse(status, "GNUTELLA", &ack_message, &major, &minor); if (code) *code = ack_code; if (GNET_PROPERTY(node_debug) > 3) g_debug("%s: code=%d, message=\"%s\", proto=%u.%u", incoming ? "ACK" : "REPLY", ack_code, ack_message, major, minor); if (ack_code == -1) { if (GNET_PROPERTY(node_debug)) { if (incoming || 0 != strcmp(status, "GNUTELLA OK")) { g_warning("weird GNUTELLA %s status line from %s", what, host_addr_to_string(n->addr)); dump_hex(stderr, "Status Line", status, MIN(getline_length(s->getline), 80)); } else g_warning("node %s gave a 0.4 reply to our 0.6 HELLO, dropping", node_addr(n)); } hcache_add(HCACHE_UNSTABLE, n->addr, 0, "bad ack_code"); } else { ack_ok = TRUE; n->flags |= NODE_F_VALID; /* This is a Gnutella node */ } if (ack_ok && (major != n->proto_major || minor != n->proto_minor)) { if (GNET_PROPERTY(node_debug)) { if (incoming) g_warning("node %s handshaked at %d.%d and now acks at %d.%d, " "adjusting", host_addr_to_string(n->addr), n->proto_major, n->proto_minor, major, minor); else g_warning("node %s was sent %d.%d HELLO but supports %d.%d " "only, adjusting", host_addr_to_string(n->addr), n->proto_major, n->proto_minor, major, minor); } n->proto_major = major; n->proto_minor = minor; } /* * Is the connection OK? */ if (!ack_ok) { node_remove(n, _("Weird HELLO %s"), what); } else if (ack_code < 200 || ack_code >= 300) { if (ack_code == 401) { /* Unauthorized */ hcache_add(HCACHE_UNSTABLE, n->addr, 0, "unauthorized"); } if (ack_code == 503) { /* Busy */ hcache_add(HCACHE_BUSY, n->addr, 0, "ack_code 503"); } node_remove(n, _("HELLO %s error %d (%s)"), what, ack_code, ack_message); ack_ok = FALSE; } else if (!incoming && ack_code == 204) { node_remove(n, _("Shielded node")); ack_ok = FALSE; } if (GTA_NODE_REMOVING == n->status) { ack_ok = FALSE; } return ack_ok; }
false
false
false
false
false
0
git_attr_file__free(git_attr_file *file) { unsigned int i; git_attr_rule *rule; if (!file) return; git_vector_foreach(&file->rules, i, rule) git_attr_rule__free(rule); git_vector_free(&file->rules); if (file->pool_is_allocated) { git_pool_clear(file->pool); git__free(file->pool); } file->pool = NULL; git__free(file); }
false
false
false
false
false
0
event_base_loopbreak(struct event_base *event_base) { if (event_base == NULL) return (-1); EVBASE_ACQUIRE_LOCK(event_base, th_base_lock); event_base->event_break = 1; EVBASE_RELEASE_LOCK(event_base, th_base_lock); if (!EVBASE_IN_THREAD(event_base)) { return evthread_notify_base(event_base); } else { return (0); } }
false
false
false
false
false
0
wb_view_detach_from_workbook (WorkbookView *wbv) { g_return_if_fail (IS_WORKBOOK_VIEW (wbv)); if (wbv->wb) { workbook_detach_view (wbv); wbv->wb = NULL; wbv->current_sheet = NULL; } }
false
false
false
false
false
0
nautilus_icon_info_get_pixbuf_at_size (NautilusIconInfo *icon, gsize forced_size) { GdkPixbuf *pixbuf, *scaled_pixbuf; int w, h, s; double scale; pixbuf = nautilus_icon_info_get_pixbuf (icon); w = gdk_pixbuf_get_width (pixbuf) / icon->orig_scale; h = gdk_pixbuf_get_height (pixbuf) / icon->orig_scale; s = MAX (w, h); if (s == forced_size) { return pixbuf; } scale = (double)forced_size / s; scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, w * scale, h * scale, GDK_INTERP_BILINEAR); g_object_unref (pixbuf); return scaled_pixbuf; }
false
false
false
false
false
0
constant_pool_add_NameAndType(struct ClassFile *cf, const char *name, const char *descriptor) { struct Pair t; struct ConstantPool **p = &cf->constant_pool; int index = 1; t.i = constant_pool_add_Utf8(cf, name); t.j = constant_pool_add_Utf8(cf, descriptor); while (*p != NULL) { if ((*p)->tag == CONSTANT_NameAndType && (*p)->data.t.i == t.i && (*p)->data.t.j == t.j) return index; p = &(*p)->next; index++; } *p = (struct ConstantPool*)malloc(sizeof(struct ConstantPool)); if (*p) { (*p)->tag = CONSTANT_NameAndType; (*p)->data.t = t; (*p)->next = NULL; } return ++cf->constant_pool_count; }
false
false
false
false
false
0
xmlSecNssAppKeyLoadSECItem(SECItem* secItem, xmlSecKeyDataFormat format, const char *pwd, void* pwdCallback, void* pwdCallbackCtx) { xmlSecKeyPtr key = NULL; xmlSecAssert2(secItem != NULL, NULL); xmlSecAssert2(format != xmlSecKeyDataFormatUnknown, NULL); switch(format) { #ifndef XMLSEC_NO_X509 case xmlSecKeyDataFormatPkcs12: key = xmlSecNssAppPkcs12LoadSECItem(secItem, pwd, pwdCallback, pwdCallbackCtx); if(key == NULL) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecNssAppPkcs12LoadSECItem", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); return(NULL); } break; case xmlSecKeyDataFormatCertDer: key = xmlSecNssAppKeyFromCertLoadSECItem(secItem, format); if(key == NULL) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecNssAppKeyFromCertLoadSECItem", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); return(NULL); } break; #endif /* XMLSEC_NO_X509 */ case xmlSecKeyDataFormatDer: key = xmlSecNssAppDerKeyLoadSECItem(secItem); if(key == NULL) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecNssAppDerKeyLoadSECItem", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); return(NULL); } break; default: xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecNssAppKeyLoad", XMLSEC_ERRORS_R_INVALID_FORMAT, "format=%d", format); return(NULL); } return(key); }
false
false
false
false
false
0
SendPointOfInterest(uint32 poi_id) { PointOfInterest const* poi = sObjectMgr.GetPointOfInterest(poi_id); if (!poi) { sLog.outErrorDb("Requested send nonexistent POI (Id: %u), ignore.", poi_id); return; } std::string icon_name = poi->icon_name; int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) if (PointOfInterestLocale const* pl = sObjectMgr.GetPointOfInterestLocale(poi_id)) if (pl->IconName.size() > size_t(loc_idx) && !pl->IconName[loc_idx].empty()) icon_name = pl->IconName[loc_idx]; WorldPacket data(SMSG_GOSSIP_POI, (4 + 4 + 4 + 4 + 4 + 10)); // guess size data << uint32(poi->flags); data << float(poi->x); data << float(poi->y); data << uint32(poi->icon); data << uint32(poi->data); data << icon_name; GetMenuSession()->SendPacket(&data); // DEBUG_LOG("WORLD: Sent SMSG_GOSSIP_POI"); }
false
false
false
false
false
0
ReleaseListToSpans(void* start) { while (start) { void *next = SLL_Next(start); ReleaseToSpans(start); start = next; } }
false
false
false
false
false
0
genie_times_int_string (NODE_T * p) { A68_INT k; A68_REF a; POP_REF (p, &a); POP_OBJECT (p, &k, A68_INT); PRELUDE_ERROR (VALUE (&k) < 0, p, ERROR_INVALID_ARGUMENT, MODE (INT)); PUSH_REF (p, empty_string (p)); while (VALUE (&k)--) { PUSH_REF (p, a); genie_add_string (p); } }
false
false
false
false
false
0
map_excludes(__isl_keep isl_map *map, void *user) { struct isl_union_map_involves_dims_data *data = user; int involves; involves = isl_map_involves_dims(map, isl_dim_param, data->first, data->n); if (involves < 0) return -1; return !involves; }
false
false
false
false
false
0
addTerm(const FbTk::FbString &str, WinProperty prop, bool negate, const FbTk::FbString& xprop) { bool rc = false; Term* term = new Term(str, prop, negate, xprop); if (!term) return rc; if ((rc = !term->regexp.error())) { m_terms.push_back(term); } else { delete term; } return rc; }
false
false
false
false
false
0
setTransientFor(w, win) Widget w; Window win; { if (!XtIsRealized(w)) XtRealizeWidget(w); XSetTransientForHint(XtDisplay(w), XtWindow(w), win); }
false
false
false
false
false
0
dspam_addattribute (DSPAM_CTX * CTX, const char *key, const char *value) { int i, j = 0; if (_ds_find_attribute(CTX->config->attributes, key)) return _ds_add_attribute(CTX->config->attributes, key, value); for(i=0;CTX->config->attributes[i];i++) j++; if (j >= CTX->config->size) { config_t ptr; CTX->config->size *= 2; ptr = realloc(CTX->config->attributes, 1+(sizeof(attribute_t)*CTX->config->size)); if (ptr) { CTX->config->attributes = ptr; } else { LOG(LOG_CRIT, ERR_MEM_ALLOC); return EFAILURE; } } return _ds_add_attribute(CTX->config->attributes, key, value); }
false
false
false
false
false
0
smi_read_eeprom(struct i2c_adapter *i2c, u16 reg, u8 *data, u16 size) { int ret; u8 b0[2] = { (reg >> 8) & 0xff, reg & 0xff }; struct i2c_msg msg[] = { { .addr = 0x50, .flags = 0, .buf = b0, .len = 2 }, { .addr = 0x50, .flags = I2C_M_RD, .buf = data, .len = size } }; ret = i2c_transfer(i2c, msg, 2); if (ret != 2) { dev_err(&i2c->dev, "%s: reg=0x%x (error=%d)\n", __func__, reg, ret); return ret; } return ret; }
false
false
false
false
false
0
window_print_items(WINDOW_REC *win) { GSList *tmp; const char *type; printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_ITEMS_HEADER); for (tmp = win->items; tmp != NULL; tmp = tmp->next) { WI_ITEM_REC *item = tmp->data; type = module_find_id_str("WINDOW ITEM TYPE", item->type); printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_ITEM, type == NULL ? "??" : type, item->visible_name, item->server == NULL ? "" : item->server->tag); } printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_ITEMS_FOOTER); }
false
false
false
false
false
0
mmio_74xx_gpio_probe(struct platform_device *pdev) { const struct of_device_id *of_id; struct mmio_74xx_gpio_priv *priv; struct resource *res; void __iomem *dat; int err; of_id = of_match_device(mmio_74xx_gpio_ids, &pdev->dev); if (!of_id) return -ENODEV; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); dat = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(dat)) return PTR_ERR(dat); priv->flags = (uintptr_t) of_id->data; err = bgpio_init(&priv->bgc, &pdev->dev, DIV_ROUND_UP(MMIO_74XX_BIT_CNT(priv->flags), 8), dat, NULL, NULL, NULL, NULL, 0); if (err) return err; priv->bgc.gc.direction_input = mmio_74xx_dir_in; priv->bgc.gc.direction_output = mmio_74xx_dir_out; priv->bgc.gc.get_direction = mmio_74xx_get_direction; priv->bgc.gc.ngpio = MMIO_74XX_BIT_CNT(priv->flags); priv->bgc.gc.owner = THIS_MODULE; platform_set_drvdata(pdev, priv); return gpiochip_add(&priv->bgc.gc); }
false
false
false
false
false
0
prepare_convdata(IR * ir) { if (!ir->resampled_samples || !ir->ir_nfram || !ir->nchan) { return; } free_ir_samples(ir); ir->ir_samples = (float**)malloc((1 + ir->nchan) * sizeof(float*)); for (int i = 0; i < ir->nchan; i++) { ir->ir_samples[i] = (float*)malloc(ir->ir_nfram * sizeof(float)); } ir->ir_samples[ir->nchan] = NULL; /* de-interleave resampled_samples to ir_samples */ for (int ch = 0; ch < ir->nchan; ch++) { float * p = ir->resampled_samples + ch; float * q = ir->ir_samples[ch]; int nch = ir->nchan; int nfram = ir->ir_nfram; for (int i = 0; i < nfram; i++) { q[i] = p[i * nch]; } } /* Autogain calculation */ float pow = 0; for (int ch = 0; ch < ir->nchan; ch++) { float * p = ir->ir_samples[ch]; for (int i = 0; i < ir->ir_nfram; i++) { pow += p[i] * p[i]; } } pow /= ir->nchan; ir->autogain_new = -10.0 * log10f(pow / 6.0); /* IR stereo width */ if (ir->nchan == 2) { ms_stereo(*ir->port_stereo_ir, ir->ir_samples[0], ir->ir_samples[1], ir->ir_nfram); } else if (ir->nchan == 4) { ms_stereo(*ir->port_stereo_ir, ir->ir_samples[0], ir->ir_samples[1], ir->ir_nfram); ms_stereo(*ir->port_stereo_ir, ir->ir_samples[2], ir->ir_samples[3], ir->ir_nfram); } process_envelopes(ir); /* reverse ir vector if needed */ int reverse = (*ir->port_reverse > 0.0f) ? 1 : 0; if (reverse) { float tmp; int nfram = ir->ir_nfram; for (int ch = 0; ch < ir->nchan; ch++) { float * p = ir->ir_samples[ch]; for (int i = 0, j = nfram-1; i < nfram/2; i++, j--) { tmp = p[i]; p[i] = p[j]; p[j] = tmp; } } } }
false
false
false
false
false
0
mpz_poly_realloc(mpz_poly_t poly, unsigned long alloc) { if ((long) alloc <= 0) alloc = 1; // clear any mpz_t's beyond the new array length for (unsigned long i = alloc; i < poly->alloc; i++) mpz_clear(poly->coeffs[i]); poly->coeffs = (mpz_t*) flint_heap_realloc(poly->coeffs, alloc * sizeof(mpz_t)); // init any new mpz_t's required for (unsigned long i = poly->alloc; i < alloc; i++) mpz_init(poly->coeffs[i]); poly->alloc = alloc; // truncate poly if necessary if (poly->length > alloc) { poly->length = alloc; mpz_poly_normalise(poly); } }
false
false
false
false
false
0
node_create(const node_id_t * node_id) { node_t *node; gchar *name; guint i; g_assert(node_id); node = g_malloc (sizeof (node_t)); g_assert(node); node->node_id = *node_id; name = node_id_str(node_id); node->name = g_string_new(name); node->numeric_name = g_string_new(name); g_free(name); for (i = 0 ; i <= STACK_SIZE; ++i) node->main_prot[i] = NULL; traffic_stats_init(&node->node_stats); ++nodes_num; if (INFO_ENABLED) { gchar *msg = node_id_dump(&node->node_id); g_my_info(_("New node: %s. Number of nodes %d"), msg, nodes_num); g_free(msg); } return node; }
false
false
false
false
false
0
svc_is_mapped (rpcprog_t prog, rpcvers_t vers) { struct svc_callout *prev; register struct svc_callout *s; s = svc_find (prog, vers, &prev); return s!= NULL_SVC && s->sc_mapped; }
false
false
false
false
false
0
at76_calc_padding(int wlen) { /* add the USB TX header */ wlen += AT76_TX_HDRLEN; wlen = wlen % 64; if (wlen < 50) return 50 - wlen; if (wlen >= 61) return 64 + 50 - wlen; return 0; }
false
false
false
false
false
0
skip_comment(line, process, include_space, is_comment) char_u *line; int process; int include_space; int *is_comment; { char_u *comment_flags = NULL; int lead_len; int leader_offset = get_last_leader_offset(line, &comment_flags); *is_comment = FALSE; if (leader_offset != -1) { /* Let's check whether the line ends with an unclosed comment. * If the last comment leader has COM_END in flags, there's no comment. */ while (*comment_flags) { if (*comment_flags == COM_END || *comment_flags == ':') break; ++comment_flags; } if (*comment_flags != COM_END) *is_comment = TRUE; } if (process == FALSE) return line; lead_len = get_leader_len(line, &comment_flags, FALSE, include_space); if (lead_len == 0) return line; /* Find: * - COM_END, * - colon, * whichever comes first. */ while (*comment_flags) { if (*comment_flags == COM_END || *comment_flags == ':') { break; } ++comment_flags; } /* If we found a colon, it means that we are not processing a line * starting with a closing part of a three-part comment. That's good, * because we don't want to remove those as this would be annoying. */ if (*comment_flags == ':' || *comment_flags == NUL) line += lead_len; return line; }
false
false
false
false
false
0
flac__utils_set_channel_mask_tag(FLAC__StreamMetadata *object, FLAC__uint32 channel_mask) { FLAC__StreamMetadata_VorbisComment_Entry entry = { 0, 0 }; char tag[128]; FLAC__ASSERT(object); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); FLAC__ASSERT(strlen(CHANNEL_MASK_TAG+1+2+16+1) <= sizeof(tag)); /* +1 for =, +2 for 0x, +16 for digits, +1 for NUL */ entry.entry = (FLAC__byte*)tag; if((entry.length = flac_snprintf(tag, sizeof(tag), "%s=0x%04X", CHANNEL_MASK_TAG, (unsigned)channel_mask)) >= sizeof(tag)) return false; if(!FLAC__metadata_object_vorbiscomment_replace_comment(object, entry, /*all=*/true, /*copy=*/true)) return false; return true; }
false
false
false
false
false
0
insert_name_tags(RESULT& result, WORKUNIT const& wu) { char buf[256]; int retval; sprintf(buf, "<name>%s</name>\n", result.name); retval = insert_after(result.xml_doc_in, "<result>\n", buf); if (retval) return retval; sprintf(buf, "<wu_name>%s</wu_name>\n", wu.name); retval = insert_after(result.xml_doc_in, "<result>\n", buf); if (retval) return retval; return 0; }
false
false
false
false
false
0
on_secret_info_query (GdmDBusUserVerifier *user_verifier, const char *service_name, const char *query_text) { char answer[1024]; char *res; struct termios ts0; struct termios ts1; tcgetattr (fileno (stdin), &ts0); ts1 = ts0; ts1.c_lflag &= ~ECHO; g_print ("%s", query_text); if (tcsetattr (fileno (stdin), TCSAFLUSH, &ts1) != 0) { fprintf (stderr, "Could not set terminal attributes\n"); exit (1); } answer[0] = '\0'; res = fgets (answer, sizeof (answer), stdin); answer[strlen (answer) - 1] = '\0'; if (res == NULL) { g_warning ("Couldn't get an answer"); } tcsetattr (fileno (stdin), TCSANOW, &ts0); g_print ("\n"); gdm_dbus_user_verifier_call_answer_query_sync (user_verifier, service_name, answer, NULL, NULL); }
false
false
false
false
false
0
main() { set<fraction> happy_joy; for(auto tens : digits) for(auto ones : digits) for(auto filler : digits) { //BRUTE FORCE YEEEAAAAHHHH fraction f1 = make_pair(tens * 10 + ones, filler * 10 + tens), f2 = make_pair(tens * 10 + ones, ones * 10 + filler), cancel_f1 = make_pair(ones, filler), cancel_f2 = make_pair(tens, filler); if(less_than_one(f1) && reduce(f1) == reduce(cancel_f1)) happy_joy.insert(f1); if(less_than_one(f2) && reduce(f2) == reduce(cancel_f2)) happy_joy.insert(f2); } auto answer = reduce(std::accumulate(happy_joy.begin(), happy_joy.end(), make_pair(1U,1U), frac_mult)); cout<<answer.first<<"/"<<answer.second<<endl; return 0; }
false
false
false
false
false
0
uv__stream_init(uv_loop_t* loop, uv_stream_t* stream, uv_handle_type type) { uv__handle_init(loop, (uv_handle_t*)stream, type); stream->read_cb = NULL; stream->read2_cb = NULL; stream->alloc_cb = NULL; stream->close_cb = NULL; stream->connection_cb = NULL; stream->connect_req = NULL; stream->shutdown_req = NULL; stream->accepted_fd = -1; stream->delayed_error = 0; ngx_queue_init(&stream->write_queue); ngx_queue_init(&stream->write_completed_queue); stream->write_queue_size = 0; if (loop->emfile_fd == -1) loop->emfile_fd = uv__open_cloexec("/", O_RDONLY); #if defined(__APPLE__) stream->select = NULL; #endif /* defined(__APPLE_) */ uv__io_init(&stream->io_watcher, uv__stream_io, -1); }
false
false
false
false
false
0
dumpCommand(redisClient *c) { char buf[64]; FILE *fp; robj *o, *dumpobj; sds dump = NULL; off_t payload_len; unsigned int type; /* Check if the key is here. */ if ((o = lookupKeyRead(c->db,c->argv[1])) == NULL) { addReply(c,shared.nullbulk); return; } /* Create temp file */ snprintf(buf,sizeof(buf),"redis-dump-%d.tmp",getpid()); fp = fopen(buf,"w+"); if (!fp) { redisLog(REDIS_WARNING,"Can't open tmp file for MIGRATE: %s", strerror(errno)); addReplyErrorFormat(c,"DUMP failed, tmp file creation error: %s.", strerror(errno)); return; } unlink(buf); /* Dump the serailized object and read it back in memory. * We prefix it with a one byte containing the type ID. * This is the serialization format understood by RESTORE. */ if (rdbSaveObject(fp,o) == -1) goto file_wr_err; payload_len = ftello(fp); if (fseeko(fp,0,SEEK_SET) == -1) goto file_rd_err; dump = sdsnewlen(NULL,payload_len+1); if (payload_len && fread(dump+1,payload_len,1,fp) != 1) goto file_rd_err; fclose(fp); type = o->type; if (type == REDIS_LIST && o->encoding == REDIS_ENCODING_ZIPLIST) type = REDIS_LIST_ZIPLIST; else if (type == REDIS_HASH && o->encoding == REDIS_ENCODING_ZIPMAP) type = REDIS_HASH_ZIPMAP; else if (type == REDIS_SET && o->encoding == REDIS_ENCODING_INTSET) type = REDIS_SET_INTSET; else type = o->type; dump[0] = type; /* Transfer to the client */ dumpobj = createObject(REDIS_STRING,dump); addReplyBulk(c,dumpobj); decrRefCount(dumpobj); return; file_wr_err: redisLog(REDIS_WARNING,"Can't write on tmp file for DUMP: %s", strerror(errno)); addReplyErrorFormat(c,"DUMP failed, tmp file write error: %s.", strerror(errno)); sdsfree(dump); fclose(fp); return; file_rd_err: redisLog(REDIS_WARNING,"Can't read from tmp file for DUMP: %s", strerror(errno)); addReplyErrorFormat(c,"DUMP failed, tmp file read error: %s.", strerror(errno)); sdsfree(dump); fclose(fp); return; }
true
true
false
false
true
1
ggc_free (void *p) { page_entry *pe = lookup_page_table_entry (p); size_t order = pe->order; size_t size = OBJECT_SIZE (order); #ifdef GATHER_STATISTICS ggc_free_overhead (p); #endif if (GGC_DEBUG_LEVEL >= 3) fprintf (G.debug_file, "Freeing object, actual size=%lu, at %p on %p\n", (unsigned long) size, p, (void *) pe); #ifdef ENABLE_GC_CHECKING /* Poison the data, to indicate the data is garbage. */ VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (p, size)); memset (p, 0xa5, size); #endif /* Let valgrind know the object is free. */ VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (p, size)); #ifdef ENABLE_GC_ALWAYS_COLLECT /* In the completely-anal-checking mode, we do *not* immediately free the data, but instead verify that the data is *actually* not reachable the next time we collect. */ { struct free_object *fo = XNEW (struct free_object); fo->object = p; fo->next = G.free_object_list; G.free_object_list = fo; } #else { unsigned int bit_offset, word, bit; G.allocated -= size; /* Mark the object not-in-use. */ bit_offset = OFFSET_TO_BIT (((const char *) p) - pe->page, order); word = bit_offset / HOST_BITS_PER_LONG; bit = bit_offset % HOST_BITS_PER_LONG; pe->in_use_p[word] &= ~(1UL << bit); if (pe->num_free_objects++ == 0) { page_entry *p, *q; /* If the page is completely full, then it's supposed to be after all pages that aren't. Since we've freed one object from a page that was full, we need to move the page to the head of the list. PE is the node we want to move. Q is the previous node and P is the next node in the list. */ q = pe->prev; if (q && q->num_free_objects == 0) { p = pe->next; q->next = p; /* If PE was at the end of the list, then Q becomes the new end of the list. If PE was not the end of the list, then we need to update the PREV field for P. */ if (!p) G.page_tails[order] = q; else p->prev = q; /* Move PE to the head of the list. */ pe->next = G.pages[order]; pe->prev = NULL; G.pages[order]->prev = pe; G.pages[order] = pe; } /* Reset the hint bit to point to the only free object. */ pe->next_bit_hint = bit_offset; } } #endif }
false
false
false
false
false
0
printNamedMDNode(const NamedMDNode *NMD) { Out << '!'; printMetadataIdentifier(NMD->getName(), Out); Out << " = !{"; for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) { if (i) Out << ", "; int Slot = Machine.getMetadataSlot(NMD->getOperand(i)); if (Slot == -1) Out << "<badref>"; else Out << '!' << Slot; } Out << "}\n"; }
false
false
false
false
false
0
tio_goto_column(column) int column; /* Move cursor to column `column'. */ { if (column > hx_columns - 1) column = column - 1; if (t_column >= 0) if (abs(t_column - column) <= column) { tio_rel_move(0, column - t_column); return; } if (t_goto_column) tio_command(t_goto_column, 1, column); else { tio_return(); tio_right(column); } t_column = column; }
false
false
false
false
false
0
compute_luids (start, end, prev_luid) rtx start, end; int prev_luid; { int i; rtx insn; for (insn = start, i = prev_luid; insn != end; insn = NEXT_INSN (insn)) { if (INSN_UID (insn) >= max_uid_for_loop) continue; /* Don't assign luids to line-number NOTEs, so that the distance in luids between two insns is not affected by -g. */ if (GET_CODE (insn) != NOTE || NOTE_LINE_NUMBER (insn) <= 0) uid_luid[INSN_UID (insn)] = ++i; else /* Give a line number note the same luid as preceding insn. */ uid_luid[INSN_UID (insn)] = i; } return i + 1; }
false
false
false
false
false
0
Transport_StirRandom(TSS_HCONTEXT tspContext, /* in */ UINT32 inDataSize, /* in */ BYTE * inData) /* in */ { TSS_RESULT result; UINT64 offset; UINT32 dataLen; TCS_HANDLE handlesLen = 0; BYTE *data; if ((result = obj_context_transport_init(tspContext))) return result; LogDebugFn("Executing in a transport session"); dataLen = sizeof(UINT32) + inDataSize; if ((data = malloc(dataLen)) == NULL) { LogError("malloc of %u bytes failed", dataLen); return TSPERR(TSS_E_OUTOFMEMORY); } offset = 0; Trspi_LoadBlob_UINT32(&offset, inDataSize, data); Trspi_LoadBlob(&offset, inDataSize, data, inData); result = obj_context_transport_execute(tspContext, TPM_ORD_StirRandom, dataLen, data, NULL, &handlesLen, NULL, NULL, NULL, NULL, NULL); free(data); return result; }
false
false
false
false
false
0
jpu_g_fmt(struct file *file, void *priv, struct v4l2_format *f) { struct jpu_q_data *q_data; struct jpu_ctx *ctx = fh_to_ctx(priv); if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type)) return -EINVAL; q_data = jpu_get_q_data(ctx, f->type); f->fmt.pix_mp = q_data->format; return 0; }
false
false
false
false
false
0
update_pool(prng_ctx ctx[1]) { unsigned int i = 0; /* transfer random pool data to the output buffer */ memcpy(ctx->obuf, ctx->rbuf, PRNG_POOL_SIZE); /* enter entropy data into the pool */ while(i < PRNG_POOL_SIZE) i += ctx->entropy(ctx->rbuf + i, PRNG_POOL_SIZE - i); /* invert and xor the original pool data into the pool */ for(i = 0; i < PRNG_POOL_SIZE; ++i) ctx->rbuf[i] ^= ~ctx->obuf[i]; /* mix the pool and the output buffer */ prng_mix(ctx->rbuf); prng_mix(ctx->obuf); }
false
false
false
false
false
0
subs(const map_basic_basic &subs_dict) const { RCP<const Mul> self = rcp_const_cast<Mul>(rcp(this)); auto it = subs_dict.find(self); if (it != subs_dict.end()) return it->second; RCP<const Number> coef = coef_; map_basic_basic d; for (auto &p: dict_) { RCP<const Basic> factor_old = pow(p.first, p.second); RCP<const Basic> factor = factor_old->subs(subs_dict); if (factor == factor_old) { Mul::dict_add_term_new(outArg(coef), d, p.second, p.first); } else if (is_a<Integer>(*factor) && rcp_static_cast<const Integer>(factor)->is_zero()) { return zero; } else if (is_a_Number(*factor)) { imulnum(outArg(coef), rcp_static_cast<const Number>(factor)); } else if (is_a<Mul>(*factor)) { RCP<const Mul> tmp = rcp_static_cast<const Mul>(factor); imulnum(outArg(coef), tmp->coef_); for (auto &q: tmp->dict_) { Mul::dict_add_term_new(outArg(coef), d, q.second, q.first); } } else { RCP<const Basic> exp, t; Mul::as_base_exp(factor, outArg(exp), outArg(t)); Mul::dict_add_term_new(outArg(coef), d, exp, t); } } return Mul::from_dict(coef, std::move(d)); }
false
false
false
false
false
0
real_execute() { int num = m_head; int total = fbwindow().screen().numHeads(); if (num < 0) num += total + 1; num = FbTk::Util::clamp(num, 1, total); fbwindow().setOnHead(num); }
false
false
false
false
false
0
cmd_hyperlink_redo (GnmCommand *cmd, WorkbookControl *wbc) { CmdHyperlink *me = CMD_HYPERLINK (cmd); GSList *l; Workbook *wb = wb_control_get_workbook (wbc); g_return_val_if_fail (me != NULL, TRUE); /* Check for locked cells */ if (cmd_selection_is_locked_effective (me->cmd.sheet, me->selection, wbc, _("Changing Hyperlink"))) return TRUE; for (l = me->selection; l; l = l->next) { GnmRange const *r = l->data; if (me->new_style) { gnm_style_ref (me->new_style); sheet_apply_style (me->cmd.sheet, r, me->new_style); } sheet_flag_style_update_range (me->cmd.sheet, r); } if (me->opt_content != NULL) for (l = me->cells; l; l = l->next) { GnmCell *cell = l->data; sheet_cell_set_value (cell, value_new_string (me->opt_content)); } sheet_redraw_all (me->cmd.sheet, FALSE); sheet_mark_dirty (me->cmd.sheet); select_selection (me->cmd.sheet, me->selection, wbc); WORKBOOK_FOREACH_CONTROL (wb, view, ctl, wb_control_menu_state_update (ctl, MS_COMMENT_LINKS);); return FALSE; }
false
false
false
false
false
0
insert(uint field, long long value) { UDSEntryPrivate::Field f; f.m_long = value; d->fields.insert(field, f); }
false
false
false
false
false
0
parseAttribute(XMLNode_as* node, xml_iterator& it, const xml_iterator end, Attributes& attributes) { const std::string terminators("\r\t\n >="); xml_iterator ourend = std::find_first_of(it, end, terminators.begin(), terminators.end()); if (ourend == end) { _status = XML_UNTERMINATED_ELEMENT; return; } std::string name(it, ourend); if (name.empty()) { _status = XML_UNTERMINATED_ELEMENT; return; } // Point iterator to the DisplayObject after the name. it = ourend; // Skip any whitespace before the '='. If we reach the end of the string // or don't find an '=', it's a parser error. if (!textAfterWhitespace(it, end) || *it != '=') { _status = XML_UNTERMINATED_ELEMENT; return; } // Point to the DisplayObject after the '=' ++it; // Skip any whitespace. If we reach the end of the string, or don't find // a " or ', it's a parser error. if (!textAfterWhitespace(it, end) || (*it != '"' && *it != '\'')) { _status = XML_UNTERMINATED_ELEMENT; return; } // Find the end of the attribute, looking for the opening DisplayObject, // as long as it's not escaped. We begin one after the present position, // which should be the opening DisplayObject. We want to remember what the // iterator is pointing to for a while, so don't advance it. ourend = it; do { ++ourend; ourend = std::find(ourend, end, *it); } while (ourend != end && *(ourend - 1) == '\\'); if (ourend == end) { _status = XML_UNTERMINATED_ATTRIBUTE; return; } ++it; std::string value(it, ourend); // Replace entities in the value. unescapeXML(value); // We've already checked that ourend != end, so we can advance at // least once. it = ourend; // Advance past the last attribute DisplayObject ++it; // Handle namespace. This is set once only for each node, and is also // pushed to the attributes list once. StringNoCaseEqual noCaseCompare; if (noCaseCompare(name, "xmlns") || noCaseCompare(name, "xmlns:")) { if (!node->getNamespaceURI().empty()) return; node->setNamespaceURI(value); } // This ensures values are not inserted twice, which is expected // behaviour attributes.insert(std::make_pair(name, value)); }
false
false
false
false
false
0
countParts(QDir & dir, QStringList & nameFilters, int & partCount) { QStringList list = dir.entryList(nameFilters, QDir::Files | QDir::NoSymLinks); partCount += list.size(); QStringList dirs = dir.entryList(QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); for (int i = 0; i < dirs.size(); ++i) { QString temp2 = dirs[i]; dir.cd(temp2); countParts(dir, nameFilters, partCount); dir.cdUp(); } }
false
false
false
false
false
0