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
getSpotLocation(icp, id, nest, offset, data, len) IMIC *icp; unsigned int id; int nest; int offset; char *data; int len; { IMConnection *conn = icp->im->connection; IMPSAttributes *ap = &icp->preedit_attr; TRACE(("imlib:getSpotLocation()\n")); if (nest == NEST_STATUS) { IMCancelRequest(conn, offset); IMSendError(conn, IMBadSomething, icp->im->id, icp->id, "spot location isn't a status attribute"); return -1; } if (!(ap->set_mask & ATTR_MASK_SPOT_LOCATION)) { fillPSDefault(icp, NEST_PREEDIT, (unsigned long)ATTR_MASK_SPOT_LOCATION); } IMPutC16(conn, id); /* attribute ID */ IMPutC16(conn, 4); /* value length */ IMPutI16(conn, ap->spot_location.x); IMPutI16(conn, ap->spot_location.y); return 0; }
false
false
false
false
false
0
HB_GSUB_Add_Feature( HB_GSUBHeader* gsub, HB_UShort feature_index, HB_UInt property ) { HB_UShort i; HB_Feature feature; HB_UInt* properties; HB_UShort* index; HB_UShort lookup_count; /* Each feature can only be added once */ if ( !gsub || feature_index >= gsub->FeatureList.FeatureCount || gsub->FeatureList.ApplyCount == gsub->FeatureList.FeatureCount ) return ERR(HB_Err_Invalid_Argument); gsub->FeatureList.ApplyOrder[gsub->FeatureList.ApplyCount++] = feature_index; properties = gsub->LookupList.Properties; feature = gsub->FeatureList.FeatureRecord[feature_index].Feature; index = feature.LookupListIndex; lookup_count = gsub->LookupList.LookupCount; for ( i = 0; i < feature.LookupListCount; i++ ) { HB_UShort lookup_index = index[i]; if (lookup_index < lookup_count) properties[lookup_index] |= property; } return HB_Err_Ok; }
false
false
false
false
false
0
get_scalar_value(const char* as_something) const { VObject* unconst_this=const_cast<VObject*>(this); if(Value* scalar=fclass.get_scalar(*unconst_this)) if(Junction* junction=scalar->get_junction()) if(const Method *method=junction->method){ VMethodFrame frame(*method, 0 /*no caller*/, *unconst_this); Value *param; if(size_t param_count=frame.method_params_count()){ if(param_count==1){ param=new VString(*new String(as_something)); frame.store_params(&param, 1); } else throw Exception(PARSER_RUNTIME, 0, "scalar getter method can't have more then 1 parameter (has %d parameters)", param_count); } // no need for else frame.empty_params() pa_thread_request().execute_method(frame); return &frame.result().as_value(); } return 0; }
false
false
false
false
false
0
_appendLDMLExtensionAsKeywords(const char* ldmlext, ExtensionListEntry** appendTo, char* buf, int32_t bufSize, UBool *posixVariant, UErrorCode *status) { const char *p, *pNext, *pSep; const char *pBcpKey, *pBcpType; const char *pKey, *pType; int32_t bcpKeyLen = 0, bcpTypeLen; ExtensionListEntry *kwd, *nextKwd; ExtensionListEntry *kwdFirst = NULL; int32_t bufIdx = 0; int32_t len; pNext = ldmlext; pBcpKey = pBcpType = NULL; while (pNext) { p = pSep = pNext; /* locate next separator char */ while (*pSep) { if (*pSep == SEP) { break; } pSep++; } if (*pSep == 0) { /* last subtag */ pNext = NULL; } else { pNext = pSep + 1; } if (pBcpKey == NULL) { pBcpKey = p; bcpKeyLen = (int32_t)(pSep - p); } else { pBcpType = p; bcpTypeLen = (int32_t)(pSep - p); /* BCP key to locale key */ len = _bcp47ToLDMLKey(pBcpKey, bcpKeyLen, buf + bufIdx, bufSize - bufIdx - 1, status); if (U_FAILURE(*status)) { goto cleanup; } pKey = buf + bufIdx; bufIdx += len; *(buf + bufIdx) = 0; bufIdx++; /* BCP type to locale type */ len = _bcp47ToLDMLType(pKey, -1, pBcpType, bcpTypeLen, buf + bufIdx, bufSize - bufIdx - 1, status); if (U_FAILURE(*status)) { goto cleanup; } pType = buf + bufIdx; bufIdx += len; *(buf + bufIdx) = 0; bufIdx++; /* Special handling for u-va-posix, since we want to treat this as a variant, not */ /* as a keyword. */ if ( !uprv_strcmp(pKey,POSIX_KEY) && !uprv_strcmp(pType,POSIX_VALUE) ) { *posixVariant = TRUE; } else { /* create an ExtensionListEntry for this keyword */ kwd = uprv_malloc(sizeof(ExtensionListEntry)); if (kwd == NULL) { *status = U_MEMORY_ALLOCATION_ERROR; goto cleanup; } kwd->key = pKey; kwd->value = pType; if (!_addExtensionToList(&kwdFirst, kwd, FALSE)) { *status = U_ILLEGAL_ARGUMENT_ERROR; uprv_free(kwd); goto cleanup; } } /* for next pair */ pBcpKey = NULL; pBcpType = NULL; } } if (pBcpKey != NULL) { *status = U_ILLEGAL_ARGUMENT_ERROR; goto cleanup; } kwd = kwdFirst; while (kwd != NULL) { nextKwd = kwd->next; _addExtensionToList(appendTo, kwd, FALSE); kwd = nextKwd; } return; cleanup: kwd = kwdFirst; while (kwd != NULL) { nextKwd = kwd->next; uprv_free(kwd); kwd = nextKwd; } }
false
false
false
false
false
0
close_socket() { if (_sockfd == INVALID_SOCKET) { return; } /* in case of death shutdown to avoid blocking at close() */ if (shutdown(_sockfd, SHUT_RDWR) == SOCKET_ERROR && get_socket_errno() != ENOTCONN) { perror("shutdown"); } else if (closesocket(_sockfd) == SOCKET_ERROR) { perror("close"); } _sockfd= INVALID_SOCKET; }
false
false
false
false
false
0
prepareBasis(const vector<PDT::Colour>& basis) { if ( id33bar.empty() ) makeIds(); if ( basis == id33bar || basis == id33bar8 ) return 1; if ( basis == id33bar33bar ) return 2; if ( basis == id33bar88 ) return 2; throw Exception() << "Cannot handle colour configuration" << Exception::abortnow; return 0; }
false
false
false
false
false
0
skip_data_till_eof() { while (GET != my_b_EOF) ; }
false
false
false
false
false
0
check_precond(struct transaction_t *txn, const void *data, const char *etag, time_t lastmod) { const char *lock_token = NULL; unsigned locked = 0; hdrcache_t hdrcache = txn->req_hdrs; const char **hdr; time_t since; #ifdef WITH_DAV struct dav_data *ddata = (struct dav_data *) data; /* Check for a write-lock on the source */ if (ddata && ddata->lock_expire > time(NULL)) { lock_token = ddata->lock_token; switch (txn->meth) { case METH_DELETE: case METH_LOCK: case METH_MOVE: case METH_POST: case METH_PUT: /* State-changing method: Only the lock owner can execute and MUST provide the correct lock-token in an If header */ if (strcmp(ddata->lock_ownerid, httpd_userid)) return HTTP_LOCKED; locked = 1; break; case METH_UNLOCK: /* State-changing method: Authorized in meth_unlock() */ break; case METH_ACL: case METH_MKCALENDAR: case METH_MKCOL: case METH_PROPPATCH: /* State-changing method: Locks on collections unsupported */ break; default: /* Non-state-changing method: Always allowed */ break; } } #else assert(!data); #endif /* WITH_DAV */ /* Per RFC 4918, If is similar to If-Match, but with lock-token submission. Per Section 5 of HTTPbis, Part 4, LOCK errors supercede preconditions */ if ((hdr = spool_getheader(hdrcache, "If"))) { /* State tokens (sync-token, lock-token) and Etags */ if (!eval_if(hdr[0], etag, lock_token, &locked)) return HTTP_PRECOND_FAILED; } if (locked) { /* Correct lock-token was not provided in If header */ return HTTP_LOCKED; } /* Evaluate other precondition headers per Section 5 of HTTPbis, Part 4 */ /* Step 1 */ if ((hdr = spool_getheader(hdrcache, "If-Match"))) { if (!etag_match(hdr, etag)) return HTTP_PRECOND_FAILED; /* Continue to step 3 */ } /* Step 2 */ else if ((hdr = spool_getheader(hdrcache, "If-Unmodified-Since"))) { since = message_parse_date((char *) hdr[0], PARSE_DATE|PARSE_TIME|PARSE_ZONE| PARSE_GMT|PARSE_NOCREATE); if (since && (lastmod > since)) return HTTP_PRECOND_FAILED; /* Continue to step 3 */ } /* Step 3 */ if ((hdr = spool_getheader(hdrcache, "If-None-Match"))) { if (etag_match(hdr, etag)) { if (txn->meth == METH_GET || txn->meth == METH_HEAD) return HTTP_NOT_MODIFIED; else return HTTP_PRECOND_FAILED; } /* Continue to step 5 */ } /* Step 4 */ else if ((txn->meth == METH_GET || txn->meth == METH_HEAD) && (hdr = spool_getheader(hdrcache, "If-Modified-Since"))) { since = message_parse_date((char *) hdr[0], PARSE_DATE|PARSE_TIME|PARSE_ZONE| PARSE_GMT|PARSE_NOCREATE); if (lastmod <= since) return HTTP_NOT_MODIFIED; /* Continue to step 5 */ } /* Step 5 */ if (txn->flags.ranges && /* Only if we support Range requests */ txn->meth == METH_GET && (hdr = spool_getheader(hdrcache, "Range"))) { if ((hdr = spool_getheader(hdrcache, "If-Range"))) { since = message_parse_date((char *) hdr[0], PARSE_DATE|PARSE_TIME|PARSE_ZONE| PARSE_GMT|PARSE_NOCREATE); } /* Only process Range if If-Range isn't present or validator matches */ if (!hdr || (since && (lastmod <= since)) || !etagcmp(hdr[0], etag)) return HTTP_PARTIAL; } /* Step 6 */ return HTTP_OK; }
true
true
false
false
false
1
__ecereInstMeth___ecereNameSpace__ecere__gui__controls__Button_NotifyClicked__00000003(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__Instance * button, int x, int y, unsigned int mods) { struct __ecereNameSpace__ecere__gfx__ColorDropBox * __ecerePointer___ecereNameSpace__ecere__gfx__ColorDropBox = (struct __ecereNameSpace__ecere__gfx__ColorDropBox *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__ecere__gfx__ColorDropBox->offset) : 0); __ecereProp___ecereNameSpace__ecere__gui__Window_Set_visible(__ecerePointer___ecereNameSpace__ecere__gfx__ColorDropBox->defined, 0x0); __ecereProp___ecereNameSpace__ecere__gui__Window_Set_visible(__ecerePointer___ecereNameSpace__ecere__gfx__ColorDropBox->system, 0x1); __ecerePointer___ecereNameSpace__ecere__gfx__ColorDropBox->listBox = __ecerePointer___ecereNameSpace__ecere__gfx__ColorDropBox->system; return 0x1; }
false
false
false
false
false
0
Ndo_framestep_cmd(Nv_data * data, /* Local data */ Tcl_Interp * interp, /* Current interpreter */ int argc, /* Number of arguments */ char **argv /* Argument strings */ ) { /* Parse arguments */ long step; int render_type; if (argc != 3) { Tcl_SetResult(interp, "Error: should be Ndo_framestep frame_# [TRUE | FALSE]", TCL_VOLATILE); return (TCL_ERROR); } if (Tcl_GetInt(interp, argv[1], (int *)&step) != TCL_OK) return (TCL_ERROR); if (Tcl_GetBoolean(interp, argv[2], &render_type) != TCL_OK) return (TCL_ERROR); /* Call the function */ GK_do_framestep((int)step, render_type); return (TCL_OK); }
false
false
false
false
false
0
parse_htpl_for___fwd(stack, untag) int untag; STR stack; { TOKEN token; static done = 0; STR buff; int code; static int nesting = 0; static int refcount = 0; refcount++; makepersist(stack); if (numtokens < 1) RETURN(croak("%sFOR called with %d arguments, minimum needed is 1", (untag ? "/" : ""), numtokens)) if (numtokens > 4) RETURN(croak("%sFOR called with %d arguments, maximum needed is 4", (untag ? "/" : ""), numtokens)) pushscope(scope_for, 0); if (numtokens <= 1) { printfcode("foreach (1 .. %s) {\n", gettoken(1)); } if (numtokens >= 2 && numtokens <= 2) { printfcode("foreach ${\"%s\"} (1 .. %s) {\n", gettoken(1), gettoken(2)); } if (numtokens >= 3 && numtokens <= 3) { printfcode("foreach ${\"%s\"} (%s .. %s) {\n", gettoken(1), gettoken(2), gettoken(3)); } if (numtokens >= 4 && numtokens <= 4) { printfcode("for (${\"%s\"} = %s; ${\"%s\"} <= %s; ${\"%s\"} += %s) {\n", gettoken(1), gettoken(2), gettoken(1), gettoken(3), gettoken(1), gettoken(4)); } nesting = 0; RETURN(1) }
false
false
false
false
false
0
LoadWordList(char const filename[]) // where filename is listname.nn.list { FILE *f; f = fopen(filename,"r"); current_line = 0; list_t *l = newList(); // get the nn letters of filename int strl = strlen(filename); l->bit = 0x10*(filename[strl-7]-'0') + 0x01*(filename[strl-6]-'0'); strcpy(l->name,strrchr(filename,'/')+1); str_cutat(l->name,'.'); newSyntaxList("dummy"); // all variables go here int mode = 0; int count = 0; while (!feof(f)) { ReadNextLine(f, true); char *str = tempstr; str = str_skipspace(str); // do not allow empty lines (should we?) if (str_empty(str)) continue; if (mode == 0) { if (!strcmp(str,"-")) { // steal the variables from dummy syntax l->assignments = syntaxlist->var; syntaxlist->var = NULL; mode++; continue; } if (str[0] == '@') { HandleVarSet(str); continue; } printf("Error while reading %s: Unknown meaning (%s)\n",filename,str); exit(1); } if (count == WORDS_PER_FILE-1) { printf("Error while readomg %s: Too many words in file\n",filename); exit(1); } l->words[count] = strdup(str); count++; } fclose(f); l->words[count] = NULL; // free dummy syntax deleteVars(syntaxlist); delete syntaxlist; syntaxlist = NULL; }
false
false
false
false
true
1
hawki_load_frameset( const cpl_frameset * fset, int chip, cpl_type ptype) { cpl_imagelist * out ; cpl_image * ima ; int i ; /* Test entries */ if (fset == NULL) return NULL ; if (chip < 1 || chip > HAWKI_NB_DETECTORS) return NULL ; /* Create the output imagelist */ out = cpl_imagelist_new() ; /* Loop on the frames */ for (i=0 ; i<cpl_frameset_get_size(fset) ; i++) { ima = hawki_load_image(fset, i, chip, ptype) ; if (ima == NULL) { cpl_msg_error(__func__, "Cannot load %dth frame (chip %d)", i+1, chip) ; cpl_imagelist_delete(out) ; return NULL ; } cpl_imagelist_set(out, ima, i) ; } return out ; }
false
false
false
false
false
0
p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd) { int result = 0; struct p80211ioctl_req *req = (struct p80211ioctl_req *) ifr; wlandevice_t *wlandev = dev->ml_priv; u8 *msgbuf; netdev_dbg(dev, "rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len); #ifdef SIOCETHTOOL if (cmd == SIOCETHTOOL) { result = p80211netdev_ethtool(wlandev, (void __user *)ifr->ifr_data); goto bail; } #endif /* Test the magic, assume ifr is good if it's there */ if (req->magic != P80211_IOCTL_MAGIC) { result = -ENOSYS; goto bail; } if (cmd == P80211_IFTEST) { result = 0; goto bail; } else if (cmd != P80211_IFREQ) { result = -ENOSYS; goto bail; } /* Allocate a buf of size req->len */ msgbuf = kmalloc(req->len, GFP_KERNEL); if (msgbuf) { if (copy_from_user(msgbuf, (void __user *)req->data, req->len)) result = -EFAULT; else result = p80211req_dorequest(wlandev, msgbuf); if (result == 0) { if (copy_to_user ((void __user *)req->data, msgbuf, req->len)) { result = -EFAULT; } } kfree(msgbuf); } else { result = -ENOMEM; } bail: /* If allocate,copyfrom or copyto fails, return errno */ return result; }
false
false
false
false
false
0
do_power_off (GduWindow *window) { UDisksObject *object; GList *objects = NULL; GList *siblings, *l; UDisksDrive *drive; const gchar *heading; const gchar *message; object = window->current_object; drive = udisks_object_peek_drive (object); objects = g_list_append (NULL, object); /* include other drives this will affect */ siblings = udisks_client_get_drive_siblings (window->client, drive); for (l = siblings; l != NULL; l = l->next) { UDisksDrive *sibling = UDISKS_DRIVE (l->data); UDisksObject *sibling_object = (UDisksObject *) g_dbus_interface_get_object (G_DBUS_INTERFACE (sibling)); if (sibling_object != NULL) objects = g_list_append (objects, sibling_object); } if (siblings != NULL) { /* Translators: Heading for powering off a device with multiple drives */ heading = _("Are you sure you want to power off the drives?"); /* Translators: Message for powering off a device with multiple drives */ message = _("This operation will prepare the system for the following drives to be powered down and removed."); if (!gdu_utils_show_confirmation (GTK_WINDOW (window), heading, message, _("_Power Off"), NULL, NULL, window->client, objects)) goto out; } gdu_window_ensure_unused_list (window, objects, (GAsyncReadyCallback) power_off_ensure_unused_cb, NULL, /* GCancellable */ g_object_ref (object)); out: g_list_free_full (siblings, g_object_unref); g_list_free (objects); }
false
false
false
false
false
0
wi_array_init_with_data_and_count(wi_array_t *array, void **data, wi_uinteger_t count) { wi_uinteger_t i; array = wi_array_init_with_capacity(array, count); for(i = 0; i < count; i++) _wi_array_add_data(array, data[i]); return array; }
false
false
false
false
false
0
insert_tobeinserted(int position, int ph_len, struct statement * stmt, char *tobeinserted) { char *newcopy; if (!(newcopy = (char *) ecpg_alloc(strlen(stmt->command) + strlen(tobeinserted) + 1, stmt->lineno))) { ecpg_free(tobeinserted); return false; } strcpy(newcopy, stmt->command); strcpy(newcopy + position - 1, tobeinserted); /* * The strange thing in the second argument is the rest of the string from * the old string */ strcat(newcopy, stmt->command + position + ph_len - 1); ecpg_free(stmt->command); stmt->command = newcopy; ecpg_free((char *) tobeinserted); return true; }
false
true
false
false
false
1
hfi1_create_rcvhdrq(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd) { unsigned amt; u64 reg; if (!rcd->rcvhdrq) { dma_addr_t phys_hdrqtail; gfp_t gfp_flags; /* * rcvhdrqentsize is in DWs, so we have to convert to bytes * (* sizeof(u32)). */ amt = ALIGN(rcd->rcvhdrq_cnt * rcd->rcvhdrqentsize * sizeof(u32), PAGE_SIZE); gfp_flags = (rcd->ctxt >= dd->first_user_ctxt) ? GFP_USER : GFP_KERNEL; rcd->rcvhdrq = dma_zalloc_coherent( &dd->pcidev->dev, amt, &rcd->rcvhdrq_phys, gfp_flags | __GFP_COMP); if (!rcd->rcvhdrq) { dd_dev_err(dd, "attempt to allocate %d bytes for ctxt %u rcvhdrq failed\n", amt, rcd->ctxt); goto bail; } /* Event mask is per device now and is in hfi1_devdata */ /*if (rcd->ctxt >= dd->first_user_ctxt) { rcd->user_event_mask = vmalloc_user(PAGE_SIZE); if (!rcd->user_event_mask) goto bail_free_hdrq; }*/ if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL)) { rcd->rcvhdrtail_kvaddr = dma_zalloc_coherent( &dd->pcidev->dev, PAGE_SIZE, &phys_hdrqtail, gfp_flags); if (!rcd->rcvhdrtail_kvaddr) goto bail_free; rcd->rcvhdrqtailaddr_phys = phys_hdrqtail; } rcd->rcvhdrq_size = amt; } /* * These values are per-context: * RcvHdrCnt * RcvHdrEntSize * RcvHdrSize */ reg = ((u64)(rcd->rcvhdrq_cnt >> HDRQ_SIZE_SHIFT) & RCV_HDR_CNT_CNT_MASK) << RCV_HDR_CNT_CNT_SHIFT; write_kctxt_csr(dd, rcd->ctxt, RCV_HDR_CNT, reg); reg = (encode_rcv_header_entry_size(rcd->rcvhdrqentsize) & RCV_HDR_ENT_SIZE_ENT_SIZE_MASK) << RCV_HDR_ENT_SIZE_ENT_SIZE_SHIFT; write_kctxt_csr(dd, rcd->ctxt, RCV_HDR_ENT_SIZE, reg); reg = (dd->rcvhdrsize & RCV_HDR_SIZE_HDR_SIZE_MASK) << RCV_HDR_SIZE_HDR_SIZE_SHIFT; write_kctxt_csr(dd, rcd->ctxt, RCV_HDR_SIZE, reg); return 0; bail_free: dd_dev_err(dd, "attempt to allocate 1 page for ctxt %u rcvhdrqtailaddr failed\n", rcd->ctxt); vfree(rcd->user_event_mask); rcd->user_event_mask = NULL; dma_free_coherent(&dd->pcidev->dev, amt, rcd->rcvhdrq, rcd->rcvhdrq_phys); rcd->rcvhdrq = NULL; bail: return -ENOMEM; }
false
false
false
false
false
0
efreet_menu_cb_compare_names(Efreet_Menu_Internal *internal, const char *name) { if (internal->name.internal == name) return 0; return strcmp(internal->name.internal, name); }
false
false
false
false
false
0
writeToPacket(BYTE* packet, BYTE* pixel, unsigned pixel_size) { // Take care of channel and byte order here, because packet will be flushed straight to the file switch (pixel_size) { case 1: *packet = *pixel; break; case 2: { WORD val(*(WORD*)pixel); #ifdef FREEIMAGE_BIGENDIAN SwapShort(&val); #endif *(WORD*)packet = val; } break; case 3: { packet[0] = pixel[FI_RGBA_BLUE]; packet[1] = pixel[FI_RGBA_GREEN]; packet[2] = pixel[FI_RGBA_RED]; } break; case 4: { #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR *(reinterpret_cast<unsigned*>(packet)) = *(reinterpret_cast<unsigned*> (pixel)); #else packet[0] = pixel[FI_RGBA_BLUE]; packet[1] = pixel[FI_RGBA_GREEN]; packet[2] = pixel[FI_RGBA_RED]; packet[3] = pixel[FI_RGBA_ALPHA]; #endif } break; default: assert(FALSE); } }
false
false
false
false
false
0
update_bitfield_fetch_param(struct bitfield_fetch_param *data) { /* * Don't check the bitfield itself, because this must be the * last fetch function. */ if (CHECK_FETCH_FUNCS(deref, data->orig.fn)) update_deref_fetch_param(data->orig.data); else if (CHECK_FETCH_FUNCS(symbol, data->orig.fn)) update_symbol_cache(data->orig.data); }
false
false
false
false
false
0
_XBox(Field f, xfieldT* xf, enum xr required) { ENTRY(("_XBox(0x%x, 0x%x, %d)", f, xf, required)); if(DXBoundingBox((dxObject)f,(Point *) xf->box)) { float xMin = DXD_MAX_FLOAT, xMax = -DXD_MAX_FLOAT; float yMin = DXD_MAX_FLOAT, yMax = -DXD_MAX_FLOAT; float zMin = DXD_MAX_FLOAT, zMax = -DXD_MAX_FLOAT; int i; Point *p = (Point *)xf->box; for (i = 0; i < 8; i++, p++) { if (xMin > p->x) xMin = p->x; if (yMin > p->y) yMin = p->y; if (zMin > p->z) zMin = p->z; if (xMax < p->x) xMax = p->x; if (yMax < p->y) yMax = p->y; if (zMax < p->z) zMax = p->z; } p = (Point *)xf->box; p->x = xMin; p->y = yMin; p->z = zMin; p++; p->x = xMin; p->y = yMin; p->z = zMax; p++; p->x = xMin; p->y = yMax; p->z = zMin; p++; p->x = xMin; p->y = yMax; p->z = zMax; p++; p->x = xMax; p->y = yMin; p->z = zMin; p++; p->x = xMax; p->y = yMin; p->z = zMax; p++; p->x = xMax; p->y = yMax; p->z = zMin; p++; p->x = xMax; p->y = yMax; p->z = zMax; EXIT(("OK")); return OK; } else { EXIT(("ERROR")); return ERROR; } }
false
false
false
false
false
0
e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw) { u32 ctrl; s32 ret_val; u16 reg_data; ctrl = er32(CTRL); ctrl |= E1000_CTRL_SLU; ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); ew32(CTRL, ctrl); /* Set the mac to wait the maximum time between each * iteration and increase the max iterations when * polling the phy; this fixes erroneous timeouts at 10Mbps. */ ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4), 0xFFFF); if (ret_val) return ret_val; ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9), &reg_data); if (ret_val) return ret_val; reg_data |= 0x3F; ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9), reg_data); if (ret_val) return ret_val; ret_val = e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET_INB_CTRL, &reg_data); if (ret_val) return ret_val; reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING; ret_val = e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET_INB_CTRL, reg_data); if (ret_val) return ret_val; ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw); if (ret_val) return ret_val; return e1000e_setup_copper_link(hw); }
false
false
false
false
false
0
multi_inverse2(_MIPD_ int m,big *x,big *w) { /* find w[i]=1/x[i] mod f, for i=0 to m-1 */ int i; #ifdef MR_OS_THREADS miracl *mr_mip=get_mip(); #endif if (m==0) return TRUE; if (m<0) return FALSE; if (x==w) { mr_berror(_MIPP_ MR_ERR_BAD_PARAMETERS); return FALSE; } if (m==1) { inverse2(_MIPP_ x[0],w[0]); return TRUE; } convert(_MIPP_ 1,w[0]); copy(x[0],w[1]); for (i=2;i<m;i++) modmult2(_MIPP_ w[i-1],x[i-1],w[i]); modmult2(_MIPP_ w[m-1],x[m-1],mr_mip->w6); if (size(mr_mip->w6)==0) { mr_berror(_MIPP_ MR_ERR_DIV_BY_ZERO); return FALSE; } inverse2(_MIPP_ mr_mip->w6,mr_mip->w6); /* y=1/y */ copy(x[m-1],mr_mip->w5); modmult2(_MIPP_ w[m-1],mr_mip->w6,w[m-1]); for (i=m-2;;i--) { if (i==0) { modmult2(_MIPP_ mr_mip->w5,mr_mip->w6,w[0]); break; } modmult2(_MIPP_ w[i],mr_mip->w5,w[i]); modmult2(_MIPP_ w[i],mr_mip->w6,w[i]); modmult2(_MIPP_ mr_mip->w5,x[i],mr_mip->w5); } return TRUE; }
false
false
false
false
false
0
LoadGameObjectModelList() { FILE* model_list_file = fopen((sWorld.GetDataPath() + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb"); if (!model_list_file) return; uint32 name_length, displayId; char buff[500]; while (!feof(model_list_file)) { fread(&displayId, sizeof(uint32), 1, model_list_file); fread(&name_length, sizeof(uint32), 1, model_list_file); if (name_length >= sizeof(buff)) { sLog.outDebug("File %s seems to be corrupted", VMAP::GAMEOBJECT_MODELS); break; } fread(&buff, sizeof(char), name_length, model_list_file); Vector3 v1, v2; fread(&v1, sizeof(Vector3), 1, model_list_file); fread(&v2, sizeof(Vector3), 1, model_list_file); model_list.insert(ModelList::value_type(displayId, GameobjectModelData(std::string(buff, name_length), AABox(v1, v2)))); } fclose(model_list_file); }
false
false
false
false
false
0
qtrle_decode_32bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change) { int rle_code; int pixel_ptr; int row_inc = s->frame.linesize[0]; unsigned char a, r, g, b; unsigned int argb; unsigned char *rgb = s->frame.data[0]; int pixel_limit = s->frame.linesize[0] * s->avctx->height; while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 4; CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */ while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { /* there's another skip code in the stream */ CHECK_STREAM_PTR(1); pixel_ptr += (s->buf[stream_ptr++] - 1) * 4; CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */ } else if (rle_code < 0) { /* decode the run length code */ rle_code = -rle_code; CHECK_STREAM_PTR(4); a = s->buf[stream_ptr++]; r = s->buf[stream_ptr++]; g = s->buf[stream_ptr++]; b = s->buf[stream_ptr++]; argb = (a << 24) | (r << 16) | (g << 8) | (b << 0); CHECK_PIXEL_PTR(rle_code * 4); while (rle_code--) { *(unsigned int *)(&rgb[pixel_ptr]) = argb; pixel_ptr += 4; } } else { CHECK_STREAM_PTR(rle_code * 4); CHECK_PIXEL_PTR(rle_code * 4); /* copy pixels directly to output */ while (rle_code--) { a = s->buf[stream_ptr++]; r = s->buf[stream_ptr++]; g = s->buf[stream_ptr++]; b = s->buf[stream_ptr++]; argb = (a << 24) | (r << 16) | (g << 8) | (b << 0); *(unsigned int *)(&rgb[pixel_ptr]) = argb; pixel_ptr += 4; } } } row_ptr += row_inc; } }
false
false
false
false
false
0
ena_com_init_comp_ctxt(struct ena_com_admin_queue *queue) { size_t size = queue->q_depth * sizeof(struct ena_comp_ctx); struct ena_comp_ctx *comp_ctx; u16 i; queue->comp_ctx = devm_kzalloc(queue->q_dmadev, size, GFP_KERNEL); if (unlikely(!queue->comp_ctx)) { pr_err("memory allocation failed"); return -ENOMEM; } for (i = 0; i < queue->q_depth; i++) { comp_ctx = get_comp_ctxt(queue, i, false); if (comp_ctx) init_completion(&comp_ctx->wait_event); } return 0; }
false
false
false
false
false
0
parse_net(const char *spec, uint32_t *net, uint32_t *mask) { int n, a, b, c, d, slash = 32, len = 0; if ((sscanf(spec, "%d.%d.%d.%d/%d%n", &a, &b, &c, &d, &slash, &n) == 5 || sscanf(spec, "%d.%d.%d.%d%n", &a, &b, &c, &d, &n) == 4) && isbyte(a) && isbyte(b) && isbyte(c) && isbyte(d) && slash >= 0 && slash < 33) { len = n; *net = ((uint32_t)a << 24) | ((uint32_t)b << 16) | ((uint32_t)c << 8) | d; *mask = slash ? 0xffffffffU << (32 - slash) : 0; } return len; }
false
false
false
false
false
0
gst_base_src_set_playing (GstBaseSrc * basesrc, gboolean live_play) { GstBaseSrcClass *bclass; bclass = GST_BASE_SRC_GET_CLASS (basesrc); /* unlock subclasses locked in ::create, we only do this when we stop playing. */ if (!live_play) { GST_DEBUG_OBJECT (basesrc, "unlock"); if (bclass->unlock) bclass->unlock (basesrc); } /* we are now able to grab the LIVE lock, when we get it, we can be * waiting for PLAYING while blocked in the LIVE cond or we can be waiting * for the clock. */ GST_LIVE_LOCK (basesrc); GST_DEBUG_OBJECT (basesrc, "unschedule clock"); /* unblock clock sync (if any) */ if (basesrc->clock_id) gst_clock_id_unschedule (basesrc->clock_id); /* configure what to do when we get to the LIVE lock. */ GST_DEBUG_OBJECT (basesrc, "live running %d", live_play); basesrc->live_running = live_play; if (live_play) { gboolean start; /* clear our unlock request when going to PLAYING */ GST_DEBUG_OBJECT (basesrc, "unlock stop"); if (bclass->unlock_stop) bclass->unlock_stop (basesrc); /* for live sources we restart the timestamp correction */ basesrc->priv->latency = -1; /* have to restart the task in case it stopped because of the unlock when * we went to PAUSED. Only do this if we operating in push mode. */ GST_OBJECT_LOCK (basesrc->srcpad); start = (GST_PAD_ACTIVATE_MODE (basesrc->srcpad) == GST_ACTIVATE_PUSH); GST_OBJECT_UNLOCK (basesrc->srcpad); if (start) gst_pad_start_task (basesrc->srcpad, (GstTaskFunction) gst_base_src_loop, basesrc->srcpad); GST_DEBUG_OBJECT (basesrc, "signal"); GST_LIVE_SIGNAL (basesrc); } GST_LIVE_UNLOCK (basesrc); return TRUE; }
false
false
false
false
false
0
PyNumber_Long(PyObject *o) { PyNumberMethods *m; PyObject *trunc_func; const char *buffer; Py_ssize_t buffer_len; _Py_IDENTIFIER(__trunc__); if (o == NULL) return null_error(); if (PyLong_CheckExact(o)) { Py_INCREF(o); return o; } m = o->ob_type->tp_as_number; if (m && m->nb_int) { /* This should include subclasses of int */ PyObject *res = m->nb_int(o); if (res && !PyLong_Check(res)) { PyErr_Format(PyExc_TypeError, "__int__ returned non-int (type %.200s)", res->ob_type->tp_name); Py_DECREF(res); return NULL; } return res; } if (PyLong_Check(o)) /* An int subclass without nb_int */ return _PyLong_Copy((PyLongObject *)o); trunc_func = _PyObject_LookupSpecial(o, &PyId___trunc__); if (trunc_func) { PyObject *truncated = PyEval_CallObject(trunc_func, NULL); PyObject *int_instance; Py_DECREF(trunc_func); /* __trunc__ is specified to return an Integral type, but int() needs to return a int. */ int_instance = convert_integral_to_int(truncated, "__trunc__ returned non-Integral (type %.200s)"); return int_instance; } if (PyErr_Occurred()) return NULL; if (PyBytes_Check(o)) /* need to do extra error checking that PyLong_FromString() * doesn't do. In particular int('9.5') must raise an * exception, not truncate the float. */ return long_from_string(PyBytes_AS_STRING(o), PyBytes_GET_SIZE(o)); if (PyUnicode_Check(o)) /* The above check is done in PyLong_FromUnicode(). */ return PyLong_FromUnicodeObject(o, 10); if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) return long_from_string(buffer, buffer_len); return type_error("int() argument must be a string or a " "number, not '%.200s'", o); }
false
false
false
false
false
0
guess_abs_e_location(HTK_Param *param) { short qualtype; int basenum, abs_e_num; qualtype = param->header.samptype & ~(F_COMPRESS | F_CHECKSUM); qualtype &= ~(F_BASEMASK); basenum = guess_basenum(param, qualtype); if (qualtype & F_ENERGY) { if (qualtype & F_ZEROTH) { abs_e_num = basenum + 1; } else { abs_e_num = basenum; } } else { /* absolute energy not included */ jlog("Stat: strip_mfcc: absolute energy coef. not exist, stripping disabled\n"); abs_e_num = -1; } return abs_e_num; }
false
false
false
false
false
0
perl_tokenizer_Create( int argc, const char * const *argv, sqlite3_tokenizer **ppTokenizer ){ dTHX; dSP; int n_retval; SV *retval; perl_tokenizer *t; if (!argc) { return SQLITE_ERROR; } t = (perl_tokenizer *) sqlite3_malloc(sizeof(*t)); if( t==NULL ) return SQLITE_NOMEM; memset(t, 0, sizeof(*t)); ENTER; SAVETMPS; /* call the qualified::function::name */ PUSHMARK(SP); PUTBACK; n_retval = call_pv(argv[0], G_SCALAR); SPAGAIN; /* store a copy of the returned coderef into the tokenizer structure */ if (n_retval != 1) { warn("tokenizer_Create returned %d arguments", n_retval); } retval = POPs; t->coderef = newSVsv(retval); *ppTokenizer = &t->base; PUTBACK; FREETMPS; LEAVE; return SQLITE_OK; }
false
false
false
false
false
0
TIFF_description( FL_IMAGE * im ) { FILE *fp = im->fpin; SPEC *sp = fl_malloc( sizeof *sp ); char buf[ 4 ]; im->io_spec = sp; im->spec_size = sizeof *sp; sp->image = im; if ( fread( buf, 1, 4, fp ) != 4 ) { flimage_error( im, "Failure to read TIFF file" ); fl_free( sp ); im->io_spec = NULL; im->spec_size = 0; return -1; } sp->endian = buf[ 0 ] == 'M' ? MSBFirst : LSBFirst; initialize_tiff_io( sp, sp->endian ); sp->ifd_offset = sp->read4bytes( fp ); if ( ! sp->ifd_offset ) { flimage_error( im, "Invalid TIFF: no IFD" ); fl_free( sp ); im->io_spec = NULL; im->spec_size = 0; return -1; } read_tiff_ifd( fp, sp ); if ( get_image_info_from_ifd( im ) < 0 ) { fl_free( sp ); im->io_spec = NULL; im->spec_size = 0; return -1; } return 0; }
true
true
false
false
false
1
show_rcubarrier(struct seq_file *m, void *v) { struct rcu_state *rsp = (struct rcu_state *)m->private; seq_printf(m, "bcc: %d bseq: %lu\n", atomic_read(&rsp->barrier_cpu_count), rsp->barrier_sequence); return 0; }
false
false
false
false
false
0
List_preallocateToSize_(List *self, size_t index) { size_t s = index * sizeof(void *); if (s >= self->memSize) { size_t newSize = self->memSize * LIST_RESIZE_FACTOR; if (s > newSize) { newSize = s; } self->items = (void **)io_realloc(self->items, newSize); memset(self->items + self->size, 0, (newSize - (self->size*sizeof(void *)))); self->memSize = newSize; } }
false
false
false
false
false
0
addInternalAI() { TRACE("ServerInterface::addInternalAI"); QStringList arglist; AttalSocket * socket = new AttalSocket; Analyst * ai = new Analyst( socket ); socket->connectToHost( "localhost", PORT.toInt() ); _aiList.append( ai ); ai->start(); }
false
false
false
false
false
0
mark_effect (exp, nonequal) rtx exp; regset nonequal; { int regno; rtx dest; switch (GET_CODE (exp)) { /* In case we do clobber the register, mark it as equal, as we know the value is dead so it don't have to match. */ case CLOBBER: if (REG_P (XEXP (exp, 0))) { dest = XEXP (exp, 0); regno = REGNO (dest); CLEAR_REGNO_REG_SET (nonequal, regno); if (regno < FIRST_PSEUDO_REGISTER) { int n = HARD_REGNO_NREGS (regno, GET_MODE (dest)); while (--n > 0) CLEAR_REGNO_REG_SET (nonequal, regno + n); } } return false; case SET: if (rtx_equal_for_cselib_p (SET_DEST (exp), SET_SRC (exp))) return false; dest = SET_DEST (exp); if (dest == pc_rtx) return false; if (!REG_P (dest)) return true; regno = REGNO (dest); SET_REGNO_REG_SET (nonequal, regno); if (regno < FIRST_PSEUDO_REGISTER) { int n = HARD_REGNO_NREGS (regno, GET_MODE (dest)); while (--n > 0) SET_REGNO_REG_SET (nonequal, regno + n); } return false; default: return false; } }
false
false
false
false
false
0
write_feed_list() { FILE* f = fopen(NOTICES_DIR"/feeds.xml", "w"); if (!f) return; MIOFILE fout; fout.init_file(f); write_rss_feed_descs(fout, feeds); fclose(f); }
false
false
false
false
false
0
atmel_poll_get_char(struct uart_port *port) { while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_RXRDY)) cpu_relax(); return atmel_uart_read_char(port); }
false
false
false
false
false
0
evaluate(string_ty *path_unres, string_ty *path, string_ty *path_res, struct stat *st) const { rpt_value::pointer vp = get_left()->evaluate(path_unres, path, path_res, st); if (vp->is_an_error()) return vp; return get_right()->evaluate(path_unres, path, path_res, st); }
false
false
false
false
false
0
hash_insert(hash_t *hash, hnode_t *node, const void *key) { hash_val_t hkey, chain; assert (hash_val_t_bit != 0); assert (node->next == NULL); assert (hash->nodecount < hash->maxcount); /* 1 */ assert (hash_lookup(hash, key) == NULL); /* 2 */ if (hash->dynamic && hash->nodecount >= hash->highmark) /* 3 */ grow_table(hash); hkey = hash->function(key); chain = hkey & hash->mask; /* 4 */ node->key = key; node->hkey = hkey; node->next = hash->table[chain]; hash->table[chain] = node; hash->nodecount++; assert (hash_verify(hash)); }
false
false
false
false
false
0
ojc_object_nappend(ojcErr err, ojcVal object, const char *key, int klen, ojcVal val) { if (bad_object(err, object, "append")) { return; } val->next = 0; _ojc_set_key(val, key, klen); if (0 == object->members.head) { object->members.head = val; } else { object->members.tail->next = val; } object->members.tail = val; }
false
false
false
false
false
0
read_head(struct mpstr * mp) { unsigned long head=0; if(mdebug==4)printf("before head = read_buf_byte(mp)\n"); head = read_buf_byte(mp); head <<= 8; if(mdebug==4)printf("before head |= read_buf_byte(mp)\n"); head |= read_buf_byte(mp); head <<= 8; if(mdebug==4)printf("before head |= read_buf_byte(mp)\n"); head |= read_buf_byte(mp); head <<= 8; if(mdebug==4)printf("before head |= read_buf_byte(mp)\n"); head |= read_buf_byte(mp); mp->header = head; mp->fr.offset=Hoffset; Hoffset+=4; }
false
false
false
false
false
0
get_value (bfd_vma size, unsigned long chunksz, bfd *input_bfd, bfd_byte *location) { bfd_vma x = 0; for (; size; size -= chunksz, location += chunksz) { switch (chunksz) { default: case 0: abort (); case 1: x = (x << (8 * chunksz)) | bfd_get_8 (input_bfd, location); break; case 2: x = (x << (8 * chunksz)) | bfd_get_16 (input_bfd, location); break; case 4: x = (x << (8 * chunksz)) | bfd_get_32 (input_bfd, location); break; case 8: #ifdef BFD64 x = (x << (8 * chunksz)) | bfd_get_64 (input_bfd, location); #else abort (); #endif break; } } return x; }
false
false
false
false
false
0
couple_lossless(float A, float B, float *qA, float *qB){ int test1=fabs(*qA)>fabs(*qB); test1-= fabs(*qA)<fabs(*qB); if(!test1)test1=((fabs(A)>fabs(B))<<1)-1; if(test1==1){ *qB=(*qA>0.f?*qA-*qB:*qB-*qA); }else{ float temp=*qB; *qB=(*qB>0.f?*qA-*qB:*qB-*qA); *qA=temp; } if(*qB>fabs(*qA)*1.9999f){ *qB= -fabs(*qA)*2.f; *qA= -*qA; } }
false
false
false
false
false
0
operator() (double x) const { double xx = x/(_a.getValue()+_b.getValue()); xx = xx - floor(xx); if (xx < _a.getValue()/(_a.getValue()+_b.getValue())) { return 0; } else { return _height.getValue(); } }
false
false
false
false
false
0
start () { int i; day = 1; clouds = 0; weather = WEATHER_SUNNY; camera = 0; sungamma = 50; if (l != NULL) delete l; l = new GLLandscape (space, LANDSCAPE_ALPINE_EROSION, NULL); int px, py; l->searchPlain (-1, -1, &px, &py); playerInit (); fplayer->tl->x = px; fplayer->tl->z = py + 150; for (i = 1; i <= 2; i ++) { fighter [i]->party = 0; fighter [i]->target = fighter [0]; fighter [i]->o = &model_tank1; fighter [i]->tl->x = px + 6 - i * 4; fighter [i]->tl->z = py + 6 - i * 4; fighter [i]->newinit (TANK_GROUND1, 0, 400); fighter [i]->maxthrust = 0; } }
false
false
false
false
false
0
sample_nearest(byte *s, int w, int h, int n, int u, int v) { if (u < 0) u = 0; if (v < 0) v = 0; if (u >= w) u = w - 1; if (v >= h) v = h - 1; return s + (v * w + u) * n; }
false
false
false
false
false
0
dumpComplex(FILE *file, int page){ FILE* pageFile; GooString* tmp; if( firstPage == -1 ) firstPage = page; if (dumpComplexHeaders(file, pageFile, page)) { error(-1, "Couldn't write headers."); return; } tmp=basename(DocName); fputs("<STYLE type=\"text/css\">\n<!--\n",pageFile); fputs("\tp {margin: 0; padding: 0;}",pageFile); for(int i=fontsPageMarker;i!=fonts->size();i++) { GooString *fontCSStyle; if (!singleHtml) fontCSStyle = fonts->CSStyle(i); else fontCSStyle = fonts->CSStyle(i,page); fprintf(pageFile,"\t%s\n",fontCSStyle->getCString()); delete fontCSStyle; } fputs("-->\n</STYLE>\n",pageFile); if( !noframes ) { fputs("</HEAD>\n<BODY bgcolor=\"#A0A0A0\" vlink=\"blue\" link=\"blue\">\n",pageFile); } fprintf(pageFile,"<DIV id=\"page%d-div\" style=\"position:relative;width:%dpx;height:%dpx;\">\n", page, pageWidth, pageHeight); if( !ignore ) { fprintf(pageFile, "<IMG width=\"%d\" height=\"%d\" src=\"%s%03d.%s\" alt=\"background image\"/>\n", pageWidth, pageHeight, tmp->getCString(), (page-firstPage+1), imgExt->getCString()); } delete tmp; for(HtmlString *tmp1=yxStrings;tmp1;tmp1=tmp1->yxNext){ if (tmp1->htext){ fprintf(pageFile, "<P style=\"position:absolute;top:%dpx;left:%dpx;white-space:nowrap\" class=\"ft", xoutRound(tmp1->yMin), xoutRound(tmp1->xMin)); if (!singleHtml) { fputc('0', pageFile); } else { fprintf(pageFile, "%d", page); } fprintf(pageFile,"%d\">", tmp1->fontpos); fputs(tmp1->htext->getCString(), pageFile); fputs("</P>\n", pageFile); } } fputs("</DIV>\n", pageFile); if( !noframes ) { fputs("</BODY>\n</HTML>\n",pageFile); fclose(pageFile); } }
false
false
false
false
false
0
table_add( const char *label, const char *pinseq, const char *pintype, const char *type, const char *gender, struct sig *sig ) { entry[nentries].port = label; if (pinseq) { entry[nentries].pinseq = atoi(pinseq); } else { entry[nentries].pinseq = 0; } entry[nentries].pintype = pintype; entry[nentries].type = type; entry[nentries].gender = gender; entry[nentries].sig = sig; nentries++; }
false
false
false
false
true
1
create_wpt_dest(const waypoint* wpt_orig, double lat_orig, double long_orig, double lat_orig_adj, double long_orig_adj) { double distance = gcdist(lat_orig, long_orig, lat_orig_adj, long_orig_adj); double frac; double lat_dest; double long_dest; waypoint* wpt_dest = NULL; distance = radtometers(distance); if (distance <= maxDist) { return NULL; } frac = maxDist / distance; linepart(lat_orig, long_orig, lat_orig_adj, long_orig_adj, frac, &lat_dest, &long_dest); wpt_dest = waypt_dupe(wpt_orig); wpt_dest->latitude = DEG(lat_dest); wpt_dest->longitude = DEG(long_dest); return wpt_dest; }
false
false
false
false
false
0
cmp(const void *aa, const void *bb) { const struct Distance *a = aa, *b = bb; if (a->dist < b->dist) return -1; return a->dist > b->dist; }
false
false
false
false
false
0
keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved) { int rc; (void)reserved; if (!hd) return G10ERR_INV_ARG; rc = keydb_search_reset (hd); /* this does reset hd->current */ if (rc) return rc; /* If we have a primary set, try that one first */ if(primary_keyring) { for ( ; hd->current >= 0 && hd->current < hd->used; hd->current++) { if(hd->active[hd->current].token==primary_keyring) { if(keyring_is_writable (hd->active[hd->current].token)) return 0; else break; } } rc = keydb_search_reset (hd); /* this does reset hd->current */ if (rc) return rc; } for ( ; hd->current >= 0 && hd->current < hd->used; hd->current++) { switch (hd->active[hd->current].type) { case KEYDB_RESOURCE_TYPE_NONE: BUG(); break; case KEYDB_RESOURCE_TYPE_KEYRING: if (keyring_is_writable (hd->active[hd->current].token)) return 0; /* found (hd->current is set to it) */ break; } } return -1; }
false
false
false
false
false
0
check() { for (ListType::iterator i = __listPlus.begin(); i != __listPlus.end(); ++i) { (*(*i)).check(); } for (ListType::iterator i = __listMinus.begin(); i != __listMinus.end(); ++i) { (*(*i)).check(); } }
false
false
false
false
false
0
IDirectFBEventBuffer_Reset( IDirectFBEventBuffer *thiz ) { EventBufferItem *item; DirectLink *n; DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) D_DEBUG_AT( IDFBEvBuf, "%s( %p )\n", __FUNCTION__, thiz ); if (data->pipe) return DFB_UNSUPPORTED; pthread_mutex_lock( &data->events_mutex ); direct_list_foreach_safe (item, n, data->events) D_FREE( item ); data->events = NULL; pthread_mutex_unlock( &data->events_mutex ); return DFB_OK; }
false
false
false
false
false
0
CyaSSL_Malloc(size_t size) { void* res = 0; if (malloc_function) res = malloc_function(size); else res = malloc(size); return res; }
false
false
false
false
false
0
ComputeMessageRepresentative(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, size_t representativeBitLength) const { assert(recoverableMessageLength == 0); assert(hashIdentifier.second == 0); const size_t representativeByteLength = BitsToBytes(representativeBitLength); const size_t digestSize = hash.DigestSize(); const size_t paddingLength = SaturatingSubtract(representativeByteLength, digestSize); memset(representative, 0, paddingLength); hash.TruncatedFinal(representative+paddingLength, STDMIN(representativeByteLength, digestSize)); if (digestSize*8 > representativeBitLength) { Integer h(representative, representativeByteLength); h >>= representativeByteLength*8 - representativeBitLength; h.Encode(representative, representativeByteLength); } }
false
false
false
false
false
0
ipath_query_device(struct ib_device *ibdev, struct ib_device_attr *props, struct ib_udata *uhw) { struct ipath_ibdev *dev = to_idev(ibdev); if (uhw->inlen || uhw->outlen) return -EINVAL; memset(props, 0, sizeof(*props)); props->device_cap_flags = IB_DEVICE_BAD_PKEY_CNTR | IB_DEVICE_BAD_QKEY_CNTR | IB_DEVICE_SHUTDOWN_PORT | IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_RC_RNR_NAK_GEN | IB_DEVICE_PORT_ACTIVE_EVENT | IB_DEVICE_SRQ_RESIZE; props->page_size_cap = PAGE_SIZE; props->vendor_id = IPATH_SRC_OUI_1 << 16 | IPATH_SRC_OUI_2 << 8 | IPATH_SRC_OUI_3; props->vendor_part_id = dev->dd->ipath_deviceid; props->hw_ver = dev->dd->ipath_pcirev; props->sys_image_guid = dev->sys_image_guid; props->max_mr_size = ~0ull; props->max_qp = ib_ipath_max_qps; props->max_qp_wr = ib_ipath_max_qp_wrs; props->max_sge = ib_ipath_max_sges; props->max_sge_rd = ib_ipath_max_sges; props->max_cq = ib_ipath_max_cqs; props->max_ah = ib_ipath_max_ahs; props->max_cqe = ib_ipath_max_cqes; props->max_mr = dev->lk_table.max; props->max_fmr = dev->lk_table.max; props->max_map_per_fmr = 32767; props->max_pd = ib_ipath_max_pds; props->max_qp_rd_atom = IPATH_MAX_RDMA_ATOMIC; props->max_qp_init_rd_atom = 255; /* props->max_res_rd_atom */ props->max_srq = ib_ipath_max_srqs; props->max_srq_wr = ib_ipath_max_srq_wrs; props->max_srq_sge = ib_ipath_max_srq_sges; /* props->local_ca_ack_delay */ props->atomic_cap = IB_ATOMIC_GLOB; props->max_pkeys = ipath_get_npkeys(dev->dd); props->max_mcast_grp = ib_ipath_max_mcast_grps; props->max_mcast_qp_attach = ib_ipath_max_mcast_qp_attached; props->max_total_mcast_qp_attach = props->max_mcast_qp_attach * props->max_mcast_grp; return 0; }
false
false
false
false
false
0
il_kill_to_beginning_of_line() { size_t old_mark = (il->mark <= il->point) ? il->static_length : il->mark - il->point; il_set_mark(); il_beginning_of_line(); il_region_command(IL_STORE | IL_KILL); il->mark = min(old_mark, il->length); il->last_operation = IL_KILL_TO_BEGINNING_OF_LINE; }
false
false
false
false
false
0
ListKeys(PK11SlotInfo *slot, const char *nickName, int index, KeyType keyType, PRBool dopriv, secuPWData *pwdata) { SECStatus rv = SECFailure; static const char fmt[] = \ "%s: Checking token \"%.33s\" in slot \"%.65s\"\n"; if (slot == NULL) { PK11SlotList *list; PK11SlotListElement *le; list= PK11_GetAllTokens(CKM_INVALID_MECHANISM,PR_FALSE,PR_FALSE,pwdata); if (list) { for (le = list->head; le; le = le->next) { PR_fprintf(PR_STDOUT, fmt, progName, PK11_GetTokenName(le->slot), PK11_GetSlotName(le->slot)); rv &= ListKeysInSlot(le->slot,nickName,keyType,pwdata); } PK11_FreeSlotList(list); } } else { PR_fprintf(PR_STDOUT, fmt, progName, PK11_GetTokenName(slot), PK11_GetSlotName(slot)); rv = ListKeysInSlot(slot,nickName,keyType,pwdata); } return rv; }
false
false
false
false
false
0
cfq_merge(struct request_queue *q, struct request **req, struct bio *bio) { struct cfq_data *cfqd = q->elevator->elevator_data; struct request *__rq; __rq = cfq_find_rq_fmerge(cfqd, bio); if (__rq && elv_rq_merge_ok(__rq, bio)) { *req = __rq; return ELEVATOR_FRONT_MERGE; } return ELEVATOR_NO_MERGE; }
false
false
false
false
false
0
_overlay_default_coord_set(Overlay_Default *ovl, Evas_Coord x, Evas_Coord y) { EINA_SAFETY_ON_NULL_RETURN(ovl); ovl->x = x; ovl->y = y; }
false
false
false
false
false
0
i915_ring_seqno_info(struct seq_file *m, struct intel_engine_cs *engine) { seq_printf(m, "Current sequence (%s): %x\n", engine->name, engine->get_seqno(engine)); seq_printf(m, "Current user interrupts (%s): %x\n", engine->name, READ_ONCE(engine->user_interrupts)); }
false
false
false
false
false
0
submarine_destroy_all_items() { /* kill pending timers */ if(timer_id) g_source_remove(timer_id); timer_id = 0; if(timer_slow_id) g_source_remove(timer_slow_id); timer_slow_id = 0; if(timer_very_slow_id) g_source_remove(timer_very_slow_id); timer_very_slow_id = 0; if(boardRootItem!=NULL) goo_canvas_item_remove(boardRootItem); boardRootItem = NULL; stop_frigate_anim(); }
false
false
false
false
false
0
GetNoDataValue( int *pbSuccess ) { if( pbSuccess != NULL ) *pbSuccess = TRUE; if( eDataType == GDT_Float64 ) return rUNDEF; else if( eDataType == GDT_Int32) return iUNDEF; else if( eDataType == GDT_Int16) return shUNDEF; else if( eDataType == GDT_Float32) return flUNDEF; else if( EQUAL(psInfo.stDomain.c_str(),"image") || EQUAL(psInfo.stDomain.c_str(),"colorcmp")) { *pbSuccess = false; return 0; } else return 0; }
false
false
false
true
false
1
ssh_channel_is_eof(ssh_channel channel) { if(channel == NULL) { return SSH_ERROR; } if ((channel->stdout_buffer && buffer_get_rest_len(channel->stdout_buffer) > 0) || (channel->stderr_buffer && buffer_get_rest_len(channel->stderr_buffer) > 0)) { return 0; } return (channel->remote_eof != 0); }
false
false
false
false
false
0
gmenubar_destroy(GGadget *g) { GMenuBar *mb = (GMenuBar *) g; if ( g==NULL ) return; if ( mb->child!=NULL ) { GMenuDestroy(mb->child); GDrawSync(NULL); GDrawProcessPendingEvents(NULL); /* popup's destroy routine must execute before we die */ } GMenuItemArrayFree(mb->mi); free(mb->xs); _ggadget_destroy(g); }
false
false
false
false
false
0
mail_receive_hook(gpointer source, gpointer data) { MailReceiveData *mail_receive_data = (MailReceiveData *) source; Pop3Session *session; gchar *newheaders; gchar *newdata; gchar date[PREFSBUFSIZE]; if (!config.fetchinfo_enable) { return FALSE; } g_return_val_if_fail( mail_receive_data && mail_receive_data->session && mail_receive_data->data, FALSE ); session = mail_receive_data->session; get_rfc822_date(date, PREFSBUFSIZE); newheaders = g_strdup(""); if (config.fetchinfo_uidl) fetchinfo_add_header(&newheaders, "X-FETCH-UIDL", session->msg[session->cur_msg].uidl); if (config.fetchinfo_account) fetchinfo_add_header(&newheaders, "X-FETCH-ACCOUNT", session->ac_prefs->account_name); if (config.fetchinfo_server) fetchinfo_add_header(&newheaders, "X-FETCH-SERVER", session->ac_prefs->recv_server); if (config.fetchinfo_userid) fetchinfo_add_header(&newheaders, "X-FETCH-USERID", session->ac_prefs->userid); if (config.fetchinfo_time) fetchinfo_add_header(&newheaders, "X-FETCH-TIME", date); newdata = g_strconcat(newheaders, mail_receive_data->data, NULL); g_free(newheaders); g_free(mail_receive_data->data); mail_receive_data->data = newdata; mail_receive_data->data_len = strlen(newdata); return FALSE; }
false
false
false
false
false
0
pma_get_opa_classportinfo(struct opa_pma_mad *pmp, struct ib_device *ibdev, u32 *resp_len) { struct opa_class_port_info *p = (struct opa_class_port_info *)pmp->data; memset(pmp->data, 0, sizeof(pmp->data)); if (pmp->mad_hdr.attr_mod != 0) pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; p->base_version = OPA_MGMT_BASE_VERSION; p->class_version = OPA_SMI_CLASS_VERSION; /* * Expected response time is 4.096 usec. * 2^18 == 1.073741824 sec. */ p->cap_mask2_resp_time = cpu_to_be32(18); if (resp_len) *resp_len += sizeof(*p); return reply((struct ib_mad_hdr *)pmp); }
false
false
false
false
false
0
AngleMove_Begin (edict_t *ent) { vec3_t destdelta; float len; float traveltime; float frames; // set destdelta to the vector needed to move if (ent->moveinfo.state == STATE_UP) VectorSubtract (ent->moveinfo.end_angles, ent->s.angles, destdelta); else VectorSubtract (ent->moveinfo.start_angles, ent->s.angles, destdelta); // calculate length of vector len = VectorLength (destdelta); // divide by speed to get time to reach dest traveltime = len / ent->moveinfo.speed; if (traveltime < FRAMETIME) { AngleMove_Final (ent); return; } frames = floor(traveltime / FRAMETIME); // scale the destdelta vector by the time spent traveling to get velocity VectorScale (destdelta, 1.0 / traveltime, ent->avelocity); // set nextthink to trigger a think when dest is reached ent->nextthink = level.time + frames * FRAMETIME; ent->think = AngleMove_Final; }
false
false
false
false
false
0
gnac_profiles_mgr_list_profiles(void) { GFile *dir = gnac_profiles_mgr_get_profiles_dir(); GError *error = NULL; GFileEnumerator *files = g_file_enumerate_children(dir, G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, &error); if (!files && error) { g_clear_error(&error); /* no profiles found, try to import the default ones */ gnac_profiles_mgr_import_default_profiles(); files = g_file_enumerate_children(dir, G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, &error); if (!files && error) { g_printerr(_("No profiles available")); libgnac_warning("%s", error->message); g_clear_error(&error); return; } } g_print(_("Available audio profiles:")); g_print("\n\n"); gchar *last_used_profile = gnac_settings_get_string( GNAC_KEY_LAST_USED_PROFILE); GFile *profile_file = g_file_enumerator_get_container(files); gchar *profile_file_path = g_file_get_path(profile_file); GFileInfo *file_info; GSList *profiles = NULL; while ((file_info = g_file_enumerator_next_file(files, NULL, NULL))) { if (g_file_info_get_file_type(file_info) == G_FILE_TYPE_REGULAR) { AudioProfileGeneric *profile; const gchar *profile_file_name = g_file_info_get_name(file_info); gchar *profile_file_full_path = g_build_filename(profile_file_path, profile_file_name, NULL); gnac_profiles_default_load_generic_audio_profile(profile_file_full_path, &profile); if (profile) { gpointer name = (profile->generic)->name; profiles = g_slist_prepend(profiles, name); } g_free(profile_file_full_path); } g_object_unref(file_info); } g_free(profile_file_path); profiles = g_slist_reverse(profiles); guint count = g_slist_length(profiles); if (count == 0) { g_print("\t"); g_print(_("No profiles available")); g_print("\n"); } else { /* check if last_used_profile exists */ if (!g_slist_find_custom(profiles, last_used_profile, (GCompareFunc) g_strcmp0)) { last_used_profile = NULL; } GSList *tmp; for (tmp = profiles; tmp; tmp = g_slist_next(tmp)) { gint pos = g_slist_position(profiles, tmp); gchar *count_str = g_strdup_printf("%u", pos+1); /* if last_used_profile is not set, assume the * first profile was last used */ gchar *name = tmp->data; gboolean found = ((pos == 0 && !last_used_profile) || gnac_utils_str_equal(name, last_used_profile)); g_print("\t%2s) %s\n", found ? "*" : count_str, name); g_free(count_str); } } g_print("\n"); g_slist_free(profiles); g_free(last_used_profile); g_object_unref(dir); g_file_enumerator_close(files, NULL, NULL); g_object_unref(files); }
false
false
false
false
false
0
is_blank(int row, int col, int n) { n += col; for( ;col < n; col++){ if(pscr(row, col) == NULL || pscr(row, col)->c != ' ') return(0); } return(1); }
false
false
false
false
false
0
SetVariableAssignHook(VariableSpace space, const char *name, VariableAssignHook hook) { struct _variable *current, *previous; if (!space) return false; if (!valid_variable_name(name)) return false; for (previous = space, current = space->next; current; previous = current, current = current->next) { if (strcmp(current->name, name) == 0) { /* found entry, so update */ current->assign_hook = hook; (*hook) (current->value); return true; } } /* not present, make new entry */ current = pg_malloc(sizeof *current); current->name = pg_strdup(name); current->value = NULL; current->assign_hook = hook; current->next = NULL; previous->next = current; (*hook) (NULL); return true; }
false
false
false
false
false
0
writeData ( tnstream& stream ) const { stream.writeInt( destructContainerStreamVersion ); ContainerAction::writeData( stream ); stream.writeInt( building ); if ( unitBuffer ) { stream.writeInt( 1 ); unitBuffer->writetostream( &stream ); } else stream.writeInt( 0 ); stream.writeInt( (int)fieldRegistration ); stream.writeInt( hostingCarrier ); stream.writeInt( cargoSlot ); stream.writeInt( suppressWreckage ); stream.writeInt( hadViewOnMap ); }
false
false
false
false
false
0
trayIconClicked(QSystemTrayIcon::ActivationReason reason) { if(reason == QSystemTrayIcon::Trigger) trayIconMenu->exec(QCursor::pos()); }
false
false
false
false
false
0
replaceStreamData( PointerHolder<QPDFObjectHandle::StreamDataProvider> provider, QPDFObjectHandle const& filter, QPDFObjectHandle const& decode_parms) { this->stream_provider = provider; this->stream_data = 0; replaceFilterData(filter, decode_parms, 0); }
false
false
false
false
false
0
opt_parse_extended(char *str, struct mkfs_opts *opts) { char *opt; while ((opt = strsep(&str, ",")) != NULL) { char *key = strsep(&opt, "="); char *val = strsep(&opt, "="); if (key == NULL || *key == '\0') { fprintf(stderr, _("Missing argument to '-o' option\n")); exit(-1); } if (strcmp("sunit", key) == 0) { opts->sunit = parse_ulong(opts, "sunit", val); opts->got_sunit = 1; } else if (strcmp("swidth", key) == 0) { opts->swidth = parse_ulong(opts, "swidth", val); opts->got_swidth = 1; } else if (strcmp("align", key) == 0) { opts->align = parse_bool(opts, "align", val); } else if (strcmp("help", key) == 0) { print_ext_opts(); exit(0); } else { fprintf(stderr, _("Invalid option '%s'\n"), key); exit(-1); } } }
false
false
false
false
false
0
H5FD_log_get_eof(const H5FD_t *_file) { const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(MAX(file->eof, file->eoa)) }
false
false
false
false
false
0
_gnutls_x509_read_uint (ASN1_TYPE node, const char *value, unsigned int *ret) { int len, result; opaque *tmpstr; len = 0; result = asn1_read_value (node, value, NULL, &len); if (result != ASN1_MEM_ERROR) { gnutls_assert (); return _gnutls_asn2err (result); } tmpstr = gnutls_malloc (len); if (tmpstr == NULL) { gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; } result = asn1_read_value (node, value, tmpstr, &len); if (result != ASN1_SUCCESS) { gnutls_assert (); gnutls_free (tmpstr); return _gnutls_asn2err (result); } if (len == 1) *ret = tmpstr[0]; else if (len == 2) *ret = _gnutls_read_uint16 (tmpstr); else if (len == 3) *ret = _gnutls_read_uint24 (tmpstr); else if (len == 4) *ret = _gnutls_read_uint32 (tmpstr); else { gnutls_assert (); gnutls_free (tmpstr); return GNUTLS_E_INTERNAL_ERROR; } gnutls_free (tmpstr); return 0; }
false
false
false
false
false
0
uca_ring_buffer_get_read_pointer (UcaRingBuffer *buffer) { UcaRingBufferPrivate *priv; gpointer data; g_return_val_if_fail (UCA_IS_RING_BUFFER (buffer), NULL); priv = buffer->priv; g_return_val_if_fail (priv->read_index != priv->write_index, NULL); data = priv->data + (priv->read_index % priv->n_blocks_total) * priv->block_size; priv->read_index++; return data; }
false
false
false
false
false
0
buf_parse (struct buffer *buf, const int delim, char *line, const int size) { bool eol = false; int n = 0; int c; ASSERT (size > 0); do { c = buf_read_u8 (buf); if (c < 0) eol = true; if (c <= 0 || c == delim) c = 0; if (n >= size) break; line[n++] = c; } while (c); line[size-1] = '\0'; return !(eol && !strlen (line)); }
false
false
false
false
false
0
g_dbus_client_unref(GDBusClient *client) { unsigned int i; if (client == NULL) return; if (__sync_sub_and_fetch(&client->ref_count, 1) > 0) return; if (client->pending_call != NULL) { dbus_pending_call_cancel(client->pending_call); dbus_pending_call_unref(client->pending_call); } if (client->get_objects_call != NULL) { dbus_pending_call_cancel(client->get_objects_call); dbus_pending_call_unref(client->get_objects_call); } for (i = 0; i < client->match_rules->len; i++) { modify_match(client->dbus_conn, "RemoveMatch", g_ptr_array_index(client->match_rules, i)); } g_ptr_array_free(client->match_rules, TRUE); dbus_connection_remove_filter(client->dbus_conn, message_filter, client); g_list_free_full(client->proxy_list, proxy_free); if (client->disconn_func) client->disconn_func(client->dbus_conn, client->disconn_data); dbus_connection_unref(client->dbus_conn); g_free(client->service_name); g_free(client->unique_name); g_free(client->base_path); g_free(client); }
false
false
false
false
false
0
Ltrucf(flg,pptr) int flg; truc *pptr; { truc *ptr; long n0; switch(flg) { case vARRELE: ARGpush(pptr[1]); ARGpush(pptr[2]); argStkPtr[-1] = eval(argStkPtr-1); argStkPtr[0] = eval(argStkPtr); flg = arrindex(argStkPtr-1,&n0); if(flg == fVECTOR) { ptr = vectele(argStkPtr-1,n0); } else { ptr = NULL; } ARGnpop(2); break; case vRECFIELD: ARGpush(pptr[1]); *argStkPtr = eval(argStkPtr); ptr = recfield(argStkPtr,pptr[2]); ARGpop(); break; default: ptr = NULL; } return(ptr); }
false
false
false
false
false
0
visit(ir_loop_jump *ir) { switch (ir->mode) { case ir_loop_jump::jump_break: emit(BRW_OPCODE_BREAK); break; case ir_loop_jump::jump_continue: emit(BRW_OPCODE_CONTINUE); break; } }
false
false
false
false
false
0
stopAndRestartSolver() { if ( m_toldAboutLostGame || m_toldAboutWonGame ) // who cares? return; if ( m_solverThread && m_solverThread->isRunning() ) { m_solverThread->abort(); } if ( isCardAnimationRunning() ) { startSolver(); return; } slotSolverEnded(); }
false
false
false
false
false
0
notifyCommFailure(const giopAddress* addr, CORBA::Boolean heldlock) { if (heldlock) { ASSERT_OMNI_TRACEDMUTEX_HELD(*omniTransportLock,1); } else { ASSERT_OMNI_TRACEDMUTEX_HELD(*omniTransportLock,0); omniTransportLock->lock(); } const giopAddress* addr_in_use; addr_in_use = pd_addresses[pd_addresses_order[pd_address_in_use]]; if (addr == addr_in_use) { pd_address_in_use++; if (pd_address_in_use >= pd_addresses_order.size()) pd_address_in_use = 0; addr_in_use = pd_addresses[pd_addresses_order[pd_address_in_use]]; if (omniORB::trace(20)) { omniORB::logger l; l << "Switch rope to use address " << addr_in_use->address() << "\n"; } } if (!heldlock) { omniTransportLock->unlock(); } return addr_in_use; }
false
false
false
false
false
0
append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_constructed, int exp_pad, int imp_ok) { tag_exp_type *exp_tmp; /* Can only have IMPLICIT if permitted */ if ((arg->imp_tag != -1) && !imp_ok) { ASN1err(ASN1_F_APPEND_EXP, ASN1_R_ILLEGAL_IMPLICIT_TAG); return 0; } if (arg->exp_count == ASN1_FLAG_EXP_MAX) { ASN1err(ASN1_F_APPEND_EXP, ASN1_R_DEPTH_EXCEEDED); return 0; } exp_tmp = &arg->exp_list[arg->exp_count++]; /* If IMPLICIT set tag to implicit value then * reset implicit tag since it has been used. */ if (arg->imp_tag != -1) { exp_tmp->exp_tag = arg->imp_tag; exp_tmp->exp_class = arg->imp_class; arg->imp_tag = -1; arg->imp_class = -1; } else { exp_tmp->exp_tag = exp_tag; exp_tmp->exp_class = exp_class; } exp_tmp->exp_constructed = exp_constructed; exp_tmp->exp_pad = exp_pad; return 1; }
false
false
false
false
false
0
snd_pcm_dsnoop_mmap_commit(snd_pcm_t *pcm, snd_pcm_uframes_t offset ATTRIBUTE_UNUSED, snd_pcm_uframes_t size) { snd_pcm_direct_t *dsnoop = pcm->private_data; int err; switch (snd_pcm_state(dsnoop->spcm)) { case SND_PCM_STATE_XRUN: return -EPIPE; case SND_PCM_STATE_SUSPENDED: return -ESTRPIPE; default: break; } if (dsnoop->state == SND_PCM_STATE_RUNNING) { err = snd_pcm_dsnoop_sync_ptr(pcm); if (err < 0) return err; } snd_pcm_mmap_appl_forward(pcm, size); /* clear timer queue to avoid a bogus return from poll */ if (snd_pcm_mmap_capture_avail(pcm) < pcm->avail_min) snd_pcm_direct_clear_timer_queue(dsnoop); return size; }
false
false
false
false
false
0
setModeGain(unsigned int modeIndex, StkFloat gain) { if ( modeIndex >= nModes_ ) { errorString_ << "Modal::setModeGain: modeIndex parameter is greater than number of modes!"; handleError( StkError::WARNING ); return; } filters_[modeIndex]->setGain(gain); }
false
false
false
false
false
0
_mysql_jobcomp_check_tables() { if (mysql_db_create_table(jobcomp_mysql_conn, jobcomp_table, jobcomp_table_fields, ")") == SLURM_ERROR) return SLURM_ERROR; return SLURM_SUCCESS; }
false
false
false
false
false
0
thread_interrupt (DebuggerTlsData *tls, MonoThreadInfo *info, void *sigctx, MonoJitInfo *ji) { gboolean res; gpointer ip; MonoNativeThreadId tid; /* * OSX can (and will) coalesce signals, so sending multiple pthread_kills does not * guarantee the signal handler will be called that many times. Instead of tracking * interrupt_count on osx, we use this as a boolean flag to determine if a interrupt * has been requested that hasn't been handled yet, otherwise we can have threads * refuse to die when VM_EXIT is called */ #if defined(__APPLE__) if (InterlockedCompareExchange (&tls->interrupt_count, 0, 1) == 0) return FALSE; #else /* * We use interrupt_count to determine whenever this interrupt should be processed * by us or the normal interrupt processing code in the signal handler. * There is no race here with notify_thread (), since the signal is sent after * incrementing interrupt_count. */ if (tls->interrupt_count == 0) return FALSE; InterlockedDecrement (&tls->interrupt_count); #endif if (sigctx) ip = mono_arch_ip_from_context (sigctx); else if (info) ip = MONO_CONTEXT_GET_IP (&info->suspend_state.ctx); else ip = NULL; if (info) tid = mono_thread_info_get_tid (info); else tid = (MonoNativeThreadId)GetCurrentThreadId (); // FIXME: Races when the thread leaves managed code before hitting a single step // event. if (ji) { /* Running managed code, will be suspended by the single step code */ DEBUG (1, fprintf (log_file, "[%p] Received interrupt while at %s(%p), continuing.\n", (gpointer)(gsize)tid, jinfo_get_method (ji)->name, ip)); return TRUE; } else { /* * Running native code, will be suspended when it returns to/enters * managed code. Treat it as already suspended. * This might interrupt the code in process_single_step_inner (), we use the * tls->suspending flag to avoid races when that happens. */ if (!tls->suspended && !tls->suspending) { MonoContext ctx; GetLastFrameUserData data; // FIXME: printf is not signal safe, but this is only used during // debugger debugging if (ip) DEBUG (1, fprintf (log_file, "[%p] Received interrupt while at %p, treating as suspended.\n", (gpointer)(gsize)tid, ip)); //save_thread_context (&ctx); if (!tls->thread) /* Already terminated */ return TRUE; /* * We are in a difficult position: we want to be able to provide stack * traces for this thread, but we can't use the current ctx+lmf, since * the thread is still running, so it might return to managed code, * making these invalid. * So we start a stack walk and save the first frame, along with the * parent frame's ctx+lmf. This (hopefully) works because the thread will be * suspended when it returns to managed code, so the parent's ctx should * remain valid. */ data.last_frame_set = FALSE; if (sigctx) { mono_arch_sigctx_to_monoctx (sigctx, &ctx); /* * Don't pass MONO_UNWIND_ACTUAL_METHOD, its not signal safe, and * get_last_frame () doesn't need it, the last frame cannot be a ginst * since we are not in a JITted method. */ mono_walk_stack_with_ctx (get_last_frame, &ctx, MONO_UNWIND_NONE, &data); } else if (info) { mono_get_eh_callbacks ()->mono_walk_stack_with_state (get_last_frame, &info->suspend_state, MONO_UNWIND_SIGNAL_SAFE, &data); } if (data.last_frame_set) { memcpy (&tls->async_last_frame, &data.last_frame, sizeof (StackFrameInfo)); res = mono_thread_state_init_from_monoctx (&tls->async_state, &ctx); g_assert (res); mono_thread_state_init_from_monoctx (&tls->context, &ctx); g_assert (res); memcpy (&tls->async_state.ctx, &data.ctx, sizeof (MonoContext)); tls->async_state.unwind_data [MONO_UNWIND_DATA_LMF] = data.lmf; tls->async_state.unwind_data [MONO_UNWIND_DATA_JIT_TLS] = tls->thread->jit_data; } else { tls->async_state.valid = FALSE; } mono_memory_barrier (); tls->suspended = TRUE; MONO_SEM_POST (&suspend_sem); } return TRUE; } }
false
true
false
false
false
1
acpi_ex_create_mutex(struct acpi_walk_state *walk_state) { acpi_status status = AE_OK; union acpi_operand_object *obj_desc; ACPI_FUNCTION_TRACE_PTR(ex_create_mutex, ACPI_WALK_OPERANDS); /* Create the new mutex object */ obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX); if (!obj_desc) { status = AE_NO_MEMORY; goto cleanup; } /* Create the actual OS Mutex */ status = acpi_os_create_mutex(&obj_desc->mutex.os_mutex); if (ACPI_FAILURE(status)) { goto cleanup; } /* Init object and attach to NS node */ obj_desc->mutex.sync_level = (u8)walk_state->operands[1]->integer.value; obj_desc->mutex.node = (struct acpi_namespace_node *)walk_state->operands[0]; status = acpi_ns_attach_object(obj_desc->mutex.node, obj_desc, ACPI_TYPE_MUTEX); cleanup: /* * Remove local reference to the object (on error, will cause deletion * of both object and semaphore if present.) */ acpi_ut_remove_reference(obj_desc); return_ACPI_STATUS(status); }
false
false
false
false
false
0
parse_enumlist(FILE * fp, struct enum_list **retp) { register int type; char token[MAXTOKEN]; struct enum_list *ep = NULL, **epp = &ep; free_enums(retp); while ((type = get_token(fp, token, MAXTOKEN)) != ENDOFFILE) { if (type == RIGHTBRACKET) break; /* some enums use "deprecated" to indicate a no longer value label */ /* (EG: IP-MIB's IpAddressStatusTC) */ if (type == LABEL || type == DEPRECATED) { /* * this is an enumerated label */ *epp = (struct enum_list *) calloc(1, sizeof(struct enum_list)); if (*epp == NULL) return (NULL); /* * a reasonable approximation for the length */ (*epp)->label = strdup(token); type = get_token(fp, token, MAXTOKEN); if (type != LEFTPAREN) { print_error("Expected \"(\"", token, type); return NULL; } type = get_token(fp, token, MAXTOKEN); if (type != NUMBER) { print_error("Expected integer", token, type); return NULL; } (*epp)->value = strtol(token, NULL, 10); type = get_token(fp, token, MAXTOKEN); if (type != RIGHTPAREN) { print_error("Expected \")\"", token, type); return NULL; } epp = &(*epp)->next; } } if (type == ENDOFFILE) { print_error("Expected \"}\"", token, type); return NULL; } *retp = ep; return ep; }
false
false
false
false
false
0
st_destroy(search_table_t *table) { int i; search_table_check(table); if (table->bins) { for (i = 0; i < table->nbins; i++) { struct st_bin *bin = table->bins[i]; if (bin) { bin_destroy(bin); WFREE(bin); } } HFREE_NULL(table->bins); } if (table->all_entries.vals) { for (i = 0; i < table->all_entries.nvals; i++) { destroy_entry(table->all_entries.vals[i]); table->all_entries.vals[i] = NULL; } bin_destroy(&table->all_entries); } }
false
false
false
false
false
0
ShortCircuitConsString(Object** p) { // Optimization: If the heap object pointed to by p is a non-symbol // cons string whose right substring is Heap::empty_string, update // it in place to its left substring. Return the updated value. // // Here we assume that if we change *p, we replace it with a heap object // (ie, the left substring of a cons string is always a heap object). // // The check performed is: // object->IsConsString() && !object->IsSymbol() && // (ConsString::cast(object)->second() == Heap::empty_string()) // except the maps for the object and its possible substrings might be // marked. HeapObject* object = HeapObject::cast(*p); MapWord map_word = object->map_word(); map_word.ClearMark(); InstanceType type = map_word.ToMap()->instance_type(); if ((type & kShortcutTypeMask) != kShortcutTypeTag) return object; Object* second = reinterpret_cast<ConsString*>(object)->unchecked_second(); if (second != Heap::raw_unchecked_empty_string()) { return object; } // Since we don't have the object's start, it is impossible to update the // remembered set. Therefore, we only replace the string with its left // substring when the remembered set does not change. Object* first = reinterpret_cast<ConsString*>(object)->unchecked_first(); if (!Heap::InNewSpace(object) && Heap::InNewSpace(first)) return object; *p = first; return HeapObject::cast(first); }
false
false
false
false
false
0
gss_inquire_attrs_for_mech(OM_uint32 * minor_status, gss_const_OID mech, gss_OID_set *mech_attr, gss_OID_set *known_mech_attrs) { OM_uint32 major, junk; if (known_mech_attrs) *known_mech_attrs = GSS_C_NO_OID_SET; if (mech_attr && mech) { gssapi_mech_interface m; struct gss_mech_compat_desc_struct *gmc; if ((m = __gss_get_mechanism(mech)) == NULL) { *minor_status = 0; return GSS_S_BAD_MECH; } gmc = m->gm_compat; if (gmc && gmc->gmc_inquire_attrs_for_mech) { major = gmc->gmc_inquire_attrs_for_mech(minor_status, mech, mech_attr, known_mech_attrs); } else { major = gss_create_empty_oid_set(minor_status, mech_attr); if (major == GSS_S_COMPLETE) add_all_mo(m, mech_attr, GSS_MO_MA); } if (GSS_ERROR(major)) return major; } if (known_mech_attrs) { struct _gss_mech_switch *m; if (*known_mech_attrs == GSS_C_NO_OID_SET) { major = gss_create_empty_oid_set(minor_status, known_mech_attrs); if (GSS_ERROR(major)) { if (mech_attr) gss_release_oid_set(&junk, mech_attr); return major; } } _gss_load_mech(); HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) add_all_mo(&m->gm_mech, known_mech_attrs, GSS_MO_MA); } return GSS_S_COMPLETE; }
false
false
false
false
false
0
_buildAuthorProps(pp_Author * pAuthor, const gchar **& szProps, std::string & storage) { const PP_AttrProp * pAP = pAuthor->getAttrProp(); UT_uint32 iCnt= pAP->getPropertyCount(); szProps = new const gchar * [2*iCnt + 3]; UT_DEBUGMSG(("_buildAuthorProps getAuthorInt %d \n",pAuthor->getAuthorInt())); storage = UT_std_string_sprintf("%d",pAuthor->getAuthorInt()); szProps[0] = "id"; szProps[1] = storage.c_str(); UT_uint32 i = 0; const gchar * szName = NULL; const gchar * szValue = NULL; UT_uint32 j = 2; for(i=0;i<iCnt;i++) { pAP->getNthProperty(i,szName,szValue); if(*szValue) { szProps[j++] = szName; szProps[j++] = szValue; } } szProps[j] = NULL; return true; }
false
false
false
false
false
0
clutter_gst_auto_video_sink_sink_pad_blocked_cb (GstPad *pad, gboolean blocked, gpointer user_data) { ClutterGstAutoVideoSink *bin = CLUTTER_GST_AUTO_VIDEO_SINK_CAST (user_data); GstCaps *caps = NULL; /* In case the pad is not blocked we should not do anything but return */ if (!blocked) { GST_DEBUG_OBJECT (bin, "pad successfully unblocked"); return; } CLUTTER_GST_AUTO_VIDEO_SINK_LOCK (bin); /* This only occurs when our bin is first initialised || stream changes */ if (G_UNLIKELY (!bin->setup)) { caps = gst_pad_peer_get_caps_reffed (bin->sink_pad); if (G_UNLIKELY (!caps)) { GST_WARNING_OBJECT (bin, "no incoming caps defined, can't setup"); goto beach; } if (G_UNLIKELY (gst_caps_is_empty (caps))) { GST_WARNING_OBJECT (bin, "caps empty, can't setup"); goto beach; } GST_DEBUG_OBJECT (bin, "incoming caps %" GST_PTR_FORMAT, caps); if (!clutter_gst_auto_video_sink_reconfigure (bin, caps)) goto beach; /* We won't be doing this again unless stream changes */ bin->setup = TRUE; } /* Note that we finished our ASYNC state change but our children will have * posted their own messages on our bus. */ clutter_gst_auto_video_sink_do_async_done (bin); GST_DEBUG_OBJECT (bin, "unblock the pad"); beach: if (caps) { gst_caps_unref (caps); } gst_pad_set_blocked_async (bin->sink_block_pad, FALSE, clutter_gst_auto_video_sink_sink_pad_blocked_cb, bin); CLUTTER_GST_AUTO_VIDEO_SINK_UNLOCK (bin); return; }
false
false
false
false
false
0
gli_draw_string(int x, int y, int fidx, unsigned char *rgb, unsigned char *s, int n, int spw) { font_t *f = &gfont_table[fidx]; int dolig = ! FT_IS_FIXED_WIDTH(f->face); int prev = -1; glui32 c; int px, sx; if ( FT_Get_Char_Index(f->face, UNI_LIG_FI) == 0 ) dolig = 0; if ( FT_Get_Char_Index(f->face, UNI_LIG_FL) == 0 ) dolig = 0; while (n--) { bitmap_t *glyphs; int adv; c = touni(*s++); if (dolig && n && c == 'f' && *s == 'i') { c = UNI_LIG_FI; s++; n--; } if (dolig && n && c == 'f' && *s == 'l') { c = UNI_LIG_FL; s++; n--; } getglyph(f, c, &adv, &glyphs); if (prev != -1) x += charkern(f, prev, c); px = x / GLI_SUBPIX; sx = x % GLI_SUBPIX; if (gli_conf_lcd) draw_bitmap_lcd(&glyphs[sx], px, y, rgb); else draw_bitmap(&glyphs[sx], px, y, rgb); if (spw >= 0 && c == ' ') x += spw; else x += adv; prev = c; } return x; }
false
false
false
false
false
0
gt_array_rem_span(GtArray *a, unsigned long frompos, unsigned long topos) { unsigned long i, len; gt_assert(a && frompos <= topos); gt_assert(frompos < a->next_free && topos < a->next_free); /* move elements */ len = topos - frompos + 1; for (i = topos + 1; i < a->next_free; i++) { memcpy((char*) a->space + (i-len) * a->size_of_elem, (char*) a->space + i * a->size_of_elem, a->size_of_elem); } /* remove last (now duplicated) elements */ a->next_free -= len; }
false
false
false
false
false
0