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
isCompressedFile(std::string & cmd) { bool compressed = false, isInput = (flags_ & std::ios::in); cmd = ""; unsigned int len = path_.size(); if( len > kGzipped.size() && path_.find(kGzipped) == len - kGzipped.size()) { //gzip file command to compress or decompress compressed = true; // cmd = (isInput ? "exec gunzip -cf " : "exec gzip -c > ") + path_; cmd = (isInput ? "exec " + kGunzipCommand + "c " : "exec " + kGzipCommand + "c > ") + path_; } else if( len > kBzipped2.size() && path_.find(kBzipped2) == len - kBzipped2.size()) { //do bzipped2 file command compressed = true; cmd = (isInput ? "exec " + kBunzip2Command + "c " : "exec " + kBzip2Command + "c > ") + path_; } return compressed; }
false
false
false
false
false
0
tifm_alloc_device(struct tifm_adapter *fm, unsigned int id, unsigned char type) { struct tifm_dev *sock = NULL; if (!tifm_media_type_name(type, 0)) return sock; sock = kzalloc(sizeof(struct tifm_dev), GFP_KERNEL); if (sock) { spin_lock_init(&sock->lock); sock->type = type; sock->socket_id = id; sock->card_event = tifm_dummy_event; sock->data_event = tifm_dummy_event; sock->dev.parent = fm->dev.parent; sock->dev.bus = &tifm_bus_type; sock->dev.dma_mask = fm->dev.parent->dma_mask; sock->dev.release = tifm_free_device; dev_set_name(&sock->dev, "tifm_%s%u:%u", tifm_media_type_name(type, 2), fm->id, id); printk(KERN_INFO DRIVER_NAME ": %s card detected in socket %u:%u\n", tifm_media_type_name(type, 0), fm->id, id); } return sock; }
false
false
false
false
false
0
OnSessionDestroy(Session* session) { LOG(LS_INFO) << "TunnelSessionClientBase::OnSessionDestroy"; ASSERT(session_manager_->signaling_thread()->IsCurrent()); if (shutdown_) return; for (std::vector<TunnelSession*>::iterator it = sessions_.begin(); it != sessions_.end(); ++it) { if ((*it)->HasSession(session)) { VERIFY((*it)->ReleaseSession(false) == session); sessions_.erase(it); return; } } }
false
false
false
false
false
0
obj_context_get_connection_version(TSS_HCONTEXT tspContext, UINT32 *version) { struct tsp_object *obj; struct tr_context_obj *context; if ((obj = obj_list_get_obj(&context_list, tspContext)) == NULL) return TSPERR(TSS_E_INVALID_HANDLE); context = (struct tr_context_obj *)obj->data; *version = context->current_connection; obj_list_put(&context_list); return TSS_SUCCESS; }
false
false
false
false
false
0
fs_binding_get_vals(fs_binding *b, const char *name, int *bound) { #ifdef DEBUG_BINDING if (!strcmp(DEBUG_BINDING, name)) printf("@@ get_vals("DEBUG_BINDING")\n"); #endif int i; for (i=0; 1; i++) { if (!b[i].name) break; if (!strcmp(b[i].name, name)) { if (bound) *bound = b[i].bound; return b[i].vals; } } /* fs_error(LOG_ERR, "binding lookup on unknown variable '%s'", name); */ return NULL; }
false
false
false
false
false
0
ssl_init() { SSL_CTX *ctx = NULL; SSL_load_error_strings(); SSL_library_init(); OpenSSL_add_all_algorithms(); if ((locks = calloc(CRYPTO_num_locks(), sizeof(pthread_mutex_t)))) { for (int i = 0; i < CRYPTO_num_locks(); i++) { pthread_mutex_init(&locks[i], NULL); } CRYPTO_set_locking_callback(ssl_lock); CRYPTO_set_id_callback(ssl_id); if ((ctx = SSL_CTX_new(SSLv23_client_method()))) { SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); SSL_CTX_set_verify_depth(ctx, 0); SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY); SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_CLIENT); } } return ctx; }
false
false
false
false
false
0
CompAssComObjExpr ( Stat stat ) { CVar record; /* record, left operand */ CVar rnam; /* name, left operand */ CVar rhs; /* rhs, right operand */ /* print a comment */ if ( CompPass == 2 ) { Emit( "\n/* " ); PrintStat( stat ); Emit( " */\n" ); } /* compile the record expression */ record = CompExpr( ADDR_STAT(stat)[0] ); /* get the name (stored immediately in the statement) */ rnam = CompExpr( ADDR_STAT(stat)[1] ); /* compile the right hand side */ rhs = CompExpr( ADDR_STAT(stat)[2] ); /* emit the code for the assignment */ Emit( "if ( TNUM_OBJ(%c) == T_COMOBJ ) {\n", record ); Emit( "AssPRec( %c, RNamObj(%c), %c );\n", record, rnam, rhs ); Emit( "}\nelse {\n" ); Emit( "ASS_REC( %c, RNamObj(%c), %c );\n", record, rnam, rhs ); Emit( "}\n" ); /* free the temporaries */ if ( IS_TEMP_CVAR( rhs ) ) FreeTemp( TEMP_CVAR( rhs ) ); if ( IS_TEMP_CVAR( rnam ) ) FreeTemp( TEMP_CVAR( rnam ) ); if ( IS_TEMP_CVAR( record ) ) FreeTemp( TEMP_CVAR( record ) ); }
false
false
false
false
false
0
SVCmd_ResetScores_f (void) { if(!matchmode->value) { gi.cprintf(NULL, PRINT_HIGH, "This command works only in matchmode\n"); return; } ResetScores(true); gi.bprintf(PRINT_HIGH, "Scores and time was resetted by console\n"); }
false
false
false
false
false
0
genget(char *name, char **table, int stlen) /* name to match */ /* name entry in table */ { char **c, **found; int n; if (name == 0) return 0; found = 0; for (c = table; *c != 0; c = (char **)((char *)c + stlen)) { if ((n = isprefix(name, *c)) == 0) continue; if (n < 0) /* exact match */ return(c); if (found) return(&ambiguous); found = c; } return(found); }
false
false
false
false
false
0
on_line_width_combo_combo_entry_changed(GtkEditable *editable, gpointer user_data) { char *tmp; int t; GdkGCValues gcvalues; gpaint_canvas *canvas; gpaint_drawing *drawing; int position = 0; debug_fn(); canvas = canvas_lookup(GTK_WIDGET(editable)); drawing = canvas->drawing; tmp = gtk_editable_get_chars(editable, 0, -1); g_assert(tmp); if (strlen(tmp) > 0) { sscanf(tmp, "%d", &t); g_free(tmp); if (t > 0) { gdk_gc_get_values(drawing->gc, &gcvalues); gdk_gc_set_line_attributes(drawing->gc, t, gcvalues.line_style, gcvalues.cap_style, gcvalues.join_style); /* force the line width entry widget to give up focus */ gtk_widget_grab_focus(GTK_WIDGET(canvas->drawing_area)); } else { gdk_gc_get_values(drawing->gc, &gcvalues); tmp = g_strdup_printf("%d", gcvalues.line_width); gtk_editable_delete_text(editable, 0, -1); gtk_editable_insert_text(editable, tmp, strlen(tmp), &position); gtk_editable_set_position(editable, -1); g_free(tmp); } } else { g_free(tmp); } }
false
false
false
false
false
0
DetermineCfenginePort() { struct servent *server; if ((server = getservbyname(CFENGINE_SERVICE,"tcp")) == NULL) { CfOut(cf_verbose,"getservbyname","No registered cfengine service, using default"); snprintf(STR_CFENGINEPORT,15,"5308"); SHORT_CFENGINEPORT = htons((unsigned short)5308); } else { snprintf(STR_CFENGINEPORT,15,"%u",ntohs(server->s_port)); SHORT_CFENGINEPORT = server->s_port; } CfOut(cf_verbose,"","Setting cfengine default port to %u = %s\n",ntohs(SHORT_CFENGINEPORT),STR_CFENGINEPORT); }
false
false
false
false
false
0
spif_linked_list_done(spif_linked_list_t self) { spif_linked_list_item_t current; ASSERT_RVAL(!SPIF_LIST_ISNULL(self), FALSE); if (self->len) { for (current = self->head; current;) { spif_linked_list_item_t tmp; tmp = current; current = current->next; spif_linked_list_item_del(tmp); } self->len = 0; self->head = SPIF_NULL_TYPE(linked_list_item); } return TRUE; }
false
false
false
false
false
0
getTimerInfo(double *pdelapsed) { struct timeval tv; // elapsed gettimeofday(&tv,0); *pdelapsed = (double)tv.tv_sec + 0.000001 * (double)tv.tv_usec; if(*pdelapsed < 0.000001) *pdelapsed = 0.000001; }
false
false
false
false
false
0
size() const { if (!group_ptr) return 0; int size; BOOST_MPI_CHECK_RESULT(MPI_Group_size, (*group_ptr, &size)); return size; }
false
false
false
false
false
0
qla1280_device_reset(struct scsi_qla_host *ha, int bus, int target) { uint16_t mb[MAILBOX_REGISTER_COUNT]; int status; ENTER("qla1280_device_reset"); mb[0] = MBC_ABORT_TARGET; mb[1] = (bus ? (target | BIT_7) : target) << 8; mb[2] = 1; status = qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]); /* Issue marker command. */ qla1280_marker(ha, bus, target, 0, MK_SYNC_ID); if (status) dprintk(2, "qla1280_device_reset: **** FAILED ****\n"); LEAVE("qla1280_device_reset"); return status; }
false
false
false
false
false
0
midgard_reflector_property_is_primary (MidgardReflectorProperty *self, const gchar *property) { g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (property != NULL, FALSE); g_return_val_if_fail (self->priv->klass != NULL, FALSE); MgdSchemaPropertyAttr *prop_attr = midgard_core_class_get_property_attr (MIDGARD_DBOBJECT_CLASS (self->priv->klass), property); if (prop_attr == NULL) return FALSE; return prop_attr->is_primary; }
false
false
false
false
false
0
AcpiDmDescriptorName ( void) { if (ResourceName == ACPI_DEFAULT_RESNAME) { return; } AcpiOsPrintf ("%4.4s", (char *) &ResourceName); }
false
false
false
false
false
0
adjust_image_device(const char **img_path, const char **dev_path) { const char *tmp_path; if (file_test(*dev_path, "b") >= 0) { return; } tmp_path = *img_path; *img_path = *dev_path; *dev_path = tmp_path; }
false
false
false
false
false
0
left_callback(int count, int key) { reset_indent(); if (rl_point > 0) { int i = line_start(rl_point); rl_point = (i == 0 || rl_point-i > prompt_length) ? rl_point-1 : i-1; } return 0; }
false
false
false
false
false
0
gt_ppt_hit_new(GtStrand strand, GtPPTResults *r) { GtPPTHit *h = gt_calloc((size_t) 1, sizeof (GtPPTHit)); gt_assert(h); h->strand = strand; h->res = r; h->score = 0.0; return h; }
false
false
false
false
false
0
_gcry_cipher_setctr (gcry_cipher_hd_t hd, const void *ctr, size_t ctrlen) { if (ctr && ctrlen == hd->cipher->blocksize) { memcpy (hd->u_ctr.ctr, ctr, hd->cipher->blocksize); hd->unused = 0; } else if (!ctr || !ctrlen) { memset (hd->u_ctr.ctr, 0, hd->cipher->blocksize); hd->unused = 0; } else return gpg_error (GPG_ERR_INV_ARG); return 0; }
false
false
false
false
false
0
efi_snp_statistics ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN reset, UINTN *stats_len, EFI_NETWORK_STATISTICS *stats ) { struct efi_snp_device *snpdev = container_of ( snp, struct efi_snp_device, snp ); EFI_NETWORK_STATISTICS stats_buf; DBGC2 ( snpdev, "SNPDEV %p STATISTICS%s", snpdev, ( reset ? " reset" : "" ) ); /* Gather statistics */ memset ( &stats_buf, 0, sizeof ( stats_buf ) ); stats_buf.TxGoodFrames = snpdev->netdev->tx_stats.good; stats_buf.TxDroppedFrames = snpdev->netdev->tx_stats.bad; stats_buf.TxTotalFrames = ( snpdev->netdev->tx_stats.good + snpdev->netdev->tx_stats.bad ); stats_buf.RxGoodFrames = snpdev->netdev->rx_stats.good; stats_buf.RxDroppedFrames = snpdev->netdev->rx_stats.bad; stats_buf.RxTotalFrames = ( snpdev->netdev->rx_stats.good + snpdev->netdev->rx_stats.bad ); if ( *stats_len > sizeof ( stats_buf ) ) *stats_len = sizeof ( stats_buf ); if ( stats ) memcpy ( stats, &stats_buf, *stats_len ); /* Reset statistics if requested to do so */ if ( reset ) { memset ( &snpdev->netdev->tx_stats, 0, sizeof ( snpdev->netdev->tx_stats ) ); memset ( &snpdev->netdev->rx_stats, 0, sizeof ( snpdev->netdev->rx_stats ) ); } return 0; }
false
false
false
false
false
0
strat_select_method (PyObject *self, PyObject *args) { PyStrategy *py_strat = (PyStrategy *)self; PySelectionKey *py_key; char *word = NULL; if (!PyArg_ParseTuple (args, "sO!", &word, &PySelectionKeyType, &py_key)) return _ro (Py_False); return _ro (py_strat->strat->sel (DICO_SELECT_RUN, py_key->key, word) ? Py_True : Py_False); }
false
false
false
false
false
0
shuttleVFD_init(Driver *drvthis) { PrivateData *p; struct usb_bus *bus; int claim_rc; // allocate and store private data p = (PrivateData *)calloc(1, sizeof(PrivateData)); if (p == NULL) { report(RPT_ERR, "%s: unable to allocate private data", drvthis->name); return -1; } if (drvthis->store_private_ptr(drvthis, p) < 0) { report(RPT_ERR, "%s: unable to store private data", drvthis->name); return -1; } // initialize private data p->dev = NULL; p->width = SHUTTLE_VFD_WIDTH; p->height = SHUTTLE_VFD_HEIGHT; p->cellwidth = SHUTTLE_VFD_CELLWIDTH; p->cellheight = SHUTTLE_VFD_CELLHEIGHT; p->framebuf = (char *)malloc(p->width * p->height); if (p->framebuf == NULL) { report(RPT_ERR, "%s: unable to create framebuffer", drvthis->name); return -1; } memset(p->framebuf, ' ', p->width * p->height); p->last_framebuf = (char *)malloc(p->width * p->height); if (p->last_framebuf == NULL) { report(RPT_ERR, "%s: unable to create second framebuffer", drvthis->name); return -1; } memset(p->last_framebuf, 0, p->width * p->height); p->icons = 0; p->last_icons = 0; // find VFD usb_init(); usb_find_busses(); usb_find_devices(); for (bus = usb_get_busses(); bus != NULL; bus = bus->next) { struct usb_device *dev; for (dev = bus->devices; dev != NULL; dev = dev->next) { if ((dev->descriptor.idVendor == SHUTTLE_VFD_VENDOR_ID1 || dev->descriptor.idVendor == SHUTTLE_VFD_VENDOR_ID2) && (dev->descriptor.idProduct == SHUTTLE_VFD_PRODUCT_ID1 || dev->descriptor.idProduct == SHUTTLE_VFD_PRODUCT_ID2)) { p->dev = usb_open(dev); } } } if (p->dev == NULL) { report(RPT_ERR, "%s: unable to find Shuttle VFD", drvthis->name); return -1; } claim_rc = usb_claim_interface(p->dev, SHUTTLE_VFD_INTERFACE_NUM); if (claim_rc < 0) { report(RPT_ERR, "%s: unable to claim interface: %s", drvthis->name, strerror(claim_rc)); return -1; } report(RPT_DEBUG, "%s: init() done", drvthis->name); return 0; }
false
false
false
false
false
0
show_page_by_url(const char *browser, const char *url) { char com[1024]; /* * Browsers which have openURL() command. */ if (locatestring(browser, "mozilla", MATCH_AT_LAST) || locatestring(browser, "netscape", MATCH_AT_LAST) || locatestring(browser, "netscape-remote", MATCH_AT_LAST)) { char *path; if (!(path = usable(browser))) die("%s not found in your path.", browser); snprintf(com, sizeof(com), "%s -remote \"openURL(%s)\"", path, url); } /* * Generic browser. */ else { snprintf(com, sizeof(com), "%s \"%s\"", browser, url); } system(com); }
true
true
false
false
true
1
CDB_txn_stat(dbenv, statp, db_malloc) DB_ENV *dbenv; DB_TXN_STAT **statp; void *(*db_malloc) __P((size_t)); { DB_TXNMGR *mgr; DB_TXNREGION *region; DB_TXN_STAT *stats; TXN_DETAIL *txnp; size_t nbytes; u_int32_t nactive, ndx; int ret, slop; PANIC_CHECK(dbenv); ENV_REQUIRES_CONFIG(dbenv, dbenv->tx_handle, DB_INIT_TXN); *statp = NULL; slop = 200; mgr = dbenv->tx_handle; region = mgr->reginfo.primary; retry: R_LOCK(dbenv, &mgr->reginfo); nactive = region->nactive; R_UNLOCK(dbenv, &mgr->reginfo); /* * Allocate extra active structures to handle any transactions that * are created while we have the region unlocked. */ nbytes = sizeof(DB_TXN_STAT) + sizeof(DB_TXN_ACTIVE) * (nactive + slop); if ((ret = CDB___os_malloc(nbytes, db_malloc, &stats)) != 0) return (ret); R_LOCK(dbenv, &mgr->reginfo); stats->st_last_txnid = region->last_txnid; stats->st_last_ckp = region->last_ckp; stats->st_maxtxns = region->maxtxns; stats->st_naborts = region->naborts; stats->st_nbegins = region->nbegins; stats->st_ncommits = region->ncommits; stats->st_pending_ckp = region->pending_ckp; stats->st_time_ckp = region->time_ckp; stats->st_nactive = region->nactive; if (stats->st_nactive > nactive + 200) { R_UNLOCK(dbenv, &mgr->reginfo); slop *= 2; goto retry; } stats->st_maxnactive = region->maxnactive; stats->st_txnarray = (DB_TXN_ACTIVE *)&stats[1]; ndx = 0; for (txnp = SH_TAILQ_FIRST(&region->active_txn, __txn_detail); txnp != NULL; txnp = SH_TAILQ_NEXT(txnp, links, __txn_detail)) { stats->st_txnarray[ndx].txnid = txnp->txnid; if (txnp->parent == INVALID_ROFF) stats->st_txnarray[ndx].parentid = TXN_INVALID_ID; else stats->st_txnarray[ndx].parentid = ((TXN_DETAIL *)R_ADDR(&mgr->reginfo, txnp->parent))->txnid; stats->st_txnarray[ndx].lsn = txnp->begin_lsn; ndx++; if (ndx >= stats->st_nactive) break; } stats->st_region_wait = mgr->reginfo.rp->mutex.mutex_set_wait; stats->st_region_nowait = mgr->reginfo.rp->mutex.mutex_set_nowait; stats->st_regsize = mgr->reginfo.rp->size; R_UNLOCK(dbenv, &mgr->reginfo); *statp = stats; return (0); }
false
false
false
false
false
0
brasero_file_node_add (BraseroFileNode *parent, BraseroFileNode *node, GCompareFunc sort_func) { BraseroFileTreeStats *stats; guint depth = 0; parent->union2.children = brasero_file_node_insert (BRASERO_FILE_NODE_CHILDREN (parent), node, sort_func, NULL); node->parent = parent; if (BRASERO_FILE_NODE_VIRTUAL (node)) return; stats = brasero_file_node_get_tree_stats (node->parent, &depth); if (!node->is_imported) { /* book keeping */ if (!node->is_file) stats->num_dir ++; else stats->children ++; /* NOTE: parent will be changed afterwards !!! */ if (!node->is_grafted) { /* propagate the size change*/ for (; parent && !parent->is_root; parent = parent->parent) { parent->union3.sectors += BRASERO_FILE_NODE_SECTORS (node); if (parent->is_grafted) break; } } } /* Even imported should be included. The only type of nodes that are not * heeded are the virtual nodes. */ if (node->is_file) { if (depth < 6) return; } else if (depth < 5) return; stats->num_deep ++; node->is_deep = TRUE; }
false
false
false
false
false
0
seekGame(int index) { IndexBaseType n = offset(index); if(!m_file->seek(n)) { qDebug() << "Seeking offset " << n << " failed!"; } readLine(); }
false
false
false
false
false
0
initialize(const char * szKeyBindingsKey, const char * szKeyBindingsDefaultValue) { gsf_init(); // create application-wide resources that // are shared by everything. // init keyboard language (cannot be in the constructor as it // requires the platform code already initialised setKbdLanguage(_getKbdLanguage()); // HACK: for now, this works from XAP code // TODO: where should this really go? char * szPathname = g_build_filename(getUserPrivateDirectory(), "custom.dic", NULL); UT_ASSERT(szPathname); m_pDict = new XAP_Dictionary(szPathname); FREEP(szPathname); UT_return_val_if_fail(m_pDict,false); m_pDict->load(); clearIdTable(); // // Set Smooth Scrolling // bool bEnableSmooth = true; getPrefsValueBool(XAP_PREF_KEY_EnableSmoothScrolling, &bEnableSmooth); if(bEnableSmooth) setEnableSmoothScrolling(true); else setEnableSmoothScrolling(false); // // Need to initialize the random number generator. // UT_uint32 t = static_cast<UT_uint32>(time(NULL)); UT_srandom(t); // Input mode initilization, taken out of the XAP_Frame const char * szBindings = NULL; EV_EditBindingMap * pBindingMap = NULL; if ((getPrefsValue(szKeyBindingsKey, static_cast<const gchar**>(&szBindings))) && (szBindings) && (*szBindings)) pBindingMap = m_pApp->getBindingMap(szBindings); if (!pBindingMap) pBindingMap = m_pApp->getBindingMap(szKeyBindingsDefaultValue); UT_ASSERT(pBindingMap); if (!m_pInputModes) { m_pInputModes = new XAP_InputModes(); UT_ASSERT(m_pInputModes); } bool bResult; bResult = m_pInputModes->createInputMode(szBindings,pBindingMap); UT_ASSERT(bResult); bResult = m_pInputModes->setCurrentMap(szBindings); UT_ASSERT(bResult); UT_UNUSED(bResult); // TODO deal with the error // check if the prefs are set to use specific graphics class const char * pszGraphics = NULL; if(getPrefsValue(XAP_PREF_KEY_DefaultGraphics, &pszGraphics)) { UT_uint32 iID = 0; // please leave this in hex format (the constants are defined in gr_Graphics.h as hex) sscanf(pszGraphics,"%x", &iID); if(iID != 0) { UT_DEBUGMSG(("Graphics %d requested as default\n", iID)); // first of all, check that it is registered GR_GraphicsFactory * pGF = getGraphicsFactory(); UT_return_val_if_fail(pGF,false); if(pGF->isRegistered(iID)) { pGF->registerAsDefault(iID, true); pGF->registerAsDefault(iID, false); } else { UT_DEBUGMSG(("Graphics not loaded\n")); } } } m_pScriptLibrary = new UT_ScriptLibrary(); return true; }
false
false
false
false
false
0
get_irq_infos(struct IsdnCardState *cs, struct isar_reg *ireg) { ireg->iis = cs->BC_Read_Reg(cs, 1, ISAR_IIS); ireg->cmsb = cs->BC_Read_Reg(cs, 1, ISAR_CTRL_H); ireg->clsb = cs->BC_Read_Reg(cs, 1, ISAR_CTRL_L); #if DUMP_MBOXFRAME if (cs->debug & L1_DEB_HSCX) debugl1(cs, "irq_stat(%02x,%02x,%d)", ireg->iis, ireg->cmsb, ireg->clsb); #endif }
false
false
false
false
false
0
CreateJingleVideoCodecElem(const VideoCodec& codec) { buzz::XmlElement* elem = new buzz::XmlElement(QN_JINGLE_RTP_PAYLOADTYPE); AddXmlAttr(elem, QN_ID, codec.id); elem->AddAttr(QN_NAME, codec.name); elem->AddElement(CreatePayloadTypeParameterElem( PAYLOADTYPE_PARAMETER_WIDTH, codec.width)); elem->AddElement(CreatePayloadTypeParameterElem( PAYLOADTYPE_PARAMETER_HEIGHT, codec.height)); elem->AddElement(CreatePayloadTypeParameterElem( PAYLOADTYPE_PARAMETER_FRAMERATE, codec.framerate)); return elem; }
false
false
false
false
false
0
gst_caps_from_string (const gchar * string) { GstCaps *caps; g_return_val_if_fail (string, FALSE); caps = gst_caps_new_empty (); if (gst_caps_from_string_inplace (caps, string)) { return caps; } else { gst_caps_unref (caps); return NULL; } }
false
false
false
false
false
0
boostCollision(bool boost) { // calculate boost from lab to rest if(!boost) { Lorentz5Momentum ptotal=incoming_.first ->momentum()+incoming_.second->momentum(); boost_ = LorentzRotation(-ptotal.boostVector()); Axis axis((boost_*incoming_.first ->momentum()).vect().unit()); if(axis.perp2()>0.) { double sinth(sqrt(sqr(axis.x())+sqr(axis.y()))); boost_.rotate(acos(-axis.z()),Axis(-axis.y()/sinth,axis.x()/sinth,0.)); } } // first call performs the boost and second inverse // get the particles to be boosted set<tPPtr> particles; addChildren(incoming_.first,particles); addChildren(incoming_.second,particles); // apply the boost for(set<tPPtr>::const_iterator cit=particles.begin(); cit!=particles.end();++cit) { (*cit)->transform(boost_); } if(!boost) boost_.invert(); }
false
false
false
false
false
0
ifile_read_header (ifile_db * idata, char **bufp) { char *line; char *token = NULL; long int i; long int num; if ((line = readline(bufp)) == NULL) return -1; /* read folder names */ token = strtok(line, " \t"); for (i = 0; token != NULL; i++) { EXT_ARRAY_SET(idata->folder_name, char *, i, ifile_strdup(token)); token = strtok(NULL, " \t"); } idata->num_folders = i; if ((line = readline(bufp)) == NULL) return -1; /* read word frequencies */ token = strtok(line, " \t"); for (i = 0; token != NULL; i++) { num = atoi(token); EXT_ARRAY_SET(idata->folder_freq, long int, i, num); idata->total_freq += num; token = strtok(NULL, " \t"); } if (i != idata->num_folders) ifile_verbosify(ifile_quiet, "Bad data file format - line #2\n"); if ((line = readline(bufp)) == NULL) return -1; /* read document frequencies */ token = strtok(line, " \t"); for (i = 0; token != NULL; i++) { num = atoi(token); EXT_ARRAY_SET(idata->folder_msg, long int, i, num); idata->total_docs += num; token = strtok(NULL, " \t"); } if (i != idata->num_folders) ifile_verbosify(ifile_quiet, "Bad data file format - line #3\n"); return idata->num_folders; }
false
false
false
false
false
0
fw_hdrs_free(struct fw_hdr *hdr) { struct fw_hdr *next; while (hdr) { next = hdr->next; kfree(hdr); hdr = next; } }
false
false
false
false
false
0
server_remove_player(struct player *pplayer) { const struct player_slot *pslot; fc_assert_ret(NULL != pplayer); /* save player slot */ pslot = pplayer->slot; log_normal(_("Removing player %s."), player_name(pplayer)); notify_conn(pplayer->connections, NULL, E_CONNECTION, ftc_server, _("You've been removed from the game!")); notify_conn(game.est_connections, NULL, E_CONNECTION, ftc_server, _("%s has been removed from the game."), player_name(pplayer)); if (is_barbarian(pplayer)) { server.nbarbarians--; } /* Don't use conn_list_iterate here because connection_detach() can be * recursive and free the next connection pointer. */ while (conn_list_size(pplayer->connections) > 0) { connection_detach(conn_list_get(pplayer->connections, 0), FALSE); } script_server_remove_exported_object(pplayer); /* Clear data saved in the other player structs. */ players_iterate(aplayer) { BV_CLR(aplayer->real_embassy, player_index(pplayer)); if (gives_shared_vision(aplayer, pplayer)) { remove_shared_vision(aplayer, pplayer); } } players_iterate_end; /* Remove citizens of this player from the cities of all other players. */ /* FIXME: add a special case if the server quits - no need to run this for * each player in that case. */ if (game.info.citizen_nationality) { cities_iterate(pcity) { if (city_owner(pcity) != pplayer) { citizens nationality = citizens_nation_get(pcity, pplayer->slot); if (nationality != 0) { /* Change nationality of the citizens to the nationality of the * city owner. */ citizens_nation_move(pcity, pplayer->slot, city_owner(pcity)->slot, nationality); city_refresh_queue_add(pcity); } } } cities_iterate_end city_refresh_queue_processing(); } /* AI type lost control of this player */ CALL_PLR_AI_FUNC(lost_control, pplayer, pplayer); /* We have to clear all player data before the ai memory is freed because * some function may depend on it. */ player_clear(pplayer, TRUE); if (!map_is_empty()) { remove_player_from_maps(pplayer); } player_map_free(pplayer); /* Destroy advisor and ai data. */ CALL_FUNC_EACH_AI(player_free, pplayer); adv_data_close(pplayer); player_destroy(pplayer); send_updated_vote_totals(NULL); /* must be called after the player was destroyed */ send_player_remove_info_c(pslot, NULL); /* Recalculate borders. */ map_calculate_borders(); }
false
false
false
false
false
0
data_stack_grow(SRE_STATE* state, Py_ssize_t size) { Py_ssize_t minsize, cursize; minsize = state->data_stack_base+size; cursize = state->data_stack_size; if (cursize < minsize) { void* stack; cursize = minsize+minsize/4+1024; TRACE(("allocate/grow stack %d\n", cursize)); stack = PyMem_REALLOC(state->data_stack, cursize); if (!stack) { data_stack_dealloc(state); return SRE_ERROR_MEMORY; } state->data_stack = (char *)stack; state->data_stack_size = cursize; } return 0; }
false
true
false
false
false
1
ecs_famille_chaine__affiche(const ecs_int_t num_fam, ecs_famille_t *fam_tete) { int ifam; ecs_famille_t *ptr_fam; /*xxxxxxxxxxxxxxxxxxxxxxxxxxx Instructions xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ assert(fam_tete != NULL); ifam = 1; ptr_fam = fam_tete; while (ptr_fam != NULL && ifam++ != num_fam) ptr_fam = ptr_fam->l_famille_sui; assert(ptr_fam != NULL); ecs_famille__affiche(ptr_fam); }
false
false
false
false
false
0
generate_characters (int groups, int repeat, int group_min, int group_max, int limit, const char *charset) { static int is_initialized = FALSE; int charset_length, group, chars; char *buffer; /* On first (usually only) call, seed the random number generator. */ if (!is_initialized) { srand (time (NULL)); is_initialized = TRUE; } /* Allocate the buffer for repeating groups. */ buffer = safe_malloc (group_max); /* Generate groups up to the number requested or to the character limit. */ charset_length = strlen (charset); chars = 0; for (group = 0; group < groups && (limit == 0 || chars < limit); group++) { int size, index, count; /* Randomize the group size between min and max inclusive. */ size = group_min + rand () % (group_max - group_min + 1); /* Pick and buffer random characters from the set. */ for (index = 0; index < size; index++) buffer[index] = charset[rand () % charset_length]; /* * Repeatedly print the group as requested. It's always printed once, * then repeated for the desired repeat count. Break altogether if we * hit any set limit on printed characters. */ count = 0; do { for (index = 0; index < size && (limit == 0 || chars < limit); index++, chars++) { /* Print with immediate buffer flush. */ putchar (buffer[index]); fflush (stdout); } putchar (' '); fflush (stdout); } while (count++ < repeat && (limit == 0 || chars < limit)); } free (buffer); }
false
false
false
false
false
0
bmc150_accel_get_bw(struct bmc150_accel_data *data, int *val, int *val2) { int i; for (i = 0; i < ARRAY_SIZE(bmc150_accel_samp_freq_table); ++i) { if (bmc150_accel_samp_freq_table[i].bw_bits == data->bw_bits) { *val = bmc150_accel_samp_freq_table[i].val; *val2 = bmc150_accel_samp_freq_table[i].val2; return IIO_VAL_INT_PLUS_MICRO; } } return -EINVAL; }
false
false
false
false
false
0
shmem_init(void) { int err = OSHMEM_SUCCESS; int provided; int required = SHMEM_THREAD_SINGLE; if (oshmem_shmem_initialized) { /* * SPEC: If start_pes() is called multiple times, subsequent calls have no effect. */ return; } shmem_api_logger_output = opal_output_open(NULL); opal_output_set_verbosity(shmem_api_logger_output, oshmem_shmem_api_verbose); err = oshmem_shmem_init(0, NULL, required, &provided); if (OSHMEM_SUCCESS != err) { /* since spec does not propagete error to user we can only abort */ SHMEM_API_ERROR("SHMEM failed to initialize - aborting"); oshmem_shmem_abort(-1); } OPAL_CR_INIT_LIBRARY(); }
false
false
false
false
false
0
guess_dm_gone(int t1, int t2) { int wait = t2; char *avoid = getenv("X11VNC_AVOID_WINDOWS"); time_t tcheck = last_client; if (last_open_xdisplay > last_client) { /* better time for -display WAIT:... */ tcheck = last_open_xdisplay; } if (avoid && !strcmp(avoid, "never")) { return 1; } if (!screen || !screen->clientHead) { return 0; } if (avoid) { int n = atoi(avoid); if (n > 1) { wait = n; } else { wait = 90; } } else { static time_t saw_wm = 0; wait = t2; X_LOCK; if (wm_running()) { if (saw_wm == 0) { saw_wm = time(NULL); } else if (time(NULL) <= saw_wm + 2) { /* try to wait a few seconds after transition */ ; } else { wait = t1; } } X_UNLOCK; } if (getenv("DEBUG_WM_RUNNING")) { rfbLog("guess_dm_gone: wait=%d\n", wait); } /* we assume they've logged in OK after wait seconds... */ if (time(NULL) <= tcheck + wait) { return 0; } return 1; }
false
false
false
false
false
0
vartable_limits_set_by_var (gint j, GGobiData *d) { vartabled *vt = vartable_element_get (j, d); GtkTreeModel *model; GtkTreeIter iter; if (!vartable_iter_from_varno(j, d, &model, &iter)) return; if (vt) { switch (vt->vartype) { case integer: case counter: case uniform: case real: gtk_tree_store_set(GTK_TREE_STORE(model), &iter, VT_REAL_DATA_MIN, vt->lim_display.min, VT_REAL_DATA_MAX, vt->lim_display.max, -1); if (vt->lim_specified_p) { gtk_tree_store_set(GTK_TREE_STORE(model), &iter, VT_REAL_USER_MIN, vt->lim_specified_tform.min, VT_REAL_USER_MAX, vt->lim_specified_tform.max, -1); } break; case categorical: gtk_tree_store_set(GTK_TREE_STORE(model), &iter, VT_CAT_DATA_MIN, (gint)vt->lim_display.min, VT_CAT_DATA_MAX, (gint)vt->lim_display.max, -1); if (vt->lim_specified_p) { gtk_tree_store_set(GTK_TREE_STORE(model), &iter, VT_CAT_USER_MIN, (gint)vt->lim_specified_tform.min, VT_CAT_USER_MAX, (gint)vt->lim_specified_tform.max, -1); } break; case all_vartypes: g_printerr ("(vartable_limits_set_by_var) %d: illegal variable type %d\n", j, all_vartypes); break; } } }
false
false
false
false
false
0
openLib(const string& lib_name) { bool success = (dlopen(lib_name.c_str(), RTLD_LAZY | RTLD_GLOBAL) != 0); if (!success) { char buffer[BUFF_SIZE]; sprintf(buffer, "%s did not load properly.\n Error: %s", lib_name.c_str(), dlerror()); OpenBabel::obErrorLog.ThrowError(__FUNCTION__, buffer, OpenBabel::obError); } return success; }
false
false
false
false
false
0
head_check(unsigned long head,int check_layer) { /* look for a valid header. if check_layer > 0, then require that nLayer = check_layer. */ /* bits 13-14 = layer 3 */ int nLayer=4-((head>>17)&3); if( (head & 0xffe00000) != 0xffe00000) { /* syncword */ return FALSE; } #if 0 if(!((head>>17)&3)) { /* bits 13-14 = layer 3 */ return FALSE; } #endif if (3 != nLayer) { #if defined (USE_LAYER_1) || defined (USE_LAYER_2) if (4==nLayer) return FALSE; #else return FALSE; #endif } if (check_layer>0) { if (nLayer != check_layer) return FALSE; } if( ((head>>12)&0xf) == 0xf) { /* bits 16,17,18,19 = 1111 invalid bitrate */ return FALSE; } if( ((head>>10)&0x3) == 0x3 ) { /* bits 20,21 = 11 invalid sampling freq */ return FALSE; } return TRUE; }
false
false
false
false
false
0
intr_proc(int state) { if(_inraw){ if(state){ #if HAS_TERMIOS _raw_tty.c_lflag |= ISIG; /* enable signals */ tcsetattr(STDIN_FD, TCSADRAIN, &_raw_tty); #elif HAS_TERMIO _raw_tty.c_lflag |= ISIG; /* enable signals */ (void)ioctl(STDIN_FD, TCSETAW, &_raw_tty); #else /* RAW_BSD */ _raw_tchars.t_intrc = ctrl('C'); (void)ioctl(STDIN_FD, TIOCSETC, &_raw_tchars); #endif } else{ #if HAS_TERMIOS _raw_tty.c_lflag &= ~ISIG; /* disable signals */ tcsetattr(STDIN_FD, TCSADRAIN, &_raw_tty); #elif HAS_TERMIO _raw_tty.c_lflag &= ~ISIG; /* disable signals */ (void)ioctl(STDIN_FD, TCSETAW, &_raw_tty); #else /* RAW_BSD */ _raw_tchars.t_intrc = -1; (void)ioctl(STDIN_FD, TIOCSETC, &_raw_tchars); #endif } } }
false
false
false
false
false
0
cb_build_perform_until (cb_tree condition, cb_tree varying) { cb_tree x; x = cb_build_perform (CB_PERFORM_UNTIL); CB_PERFORM (x)->test = condition; CB_PERFORM (x)->varying = varying; return x; }
false
false
false
true
false
1
xmlXPtrRangesEqual(xmlXPathObjectPtr range1, xmlXPathObjectPtr range2) { if (range1 == range2) return(1); if ((range1 == NULL) || (range2 == NULL)) return(0); if (range1->type != range2->type) return(0); if (range1->type != XPATH_RANGE) return(0); if (range1->user != range2->user) return(0); if (range1->index != range2->index) return(0); if (range1->user2 != range2->user2) return(0); if (range1->index2 != range2->index2) return(0); return(1); }
false
false
false
false
false
0
restore_display(dispwin *p) { /* Restore the ramdac */ if (p->or != NULL) { p->set_ramdac(p, p->or, 0); p->or->del(p->or); p->or = NULL; debugr("Restored original ramdac\n"); } if (p->r != NULL) { p->r->del(p->r); p->r = NULL; } #if defined(UNIX_X11) #if ScreenSaverMajorVersion >= 1 && ScreenSaverMinorVersion >= 1 /* X11R7.1 */ if (p->xsssuspend) { XScreenSaverSuspend(p->mydisplay, False); p->xsssuspend = 0; } #endif if (p->xssvalid) { /* Restore the X11 screen saver state */ XSetScreenSaver(p->mydisplay, p->timeout, p->interval, p->prefer_blanking, p->allow_exposures); } /* Restore the xscreensaver */ if (p->xssrunning) { system("xscreensaver -nosplash 2>/dev/null >/dev/null&"); } if (p->gnomessrunning && p->gnomepid != -1) { kill(p->gnomepid, SIGKILL); /* Kill the process inhibiting the screen saver */ } /* Restore the KDE screen saver state */ if (p->kdessrunning) { system("dcop kdesktop KScreensaverIface enable true 2>&1 >/dev/null"); } /* Restore DPMS */ if (p->dpmsenabled) { DPMSEnable(p->mydisplay); } /* Flush any changes out */ XSync(p->mydisplay, False); #endif /* UNIX_X11 */ }
false
false
false
false
false
0
getElement(const int position) { Link* link; int i; ASSERT(this); if (position < 1 OR position > this->size) { return NUL(const void*); } else if (position == 1) { return this->first->element; } else if (position == this->size) { return this->last->element; } else { for (link = this->first, i = 1; link AND i < position; link = link->next, i++) ; ASSERT(link); return link->element; } }
false
false
false
true
false
1
gtt_reports_menu_prepend_entry (GnomeApp *app, GnomeUIInfo *new_entry) { int i, nitems; GnomeUIInfo * current_sysmenu, *new_sysmenu; current_sysmenu = gtt_get_reports_menu (); for (i=0; GNOME_APP_UI_ENDOFINFO != current_sysmenu[i].type; i++) {} nitems = i+1; new_sysmenu = g_new0 (GnomeUIInfo, nitems+1); new_sysmenu[0] = *new_entry; memcpy (&new_sysmenu[1], current_sysmenu, nitems*sizeof(GnomeUIInfo)); gtt_set_reports_menu (app, new_sysmenu); }
false
false
false
false
false
0
ntru_gen_tern_poly(NtruIGFState *s, int df, NtruTernPoly *p) { p->N = s->N; p->num_ones = df; p->num_neg_ones = df; int idx; int r[p->N]; memset(r, 0, sizeof r); int t = 0; while (t < df) { ntru_IGF_next(s, &idx); if (!r[idx]) { p->neg_ones[t] = idx; r[idx] = 1; t++; } } t = 0; while (t < df) { ntru_IGF_next(s, &idx); if (!r[idx]) { p->ones[t] = idx; r[idx] = 1; t++; } } }
false
false
false
false
false
0
gribFileSeekOld(int fileID, long *offset) { /* position file pointer after GRIB */ int ch; int buffersize = 4096; unsigned char buffer[4096]; int retry = 4096; int i; void *fileptr; *offset = 0; fileptr = filePtr(fileID); ch = filePtrGetc(fileptr); if ( ch == EOF ) return (-1); buffer[0] = ch; ch = filePtrGetc(fileptr); if ( ch == EOF ) return (-1); buffer[1] = ch; ch = filePtrGetc(fileptr); if ( ch == EOF ) return (-1); buffer[2] = ch; ch = filePtrGetc(fileptr); if ( ch == EOF ) return (-1); buffer[3] = ch; /* fileRead(fileID, buffer, 4); */ while ( retry-- ) { for ( i = 0; i < buffersize-4; ++i ) { if (buffer[i ] == 'G' && buffer[i+1] == 'R' && buffer[i+2] == 'I' && buffer[i+3] == 'B') { if ( CGRIBEX_Debug ) Message("record offset = %d", (int) *offset); return (0); } else { ch = filePtrGetc(fileptr); if ( ch == EOF ) return (-1); buffer[i+4] = ch; (*offset)++; } } buffer[0] = buffer[i ]; buffer[1] = buffer[i+1]; buffer[2] = buffer[i+2]; buffer[3] = buffer[i+3]; } if ( CGRIBEX_Debug ) Message("record offset = %d", (int) *offset); return (1); }
false
false
false
false
false
0
tpci200_slot_irq(struct slot_irq *slot_irq) { irqreturn_t ret; if (!slot_irq) return -ENODEV; ret = slot_irq->handler(slot_irq->arg); return ret; }
false
false
false
false
false
0
dowhatdoes_core(q, cbuf) char q; char *cbuf; { dlb *fp; char bufr[BUFSZ]; register char *buf = &bufr[6], *ep, ctrl, meta; fp = dlb_fopen(CMDHELPFILE, "r"); if (!fp) { pline("Cannot open data file!"); return 0; } ctrl = ((q <= '\033') ? (q - 1 + 'A') : 0); meta = ((0x80 & q) ? (0x7f & q) : 0); while(dlb_fgets(buf,BUFSZ-6,fp)) { if ((ctrl && *buf=='^' && *(buf+1)==ctrl) || (meta && *buf=='M' && *(buf+1)=='-' && *(buf+2)==meta) || *buf==q) { ep = index(buf, '\n'); if(ep) *ep = 0; if (ctrl && buf[2] == '\t'){ buf = bufr + 1; (void) strncpy(buf, "^? ", 8); buf[1] = ctrl; } else if (meta && buf[3] == '\t'){ buf = bufr + 2; (void) strncpy(buf, "M-? ", 8); buf[2] = meta; } else if(buf[1] == '\t'){ buf = bufr; buf[0] = q; (void) strncpy(buf+1, " ", 7); } (void) dlb_fclose(fp); Strcpy(cbuf, buf); return cbuf; } } (void) dlb_fclose(fp); return (char *)0; }
false
false
false
false
false
0
sge_infotext_all_spaces(char* text) { int i; int back = 0; if (text != NULL) { for(i=0;i<strlen(text);i++) { if(text[i] != ' ') { back = 1; break; } } } return back; }
false
false
false
false
false
0
net_connect(char *host, u_short port, int binary, int strong) /* * Function: Connect to the given host and port * Returns: sock if OK * -1 if error * -2 if host not found * * Supports virtual hosting. Use enable_virtual_host() to configure. * Set binary to 1 if a binary (non-buffered) connection is needed. * Set strong to 1 if a connect() is considered successful only if we * detect a read first. * * Actually, in most cases we don't care whether we're connected. If * net_connect() doesn't fail, then we start dumping data to the socket. * We'll get an EOF soon enough if we didn't actually connect. */ { IP inaddr; int sock; char flags; struct sockaddr_in sin; struct hostent *hp; if(host == NULL || !host[0]) { internal("net: in net_connect(), host is NULL."); return -1; } /* setup address */ memset((char *)&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons(port); /* Is host in numeric IP form? */ inaddr = (IP)inet_addr(host); if(inaddr != INADDR_NONE) { /* yep */ xmemcpy((char *)&sin.sin_addr, (char *)&inaddr, sizeof(inaddr)); } else { /* nope */ hp = gethostbyname(host); if(hp == NULL || (hp->h_length != 4 && hp->h_length != 8)) return -2; /* host not found */ xmemcpy((char *)&sin.sin_addr, hp->h_addr, hp->h_length); } flags = SOCK_CONNECTING; if(binary) flags |= SOCK_BINARY; if(strong) flags |= SOCK_STRONG; sock = new_socket(flags); if(sock == -1) return -1; /* fatal */ set_socket(sock, SO_KEEPALIVE, 1); set_socket(sock, SO_LINGER, 0); /* * Virtual host? (enabled using enable_virtual_host()) */ if(vh.vh_enabled) bind_virtual_host(sock); if(connect(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* non-blocking I/O (we'll catch error as EOF during write) */ if(net_errno() == EINPROGRESS) return sock; debug("net: in net_connect(), connect() failed: %s (sock=%d)", net_errstr(), sock); destroy_socket(sock); return -1; } return sock; }
false
false
false
false
false
0
delete_link(void *address, object link_ar) {object *ar,*ar_end,*p; p=0; ar = link_ar->v.v_self; ar_end = (object *)&(link_ar->ust.ust_self[link_ar->v.v_fillp]); while (ar < ar_end) { if (*ar && *((void **)*ar)==address) { p = (object *) *ar; *ar=0; *p = *(ar+1); number_unlinked++;} ar=ar+2;} if (number_unlinked > 40) link_ar->v.v_fillp= clean_link_array(link_ar->v.v_self,ar_end); }
false
false
false
false
false
0
better_p (const_edge e1, const_edge e2) { if (e1->count != e2->count) return e1->count > e2->count; if (e1->src->frequency * e1->probability != e2->src->frequency * e2->probability) return (e1->src->frequency * e1->probability > e2->src->frequency * e2->probability); /* This is needed to avoid changes in the decision after CFG is modified. */ if (e1->src != e2->src) return e1->src->index > e2->src->index; return e1->dest->index > e2->dest->index; }
false
false
false
false
false
0
isStringOfOnes(uint64_t Mask, unsigned &LSB, unsigned &Length) { unsigned First = findFirstSet(Mask); uint64_t Top = (Mask >> First) + 1; if ((Top & -Top) == Top) { LSB = First; Length = findFirstSet(Top); return true; } return false; }
false
false
false
false
false
0
defineGeometry() { using namespace python; docstring_options doc_options(true, true, false); multidef("convexHull", pythonConvexHull<double, float, Int32>(), args("points"), "Compute the convex hull of a point set.\n" "\n" "For details see convexHull_ in the vigra C++ documentation.\n\n"); }
false
false
false
false
false
0
sr_release(struct cdrom_device_info *cdi) { struct scsi_cd *cd = cdi->handle; if (cd->device->sector_size > 2048) sr_set_blocklength(cd, 2048); }
false
false
false
false
false
0
slapi_send_ldap_result_from_pb( Slapi_PBlock *pb) { int err; char *matched; char *text; IFP fn = NULL; slapi_pblock_get(pb, SLAPI_RESULT_CODE, &err); slapi_pblock_get(pb, SLAPI_RESULT_TEXT, &text); slapi_pblock_get(pb, SLAPI_RESULT_MATCHED, &matched); slapi_pblock_get(pb,SLAPI_PLUGIN_DB_RESULT_FN,(void*)&fn); if (NULL != fn) { (*fn)(pb,err,matched,text,0,NULL); } slapi_pblock_set(pb, SLAPI_RESULT_TEXT, NULL); slapi_pblock_set(pb, SLAPI_RESULT_MATCHED, NULL); slapi_ch_free((void **)&matched); slapi_ch_free((void **)&text); }
false
false
false
false
false
0
fsl_asrc_dma_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; struct device *dev = rtd->platform->dev; struct fsl_asrc *asrc_priv = dev_get_drvdata(dev); struct fsl_asrc_pair *pair; pair = kzalloc(sizeof(struct fsl_asrc_pair), GFP_KERNEL); if (!pair) { dev_err(dev, "failed to allocate pair\n"); return -ENOMEM; } pair->asrc_priv = asrc_priv; runtime->private_data = pair; snd_pcm_hw_constraint_integer(substream->runtime, SNDRV_PCM_HW_PARAM_PERIODS); snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware); return 0; }
false
false
false
false
false
0
custom_list_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n) { CustomList *custom_list; CustomRecord *parent_record; g_return_val_if_fail (CUSTOM_IS_LIST (tree_model), FALSE); g_return_val_if_fail (iter != NULL, FALSE); custom_list = CUSTOM_LIST(tree_model); if (parent == NULL) { /* special case: if parent == NULL, set iter to n-th top-level row */ if( n >= custom_list->num_visibles_rows ) return FALSE; iter->stamp = custom_list->stamp; iter->user_data = custom_list->visibles_rows[n]; return TRUE; } /* get the parent structure */ parent_record = parent->user_data; g_return_val_if_fail (parent_record != NULL, FALSE); /* check n not too big (also check if child exist) */ if (n >= parent_record -> number_of_children || !parent_record -> has_expander) return FALSE; /* there is at least one child, so set iter on that child */ iter->stamp = custom_list->stamp; iter->user_data = parent_record -> children_rows[n]; return TRUE; }
false
false
false
false
false
0
setMapType(QGraphicsGeoMap::MapType mapType) { if (d_ptr->mapData && d_ptr->manager) { if (!d_ptr->manager->supportedMapTypes().contains(mapType)) return; d_ptr->mapData->setMapType(mapType); } }
false
false
false
false
false
0
parse_cli(int argc,char *argv[],int *operation,int *mode,char **hostname,char **port) { int opt; *operation=OPERATION_DEFAULT; *mode=MODE_DEFAULT; *port=NULL; *hostname=NULL; while ((opt=getopt(argc,argv,"h46rz"))!=-1) { switch (opt) { case 'h': *operation=OPERATION_HELP; return 0; break; case '4': (*mode)&=~MODE_IP6MODE; (*mode)|=MODE_IP4MODE; break; case '6': (*mode)&=~MODE_IP4MODE; (*mode)|=MODE_IP6MODE; break; case 'r': (*mode)|=MODE_RAW; break; case 'z': (*mode)|=MODE_NO_SSL; break; default: return 0; break; } } if (argc-optind<2) { fprintf(stderr,"Hostname and port is expected!\n"); return 0; } *hostname=argv[optind]; *port=argv[optind+1]; return 1; }
false
true
false
false
true
1
OTF_RStream_readEvents( OTF_RStream* rstream, OTF_HandlerArray* handlers ) { uint64_t recordcount= 0; int ret; # ifdef OTF_DEBUG uint64_t currenttime= 0; uint64_t oldtime= 0; # endif char next_char = '\0'; /* initialized? */ if ( NULL == rstream->eventBuffer ) { /* init */ rstream->eventBuffer= OTF_RStream_getEventBuffer( rstream ); if( NULL == rstream->eventBuffer ) { OTF_Error( "ERROR in function %s, file: %s, line: %i:\n " "the stream has no event buffer.\n", __FUNCTION__, __FILE__, __LINE__ ); return OTF_READ_ERROR; } /* jump to start time - update buffer-firstTime, lastTime, curTime */ OTF_RBuffer_searchTime( rstream->eventBuffer, 0 ); } while ( NULL != OTF_RBuffer_getRecord( rstream->eventBuffer ) ) { if ( recordcount >= rstream->recordLimit ) { /* record count limit reached, return */ return recordcount; } /* debug check */ # ifdef OTF_DEBUG oldtime= currenttime; /* inlined OTF_RBuffer_getCurrentTime() */ currenttime= rstream->eventBuffer->time; if ( oldtime > currenttime ) { OTF_Error( "ERROR in function %s, file: %s, line: %i:\n " "Time does decrease!!! %llu < %llu.\n", __FUNCTION__, __FILE__, __LINE__, (unsigned long long) currenttime, (unsigned long long) oldtime ); return OTF_READ_ERROR; } # endif /* remember next record type, if it will be a none KEYVALUE record, dont't account it in recordcount */ next_char = *(rstream->eventBuffer->buffer + rstream->eventBuffer->pos); ret= OTF_Reader_parseEventRecord( rstream->eventBuffer, handlers ); if ( 0 == ret ) { /* maybe later an errorhandler gives the record to the user */ return OTF_READ_ERROR; } /* Now reset the KeyValue list, if we consumed a none KEYVALUE record */ if ( next_char != OTF_KEYWORD_F_KEYVALUE_PREFIX /* 'K' */ ) { OTF_KeyValueList_reset(rstream->eventBuffer->list); recordcount++; } } return recordcount; }
false
false
false
false
false
0
print() { std::ostringstream os; os<<"\n"; for (int i=0; i<4; ++i) { for (int j=0; j<4; ++j) { os << m[i][j] <<" "; } os << "\n"; } return os.str(); }
false
false
false
false
false
0
berEncodePasswordData( struct berval **requestBV, char *objectDN, char *password, char *password2) { int err = 0, rc=0; BerElement *requestBer = NULL; char * utf8ObjPtr = NULL; int utf8ObjSize = 0; char * utf8PwdPtr = NULL; int utf8PwdSize = 0; char * utf8Pwd2Ptr = NULL; int utf8Pwd2Size = 0; utf8ObjSize = strlen(objectDN)+1; utf8ObjPtr = objectDN; if (password != NULL) { utf8PwdSize = strlen(password)+1; utf8PwdPtr = password; } if (password2 != NULL) { utf8Pwd2Size = strlen(password2)+1; utf8Pwd2Ptr = password2; } /* Allocate a BerElement for the request parameters.*/ if((requestBer = ber_alloc()) == NULL) { err = NMAS_E_FRAG_FAILURE; goto Cleanup; } if (password != NULL && password2 != NULL) { /* BER encode the NMAS Version, the objectDN, and the password */ rc = ber_printf(requestBer, "{iooo}", NMAS_LDAP_EXT_VERSION, utf8ObjPtr, utf8ObjSize, utf8PwdPtr, utf8PwdSize, utf8Pwd2Ptr, utf8Pwd2Size); } else if (password != NULL) { /* BER encode the NMAS Version, the objectDN, and the password */ rc = ber_printf(requestBer, "{ioo}", NMAS_LDAP_EXT_VERSION, utf8ObjPtr, utf8ObjSize, utf8PwdPtr, utf8PwdSize); } else { /* BER encode the NMAS Version and the objectDN */ rc = ber_printf(requestBer, "{io}", NMAS_LDAP_EXT_VERSION, utf8ObjPtr, utf8ObjSize); } if (rc < 0) { err = NMAS_E_FRAG_FAILURE; goto Cleanup; } else { err = 0; } /* * Convert the BER we just built to a berval that we'll send with the extended request. */ if(ber_flatten(requestBer, requestBV) == LBER_ERROR) { err = NMAS_E_FRAG_FAILURE; goto Cleanup; } Cleanup: if(requestBer) { ber_free(requestBer, 1); } return err; }
false
false
false
false
false
0
add_db_arg(char *arg) { char **temp; db5util_db_args_size++; temp = realloc(db5util_db_args, sizeof(char *) * (db5util_db_args_size + 1)); if (temp == NULL) return 0; db5util_db_args = temp; db5util_db_args[db5util_db_args_size-1] = arg; db5util_db_args[db5util_db_args_size] = NULL; return 1; }
false
false
false
false
false
0
yperr_string (const int error) { const char *str; switch (error) { case YPERR_SUCCESS: str = N_("Success"); break; case YPERR_BADARGS: str = N_("Request arguments bad"); break; case YPERR_RPC: str = N_("RPC failure on NIS operation"); break; case YPERR_DOMAIN: str = N_("Can't bind to server which serves this domain"); break; case YPERR_MAP: str = N_("No such map in server's domain"); break; case YPERR_KEY: str = N_("No such key in map"); break; case YPERR_YPERR: str = N_("Internal NIS error"); break; case YPERR_RESRC: str = N_("Local resource allocation failure"); break; case YPERR_NOMORE: str = N_("No more records in map database"); break; case YPERR_PMAP: str = N_("Can't communicate with portmapper"); break; case YPERR_YPBIND: str = N_("Can't communicate with ypbind"); break; case YPERR_YPSERV: str = N_("Can't communicate with ypserv"); break; case YPERR_NODOM: str = N_("Local domain name not set"); break; case YPERR_BADDB: str = N_("NIS map database is bad"); break; case YPERR_VERS: str = N_("NIS client/server version mismatch - can't supply service"); break; case YPERR_ACCESS: str = N_("Permission denied"); break; case YPERR_BUSY: str = N_("Database is busy"); break; default: str = N_("Unknown NIS error code"); break; } return _(str); }
false
false
false
false
false
0
selectsupported(aa_context * c) { int supported = c->params.supported; char text[40]; int ch; do { static char *texts[] = { "Normal characters", "Half bright (dim)", "Double bright (bold)", "Bold font", "Reversed", "8 bit ascii", "Control characters"}; int masks[] = {AA_NORMAL_MASK, AA_DIM_MASK, AA_BOLD_MASK, AA_BOLDFONT_MASK, AA_REVERSE_MASK, AA_EIGHT, AA_ALL}; int i; for (i = 0; i < 7; i++) { sprintf(text, "%i %-20s:%-12s", i + 1, texts[i], (SUPPORTED & masks[i]) ? ((supported & masks[i]) ? "On" : "Off") : "Unsupported"); aa_puts(context, 0, i, AA_SPECIAL, text); } aa_puts(context, 0, i, AA_SPECIAL, "8 Leave this menu"); aa_flush(context); while ((ch = tolower(aa_getkey(context, 1))) < '1' || ch > '8'); ch -= '1'; if (ch < 7) supported ^= masks[ch]; } while (ch < 7); aa_setsupported(c, supported); }
true
true
false
false
false
1
rfc1035_hostnamecmp(const char *p, const char *q) { while (*p || *q) { if (*p == '.' || *q == '.' ) { if ( (*p && *p != '.') || (*q && *q != '.')) return (1); while (*p == '.') ++p; while (*q == '.') ++q; continue; } if (!*p || !*q) return (1); if ( tl(*p) != tl(*q)) return (1); ++p; ++q; } return (0); }
false
false
false
false
false
0
get_goodcode_snippet (const char *source_version) { if (strcmp (source_version, "1.3") == 0) return "class conftest {}\n"; if (strcmp (source_version, "1.4") == 0) return "class conftest { static { assert(true); } }\n"; if (strcmp (source_version, "1.5") == 0) return "class conftest<T> { T foo() { return null; } }\n"; error (EXIT_FAILURE, 0, _("invalid source_version argument to compile_java_class")); return NULL; }
false
false
false
false
false
0
MacroAddFunction(char *lookStr, unsigned int *recognizedLen, char **invStr) { MACROENTRY tMEntry; MACROTEXT *curMT; MACROTEXT *nextMT; unsigned int i; tMEntry.macroName = (char *)"%add()"; if (strlen(lookStr) > MAXREPLACESTRING) { LexError("Out of Temporary string replacement memory inside builtin macro %add()\n"); return; } if (ParseBuiltInMacroParms(&tMEntry, lookStr)) { MacroMathFunction(&tMEntry, recognizedLen, invStr, "+"); // skip ',' strlen(parm2)+ ')' (*recognizedLen) += strlen(tMEntry.firstMacroParms->next->macroText)+2; } curMT = tMEntry.firstMacroParms; // in this case only one string was allocated free(curMT->macroText); for (i=0; i<tMEntry.numParms; i++) { nextMT = curMT->next; free(curMT); curMT = nextMT; } }
false
false
false
false
false
0
dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan, int chnum, struct dwc2_qtd *qtd) { struct dwc2_hcd_iso_packet_desc *frame_desc; u32 len; if (!qtd->urb) return 0; frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index]; len = dwc2_get_actual_xfer_length(hsotg, chan, chnum, qtd, DWC2_HC_XFER_COMPLETE, NULL); if (!len) { qtd->complete_split = 0; qtd->isoc_split_offset = 0; return 0; } frame_desc->actual_length += len; if (chan->align_buf) { dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__); dma_unmap_single(hsotg->dev, chan->qh->dw_align_buf_dma, chan->qh->dw_align_buf_size, DMA_FROM_DEVICE); memcpy(qtd->urb->buf + frame_desc->offset + qtd->isoc_split_offset, chan->qh->dw_align_buf, len); } qtd->isoc_split_offset += len; if (frame_desc->actual_length >= frame_desc->length) { frame_desc->status = 0; qtd->isoc_frame_index++; qtd->complete_split = 0; qtd->isoc_split_offset = 0; } if (qtd->isoc_frame_index == qtd->urb->packet_count) { dwc2_host_complete(hsotg, qtd, 0); dwc2_release_channel(hsotg, chan, qtd, DWC2_HC_XFER_URB_COMPLETE); } else { dwc2_release_channel(hsotg, chan, qtd, DWC2_HC_XFER_NO_HALT_STATUS); } return 1; /* Indicates that channel released */ }
false
false
false
false
false
0
tda10086_set_tone(struct dvb_frontend *fe, enum fe_sec_tone_mode tone) { struct tda10086_state* state = fe->demodulator_priv; u8 t22k_off = 0x80; dprintk ("%s\n", __func__); if (state->config->diseqc_tone) t22k_off = 0; switch (tone) { case SEC_TONE_OFF: tda10086_write_byte(state, 0x36, t22k_off); break; case SEC_TONE_ON: tda10086_write_byte(state, 0x36, 0x01 + t22k_off); break; } return 0; }
false
false
false
false
false
0
cloneInternal(ExecState* exec, Interpreter* ctx, JSValue* in, QSet<JSObject*>& path) { if (exec->hadException()) // e.g. OOM or DATA_CLONE_ERR return jsUndefined(); switch (in->type()) { case NumberType: case BooleanType: case UndefinedType: case NullType: case StringType: // Values -> can pass straight through. return in; case ObjectType: { JSObject* obj = in->getObject(); // Some things are handled by creating a new wrapper for their value; // this includes both JS-builtin types like autoboxing wrappers, and // those of HTML5 types we support that have deep cloning specified. // This goes through valueClone. if (JSObject* copy = obj->valueClone(ctx)) return copy; // Otherwise, we can only clone if it it's an array or plain object // that isn't already on our path from the root if (path.contains(obj)) { setDOMException(exec, DOM::DOMException::DATA_CLONE_ERR); break; } path.insert(obj); JSObject* clone = 0; if (obj->inherits(&ArrayInstance::info)) { clone = new ArrayInstance(ctx->builtinArrayPrototype(), 0); } else if (!obj->classInfo()) { // plain object clone = new JSObject(ctx->builtinObjectPrototype()); } else { // Something complicated and native -> error out setDOMException(exec, DOM::DOMException::DATA_CLONE_ERR); break; } // Copy over clones of properties PropertyNameArray props; obj->getOwnPropertyNames(exec, props, PropertyMap::ExcludeDontEnumProperties); for (PropertyNameArrayIterator i = props.begin(); i != props.end(); ++i) { JSValue* propVal = obj->get(exec, *i); clone->put(exec, *i, cloneInternal(exec, ctx, propVal, path)); // ### flags? } path.remove(obj); return clone; } default: // shouldn't happen! setDOMException(exec, DOM::DOMException::DATA_CLONE_ERR); } return jsUndefined(); }
false
false
false
false
false
0
zxid_set_epr_secmech(zxid_conf* cf, zxid_epr* epr, const char* secmec) { if (!epr) { ERR("Null EPR. %p", epr); return; } if (!epr->Metadata) epr->Metadata = zx_NEW_a_Metadata(cf->ctx, &epr->gg); if (!epr->Metadata->SecurityContext) epr->Metadata->SecurityContext = zx_NEW_di_SecurityContext(cf->ctx, &epr->Metadata->gg); if (secmec) { epr->Metadata->SecurityContext->SecurityMechID = zx_dup_elem(cf->ctx, &epr->Metadata->SecurityContext->gg, zx_di_SecurityMechID_ELEM, secmec); INFO("SecurityMechID set to(%s)", secmec); } else { epr->Metadata->SecurityContext->SecurityMechID = zx_dup_elem(cf->ctx, &epr->Metadata->SecurityContext->gg, zx_di_SecurityMechID_ELEM, 0); INFO("SecurityMechID set null %d", 0); } }
false
false
false
false
false
0
git_config_file__snapshot(git_config_backend **out, diskfile_backend *in) { diskfile_readonly_backend *backend; backend = git__calloc(1, sizeof(diskfile_readonly_backend)); GITERR_CHECK_ALLOC(backend); backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; git_mutex_init(&backend->header.values_mutex); backend->snapshot_from = in; backend->header.readonly = 1; backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; backend->header.parent.open = config_readonly_open; backend->header.parent.get = config_get; backend->header.parent.set = config_set_readonly; backend->header.parent.set_multivar = config_set_multivar_readonly; backend->header.parent.del = config_delete_readonly; backend->header.parent.del_multivar = config_delete_multivar_readonly; backend->header.parent.iterator = config_iterator_new; backend->header.parent.free = backend_readonly_free; *out = (git_config_backend *)backend; return 0; }
false
false
false
false
false
0
EuclideanDotFunc(float X,float Y, float scale) { const float AbsX=fabsf(X); const float AbsY=fabsf(Y); float Result; if ((AbsX+AbsY)>1.0f) { Result=((AbsY-1.0f)*(AbsY-1.0f)+ (AbsX-1.0f)*(AbsX-1.0f))-2.0f; } else { Result=2.0f-(AbsY*AbsY+AbsX*AbsX); } Result/=2.0f; return static_cast<int>(Result*scale); }
false
false
false
false
false
0
picture_start_code_name (guint8 psc) { guint i; const struct { guint8 psc; const gchar *name; } psc_names[] = { { 0x00, "Picture Start"}, { 0xb0, "Reserved"}, { 0xb1, "Reserved"}, { 0xb2, "User Data Start"}, { 0xb3, "Sequence Header Start"}, { 0xb4, "Sequence Error"}, { 0xb5, "Extension Start"}, { 0xb6, "Reserved"}, { 0xb7, "Sequence End"}, { 0xb8, "Group Start"}, { 0xb9, "Program End"} }; if (psc < 0xB0 && psc > 0) return "Slice Start"; for (i = 0; i < G_N_ELEMENTS (psc_names); i++) if (psc_names[i].psc == psc) return psc_names[i].name; return "UNKNOWN"; }
false
false
false
false
false
0
midgard_connection_get_user(MidgardConnection *self) { g_return_val_if_fail(self != NULL, NULL); if (self->priv->user == NULL) return NULL; if (!G_IS_OBJECT(self->priv->user)) return NULL; return MIDGARD_USER(self->priv->user); }
false
false
false
false
false
0
insertion_sort(int *numbers, int count, compare_cb cmp) { int i = 0; int j = 0; int temp = 0; int *target = malloc(count * sizeof(int)); if (!target) die("Memory error"); memcpy(target, numbers, count * sizeof(int)); for (i = 0; i < count; i++) { j = i; while ( j > 0 && cmp(target[j-1], target[j]) > 0 ) { temp = target[j]; target[j] = target[j-1]; target[j-1] = temp; j--; } } return target; }
false
false
false
false
false
0
RateAdd(size_t nbytes, size_t bwlimit, double timestamp) { int update_nominal = 0; if( m_history_last && timestamp < m_history_last->timestamp ){ // time went backward ClearHistory(); }else Cleanup(); if( timestamp <= m_last_realtime ){ // time went backward m_ontime = 0; m_last_size = 0; m_last_realtime = 0; } if( m_history_last && (time_t)timestamp == (time_t)(m_history_last->timestamp) ) m_history_last->bytes += nbytes; else{ if( BWSAMPLE *p = NewSample() ){ p->timestamp = timestamp; p->bytes = nbytes; if( m_history_last ){ m_history_last->next = p; update_nominal = 1; } else m_history = p; m_history_last = p; } } if( !m_selfrate && m_ontime ){ double late=timestamp - (m_last_realtime + (double)m_last_size / bwlimit); // double tmplate = late; // keep the change under control in case the system gets weird on us if( late < 0 ) late /= 2; else if( m_late && late > m_late ) late = m_late / 2; m_late += late; // CONSOLE.Debug("%p late %f->%f: %f", this, tmplate, late, m_late); m_ontime = 0; } if( m_selfrate && bwlimit && m_last_realtime && m_selfrate->LastSize() / (timestamp - m_selfrate->LastRealtime()) > bwlimit ) m_last_size += nbytes; else if( !m_selfrate && bwlimit && m_last_realtime && m_last_size / (timestamp - m_last_realtime) > bwlimit ) m_last_size += nbytes; else{ m_last_realtime = timestamp; m_last_size = nbytes; } if( nbytes > BUF_DEF_SIZ ){ m_prev_realtime = m_recent_realtime; m_prev_size = m_recent_size; m_recent_realtime = timestamp; m_recent_size = nbytes; }else m_recent_size += nbytes; if( m_selfrate ){ if( update_nominal ){ m_update_nominal = 1; (void)RateMeasure(); // updates nominal } m_selfrate->RateAdd(nbytes, bwlimit, timestamp); } //if(!m_selfrate) CONSOLE.Debug("%p RateAdd %u @ %f next=%f", this, // nbytes, timestamp, m_last_realtime + (double)m_last_size / bwlimit); }
false
false
false
false
false
0
getline(char **lineptr, size_t *n) { ssize_t ret; switch (s_type) { case TEXT: ret = ::getline(lineptr, n, text.s_fp); if (ret == -1) return text_status(); break; case GZIP: { size_t offset = 0; if (!*lineptr) { *n = 128; *lineptr = (char*)xmalloc(*n); } while (1) { char *line = *lineptr; if (gzgets(gzip.s_fp, line + offset, *n - offset)) { ret = strlen(line); if (line[ret - 1] == '\n') return ret; } else { return gzip_status(); } offset = *n - 1; *n *= 2; *lineptr = (char*)xrealloc(line, *n); } break; } default: assert(0); } return ret; }
false
false
false
false
false
0
game_keypress (gint key) { if (game_state == STATE_PLAYING) { switch (key) { case KBD_NW: if (player_move (-1, -1)) { move_robots (); } break; case KBD_N: if (player_move (0, -1)) { move_robots (); } break; case KBD_NE: if (player_move (1, -1)) { move_robots (); } break; case KBD_W: if (player_move (-1, 0)) { move_robots (); } break; case KBD_STAY: if (player_move (0, 0)) { move_robots (); } break; case KBD_E: if (player_move (1, 0)) { move_robots (); } break; case KBD_SW: if (player_move (-1, 1)) { move_robots (); } break; case KBD_S: if (player_move (0, 1)) { move_robots (); } break; case KBD_SE: if (player_move (1, 1)) { move_robots (); } break; case KBD_TELE: if (safe_teleport ()) { move_robots (); } break; case KBD_RTEL: if (random_teleport ()) { move_robots (); } break; case KBD_WAIT: game_state = STATE_WAITING; break; } } }
false
false
false
false
false
0
toString(bool verbose, const std::string &outputFormat) const { // Save this ErrorMessage in plain text. // No template is given if (outputFormat.length() == 0) { std::ostringstream text; if (!_callStack.empty()) text << callStackToString(_callStack) << ": "; if (_severity != Severity::none) text << "(" << Severity::toString(_severity) << ") "; text << (verbose ? _verboseMessage : _shortMessage); return text.str(); } // template is given. Reformat the output according to it else { std::string result = outputFormat; findAndReplace(result, "{id}", _id); findAndReplace(result, "{severity}", Severity::toString(_severity)); findAndReplace(result, "{message}", verbose ? _verboseMessage : _shortMessage); if (!_callStack.empty()) { std::ostringstream oss; oss << _callStack.back().line; findAndReplace(result, "{line}", oss.str()); findAndReplace(result, "{file}", _callStack.back().getfile()); } else { findAndReplace(result, "{file}", ""); findAndReplace(result, "{line}", ""); } return result; } }
false
false
false
false
false
0
output_check_banner(bool live_check) { if (user_opts.check && live_check) { pg_log(PG_REPORT, "Performing Consistency Checks on Old Live Server\n"); pg_log(PG_REPORT, "------------------------------------------------\n"); } else { pg_log(PG_REPORT, "Performing Consistency Checks\n"); pg_log(PG_REPORT, "-----------------------------\n"); } }
false
false
false
false
false
0
iiter_foreach(IAnjutaIterable* iiter, GFunc callback, gpointer data, GError** e) { SourceviewCell* cell = SOURCEVIEW_CELL(iiter); gint old_offset = cell->priv->offset; iiter_first (IANJUTA_ITERABLE(cell), NULL); while (iiter_next(IANJUTA_ITERABLE(cell), NULL)) { (*callback)(cell, data); } cell->priv->offset = old_offset; }
false
false
false
false
false
0
GetRRDisplayString_rdb(mDNS *const m, const ResourceRecord *rr, RDataBody *rd) { char *ptr = m->MsgBuffer; mDNSu32 length = mDNS_snprintf(m->MsgBuffer, 79, "%4d %##s %s ", rr->rdlength, rr->name.c, DNSTypeName(rr->rrtype)); switch (rr->rrtype) { case kDNSType_A: mDNS_snprintf(m->MsgBuffer+length, 79-length, "%.4a", &rd->ip); break; case kDNSType_CNAME:// Same as PTR case kDNSType_PTR: mDNS_snprintf(m->MsgBuffer+length, 79-length, "%##s", &rd->name); break; case kDNSType_HINFO:// Display this the same as TXT (just show first string) case kDNSType_TXT: mDNS_snprintf(m->MsgBuffer+length, 79-length, "%#s", rd->txt.c); break; case kDNSType_AAAA: mDNS_snprintf(m->MsgBuffer+length, 79-length, "%.16a", &rd->ipv6); break; case kDNSType_SRV: mDNS_snprintf(m->MsgBuffer+length, 79-length, "%##s", &rd->srv.target); break; default: mDNS_snprintf(m->MsgBuffer+length, 79-length, "RDLen %d: %s", rr->rdlength, rd->data); break; } for (ptr = m->MsgBuffer; *ptr; ptr++) if (*ptr < ' ') *ptr='.'; return(m->MsgBuffer); }
false
false
false
false
false
0
m_print(GtkWidget *, cchar *) // use GTK print v.9.4 { PXM * print_addgrid(PXM *printimage); // v.11.01 int err; char *printfile; PXM *printimage, *pxmtemp; zfuncs::F1_help_topic = "print"; if (! curr_file) return; // no image file printfile = strdupz(get_zuserdir(),20,"printfile"); // make temp print file: strcat(printfile,"/printfile.tif"); // ~/.fotoxx/printfile.tif v.11.03 if (Fpxm16) printimage = PXM_convbpc(Fpxm16); else printimage = PXM_copy(Fpxm8); pxmtemp = print_addgrid(printimage); // add grid lines if wanted v.11.01 if (pxmtemp) { PXM_free(printimage); printimage = pxmtemp; } err = PXBwrite(printimage,printfile); PXM_free(printimage); if (err) { zfree(printfile); // v.10.3 return; } print_image_paper_setup(mWin); // new v.11.10 print_image_margins_setup(mWin); print_image_file(printfile); zfree(printfile); return; }
false
false
false
false
false
0
ipa_get_member_ptr_load_param (tree rhs, bool use_delta) { tree rec, ref_field, ref_offset, fld, fld_offset, ptr_field, delta_field; if (TREE_CODE (rhs) == COMPONENT_REF) { ref_field = TREE_OPERAND (rhs, 1); rhs = TREE_OPERAND (rhs, 0); } else ref_field = NULL_TREE; if (TREE_CODE (rhs) != MEM_REF) return NULL_TREE; rec = TREE_OPERAND (rhs, 0); if (TREE_CODE (rec) != ADDR_EXPR) return NULL_TREE; rec = TREE_OPERAND (rec, 0); if (TREE_CODE (rec) != PARM_DECL || !type_like_member_ptr_p (TREE_TYPE (rec), &ptr_field, &delta_field)) return NULL_TREE; ref_offset = TREE_OPERAND (rhs, 1); if (ref_field) { if (integer_nonzerop (ref_offset)) return NULL_TREE; if (use_delta) fld = delta_field; else fld = ptr_field; return ref_field == fld ? rec : NULL_TREE; } if (use_delta) fld_offset = byte_position (delta_field); else fld_offset = byte_position (ptr_field); return tree_int_cst_equal (ref_offset, fld_offset) ? rec : NULL_TREE; }
false
false
false
false
false
0
challenge_cb(struct fp_img_dev *dev, int status, uint16_t num_regs, unsigned char *data, void *user_data) { struct fpi_ssm *ssm = user_data; struct uru4k_dev *urudev = dev->priv; unsigned char *respdata; PK11Context *ctx; int r, outlen; r = status; if (status != 0) { fpi_ssm_mark_aborted(ssm, status); return; } /* submit response */ /* produce response from challenge */ respdata = g_malloc(CR_LENGTH); ctx = PK11_CreateContextBySymKey(urudev->cipher, CKA_ENCRYPT, urudev->symkey, urudev->param); if (PK11_CipherOp(ctx, respdata, &outlen, CR_LENGTH, data, CR_LENGTH) != SECSuccess || PK11_Finalize(ctx) != SECSuccess) { fp_err("Failed to encrypt challenge data"); r = -ECONNABORTED; g_free(respdata); } PK11_DestroyContext(ctx, PR_TRUE); if (r >= 0) { r = write_regs(dev, REG_RESPONSE, CR_LENGTH, respdata, response_cb, ssm); g_free(respdata); } if (r < 0) fpi_ssm_mark_aborted(ssm, r); }
false
false
false
false
false
0
isns_scn_deregister(char *name) { int err; uint16_t flags, length = 0; char buf[2048]; struct isns_hdr *hdr = (struct isns_hdr *) buf; struct isns_tlv *tlv; if (!isns_fd) if (isns_connect() < 0) return 0; memset(buf, 0, sizeof(buf)); tlv = (struct isns_tlv *) hdr->pdu; length += isns_tlv_set_string(&tlv, ISNS_ATTR_ISCSI_NAME, name); length += isns_tlv_set_string(&tlv, ISNS_ATTR_ISCSI_NAME, name); flags = ISNS_FLAG_CLIENT | ISNS_FLAG_LAST_PDU | ISNS_FLAG_FIRST_PDU; isns_hdr_init(hdr, ISNS_FUNC_SCN_DEREG, length, flags, ++transaction, 0); err = write(isns_fd, buf, length + sizeof(struct isns_hdr)); if (err < 0) eprintf("%d %m\n", length); return 0; }
false
false
false
false
false
0
rsvg_handle_dispose (GObject *instance) { RsvgHandle *self = (RsvgHandle *) instance; if (self->priv->is_disposed) goto chain; self->priv->is_disposed = TRUE; g_hash_table_destroy (self->priv->entities); rsvg_defs_free (self->priv->defs); g_hash_table_destroy (self->priv->css_props); if (self->priv->user_data_destroy) (*self->priv->user_data_destroy) (self->priv->user_data); if (self->priv->title) g_string_free (self->priv->title, TRUE); if (self->priv->desc) g_string_free (self->priv->desc, TRUE); if (self->priv->metadata) g_string_free (self->priv->metadata, TRUE); if (self->priv->base_uri) g_free (self->priv->base_uri); if (self->priv->base_gfile) { g_object_unref (self->priv->base_gfile); self->priv->base_gfile = NULL; } if (self->priv->data_input_stream) { g_object_unref (self->priv->data_input_stream); self->priv->data_input_stream = NULL; } g_clear_object (&self->priv->cancellable); chain: G_OBJECT_CLASS (rsvg_handle_parent_class)->dispose (instance); }
false
false
false
false
false
0
i2c_bit_read ( struct i2c_interface *i2c, struct i2c_device *i2cdev, unsigned int offset, uint8_t *data, unsigned int len ) { struct i2c_bit_basher *i2cbit = container_of ( i2c, struct i2c_bit_basher, i2c ); struct bit_basher *basher = &i2cbit->basher; int rc = 0; DBGC ( basher, "I2CBIT %p reading from device %x: ", basher, i2cdev->dev_addr ); open_bit ( basher ); for ( ; ; data++, offset++ ) { /* Select device for writing */ if ( ( rc = i2c_select ( basher, i2cdev, offset, I2C_WRITE ) ) != 0 ) break; /* Abort at end of data */ if ( ! ( len-- ) ) break; /* Select offset */ if ( ( rc = i2c_send_byte ( basher, offset ) ) != 0 ) break; /* Select device for reading */ if ( ( rc = i2c_select ( basher, i2cdev, offset, I2C_READ ) ) != 0 ) break; /* Read byte */ *data = i2c_recv_byte ( basher ); DBGC ( basher, "%02x ", *data ); } DBGC ( basher, "%s\n", ( rc ? "failed" : "" ) ); i2c_stop ( basher ); close_bit ( basher ); return rc; }
false
false
false
false
false
0
ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg) { struct pnfs_block_layout *bl = BLK_LO2EXT(NFS_I(arg->inode)->layout); size_t count = 0, buffer_size = PAGE_SIZE; __be32 *start_p; int ret; dprintk("%s enter\n", __func__); arg->layoutupdate_page = alloc_page(GFP_NOFS); if (!arg->layoutupdate_page) return -ENOMEM; start_p = page_address(arg->layoutupdate_page); arg->layoutupdate_pages = &arg->layoutupdate_page; retry: ret = ext_tree_encode_commit(bl, start_p + 1, buffer_size, &count); if (unlikely(ret)) { ext_tree_free_commitdata(arg, buffer_size); buffer_size = ext_tree_layoutupdate_size(count); count = 0; arg->layoutupdate_pages = kcalloc(DIV_ROUND_UP(buffer_size, PAGE_SIZE), sizeof(struct page *), GFP_NOFS); if (!arg->layoutupdate_pages) return -ENOMEM; start_p = __vmalloc(buffer_size, GFP_NOFS, PAGE_KERNEL); if (!start_p) { kfree(arg->layoutupdate_pages); return -ENOMEM; } goto retry; } *start_p = cpu_to_be32(count); arg->layoutupdate_len = ext_tree_layoutupdate_size(count); if (unlikely(arg->layoutupdate_pages != &arg->layoutupdate_page)) { void *p = start_p, *end = p + arg->layoutupdate_len; int i = 0; for ( ; p < end; p += PAGE_SIZE) arg->layoutupdate_pages[i++] = vmalloc_to_page(p); } dprintk("%s found %zu ranges\n", __func__, count); return 0; }
false
false
false
false
false
0
dce_v10_0_crtc_disable(struct drm_crtc *crtc) { struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); struct drm_device *dev = crtc->dev; struct amdgpu_device *adev = dev->dev_private; struct amdgpu_atom_ss ss; int i; dce_v10_0_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); if (crtc->primary->fb) { int r; struct amdgpu_framebuffer *amdgpu_fb; struct amdgpu_bo *rbo; amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb); rbo = gem_to_amdgpu_bo(amdgpu_fb->obj); r = amdgpu_bo_reserve(rbo, false); if (unlikely(r)) DRM_ERROR("failed to reserve rbo before unpin\n"); else { amdgpu_bo_unpin(rbo); amdgpu_bo_unreserve(rbo); } } /* disable the GRPH */ dce_v10_0_grph_enable(crtc, false); amdgpu_atombios_crtc_powergate(crtc, ATOM_ENABLE); for (i = 0; i < adev->mode_info.num_crtc; i++) { if (adev->mode_info.crtcs[i] && adev->mode_info.crtcs[i]->enabled && i != amdgpu_crtc->crtc_id && amdgpu_crtc->pll_id == adev->mode_info.crtcs[i]->pll_id) { /* one other crtc is using this pll don't turn * off the pll */ goto done; } } switch (amdgpu_crtc->pll_id) { case ATOM_PPLL0: case ATOM_PPLL1: case ATOM_PPLL2: /* disable the ppll */ amdgpu_atombios_crtc_program_pll(crtc, amdgpu_crtc->crtc_id, amdgpu_crtc->pll_id, 0, 0, ATOM_DISABLE, 0, 0, 0, 0, 0, false, &ss); break; default: break; } done: amdgpu_crtc->pll_id = ATOM_PPLL_INVALID; amdgpu_crtc->adjusted_clock = 0; amdgpu_crtc->encoder = NULL; amdgpu_crtc->connector = NULL; }
false
false
false
false
false
0