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
usable_obs (const double *x, const double *y0, const double *y1, int t, const double **py) { *py = y0; if (!na(x[t]) && !na(y0[t])) { return 1; } else if (!na(x[t]) && y1 != NULL && !na(y1[t])) { *py = y1; return 1; } else { return 0; } }
false
false
false
false
false
0
loop_backing_file(struct super_block *sb) { struct file *ret; struct loop_device *l; ret = NULL; if (MAJOR(sb->s_dev) == LOOP_MAJOR) { l = sb->s_bdev->bd_disk->private_data; ret = l->lo_backing_file; } return ret; }
false
false
false
false
false
0
md_gets(BIO *bp, char *buf, int size) { EVP_MD_CTX *ctx; unsigned int ret; ctx=bp->ptr; if (size < ctx->digest->md_size) return(0); if (EVP_DigestFinal_ex(ctx,(unsigned char *)buf,&ret)<=0) return -1; return((int)ret); }
false
false
false
false
false
0
str_AddChars(char *string,char *append,long len) { if(string==NULL) { string = (char*)malloc(len+1); memcpy(string,append,len); string[len] = 0; return(string); } int slen=strlen(string); string = (char*)realloc(string,slen+len+1); string[slen+len] = 0; memcpy(string+slen,append,len); return(string); }
false
false
false
false
false
0
create_fire_button_selector( const char *title, struct button_info *info, GtkBox *parent, GtkTreeModel *model ) { GtkWidget *frame, *box, *combo; GtkCellRenderer *renderer; GtkTreeIter iter; GtkTreePath *path; size_t i; frame = gtk_frame_new( title ); gtk_box_pack_start( parent, frame, TRUE, TRUE, 0 ); box = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 4 ); gtk_container_set_border_width( GTK_CONTAINER( box ), 2 ); gtk_container_add( GTK_CONTAINER( frame ), box ); /* Create label */ info->key = *info->setting; info->label = gtk_label_new( "" ); for( i = 0; i < key_menu_count; i++ ) { keyboard_key_name key; key = key_menu[i].key; if( key_menu[i].item != GROUP && key == (unsigned int)*info->setting ) { set_key_text( info->label, key ); break; } } gtk_box_pack_start( GTK_BOX( box ), info->label, TRUE, TRUE, 0 ); /* Create combobox */ combo = gtk_combo_box_new_with_model( model ); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo ), renderer, TRUE ); gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( combo ), renderer, "text", 0, NULL ); gtk_cell_layout_set_cell_data_func( GTK_CELL_LAYOUT( combo ), renderer, set_entry_properties, NULL, NULL ); /* Select first item */ path = gtk_tree_path_new_from_indices( 0, -1 ); gtk_tree_model_get_iter( model, &iter, path ); gtk_tree_path_free( path ); gtk_combo_box_set_active_iter( GTK_COMBO_BOX( combo ), &iter ); gtk_box_pack_start( GTK_BOX( box ), combo, TRUE, TRUE, 0 ); g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( key_callback ), info ); }
false
false
false
false
false
0
ipmi_oem_fujitsu_get_error_led (ipmi_oem_state_data_t *state_data) { uint8_t bytes_rq[IPMI_OEM_MAX_BYTES]; uint8_t bytes_rs[IPMI_OEM_MAX_BYTES]; uint8_t state; int rs_len; int rv = -1; assert (state_data); assert (!state_data->prog_data->args->oem_options_count); /* Fujitsu OEM * * http://manuals.ts.fujitsu.com/file/4390/irmc_s2-en.pdf * * Request * * 0x2E - OEM network function * 0xF5 - OEM cmd * 0x?? - Fujitsu IANA (LSB first) * 0x?? - Fujitsu IANA * 0x?? - Fujitsu IANA * 0xB3 - Command Specifier * * Response * * 0xF5 - OEM cmd * 0x?? - Completion code * 0x?? - Fujitsu IANA (LSB first) * 0x?? - Fujitsu IANA * 0x?? - Fujitsu IANA * 0x?? - error led state * * GEL - Global Error LED * CSS - Customer Self Service LED * * 0 - CSS off / GEL off * 1 - CSS off / GEL on * 2 - CSS off / GEL blink * 3 - CSS on / GEL off * 4 - CSS on / GEL on * 5 - CSS on / GEL blink * 6 - CSS blink / GEL off * 7 - CSS blink / GEL on * 8 - CSS blink / GEL blink */ bytes_rq[0] = IPMI_CMD_OEM_FUJITSU_SYSTEM; bytes_rq[1] = (IPMI_IANA_ENTERPRISE_ID_FUJITSU & 0x0000FF); bytes_rq[2] = (IPMI_IANA_ENTERPRISE_ID_FUJITSU & 0x00FF00) >> 8; bytes_rq[3] = (IPMI_IANA_ENTERPRISE_ID_FUJITSU & 0xFF0000) >> 16; bytes_rq[4] = IPMI_OEM_FUJITSU_COMMAND_SPECIFIER_GET_ERROR_LED; if ((rs_len = ipmi_cmd_raw (state_data->ipmi_ctx, 0, /* lun */ IPMI_NET_FN_OEM_GROUP_RQ, /* network function */ bytes_rq, /* data */ 5, /* num bytes */ bytes_rs, IPMI_OEM_MAX_BYTES)) < 0) { pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_raw: %s\n", ipmi_ctx_errormsg (state_data->ipmi_ctx)); goto cleanup; } if (ipmi_oem_check_response_and_completion_code (state_data, bytes_rs, rs_len, 6, IPMI_CMD_OEM_FUJITSU_SYSTEM, IPMI_NET_FN_OEM_GROUP_RS, NULL) < 0) goto cleanup; state = bytes_rs[5]; switch (state) { case IPMI_OEM_FUJITSU_ERROR_LED_CSS_OFF_GEL_OFF: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_OFF_GEL_ON: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_OFF_GEL_BLINK: pstdout_printf (state_data->pstate, "CSS LED: off\n"); break; case IPMI_OEM_FUJITSU_ERROR_LED_CSS_ON_GEL_OFF: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_ON_GEL_ON: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_ON_GEL_BLINK: pstdout_printf (state_data->pstate, "CSS LED: on\n"); break; case IPMI_OEM_FUJITSU_ERROR_LED_CSS_BLINK_GEL_OFF: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_BLINK_GEL_ON: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_BLINK_GEL_BLINK: pstdout_printf (state_data->pstate, "CSS LED: blink\n"); break; default: pstdout_printf (state_data->pstate, "Unrecognized LED state: %02Xh\n", state); goto cleanup; } switch (state) { case IPMI_OEM_FUJITSU_ERROR_LED_CSS_OFF_GEL_OFF: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_ON_GEL_OFF: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_BLINK_GEL_OFF: pstdout_printf (state_data->pstate, "GEL LED: off\n"); break; case IPMI_OEM_FUJITSU_ERROR_LED_CSS_OFF_GEL_ON: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_ON_GEL_ON: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_BLINK_GEL_ON: pstdout_printf (state_data->pstate, "GEL LED: on\n"); break; case IPMI_OEM_FUJITSU_ERROR_LED_CSS_OFF_GEL_BLINK: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_ON_GEL_BLINK: case IPMI_OEM_FUJITSU_ERROR_LED_CSS_BLINK_GEL_BLINK: pstdout_printf (state_data->pstate, "GEL LED: blink\n"); break; default: pstdout_printf (state_data->pstate, "Unrecognized LED state: %02Xh\n", state); goto cleanup; } rv = 0; cleanup: return (rv); }
false
false
false
false
false
0
rad_packet_build(struct rad_packet_t *pack, uint8_t *RA) { struct rad_attr_t *attr; uint8_t *ptr; if (!pack->buf) { //ptr = mmap(NULL, REQ_LENGTH_MAX, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); ptr = mempool_alloc(buf_pool); //if (ptr == MAP_FAILED) { if (!ptr) { log_emerg("radius:packet: out of memory\n"); return -1; } pack->buf = ptr; } else ptr = pack->buf; *ptr = pack->code; ptr++; *ptr = pack->id; ptr++; *(uint16_t*)ptr = htons(pack->len); ptr+= 2; memcpy(ptr, RA, 16); ptr+=16; list_for_each_entry(attr, &pack->attrs, entry) { if (attr->vendor) { *ptr = 26; ptr++; *ptr = attr->len + 2 + 6; ptr++; *(uint32_t *)ptr = htonl(attr->vendor->id); ptr+=4; } *ptr = attr->attr->id; ptr++; *ptr = attr->len + 2; ptr++; switch(attr->attr->type) { case ATTR_TYPE_INTEGER: *(uint32_t*)ptr = htonl(attr->val.integer); break; case ATTR_TYPE_OCTETS: case ATTR_TYPE_STRING: memcpy(ptr, attr->val.string, attr->len); break; case ATTR_TYPE_IPADDR: case ATTR_TYPE_IFID: case ATTR_TYPE_IPV6ADDR: memcpy(ptr, &attr->val, attr->len); break; case ATTR_TYPE_DATE: *(uint32_t*)ptr = htonl(attr->val.date); break; case ATTR_TYPE_IPV6PREFIX: ptr[0] = 0; ptr[1] = attr->val.ipv6prefix.len; memcpy(ptr + 2, &attr->val.ipv6prefix.prefix, sizeof(attr->val.ipv6prefix.prefix)); break; default: log_emerg("radius:packet:BUG: unknown attribute type\n"); abort(); } ptr += attr->len; } //print_buf(pack->buf, pack->len); return 0; }
false
true
false
false
false
1
e_source_to_string (ESource *source, gsize *length) { GHashTableIter iter; GKeyFile *key_file; gpointer group_name; gpointer extension; gchar *data; g_return_val_if_fail (E_IS_SOURCE (source), NULL); g_rec_mutex_lock (&source->priv->lock); key_file = source->priv->key_file; source_save_to_key_file ( G_OBJECT (source), key_file, PRIMARY_GROUP_NAME); g_hash_table_iter_init (&iter, source->priv->extensions); while (g_hash_table_iter_next (&iter, &group_name, &extension)) source_save_to_key_file (extension, key_file, group_name); data = g_key_file_to_data (key_file, length, NULL); g_rec_mutex_unlock (&source->priv->lock); return data; }
false
false
false
false
false
0
settings_model_real_iter_n_children (GtkTreeModel* base, GtkTreeIter* iter) { SettingsModel * self; gint result = 0; GtkTreeIter* _tmp0_; Directory* _tmp1_ = NULL; Directory* _tmp2_; GList* _tmp3_; GList* _tmp4_; guint _tmp5_ = 0U; gint _tmp6_; self = (SettingsModel*) base; _tmp0_ = iter; _tmp1_ = settings_model_get_directory (self, _tmp0_); _tmp2_ = _tmp1_; _tmp3_ = directory_get_children (_tmp2_); _tmp4_ = _tmp3_; _tmp5_ = g_list_length (_tmp4_); _tmp6_ = (gint) _tmp5_; _g_object_unref0 (_tmp2_); result = _tmp6_; return result; }
false
false
false
false
false
0
lutil_progname( const char* name, int argc, char *argv[] ) { char *progname; if(argc == 0) { return (char *)name; } #ifdef HAVE_EBCDIC if (_trans_argv) { int i; for (i=0; i<argc; i++) __etoa(argv[i]); _trans_argv = 0; } #endif LUTIL_SLASHPATH( argv[0] ); progname = strrchr ( argv[0], *LDAP_DIRSEP ); progname = progname ? &progname[1] : argv[0]; #ifdef _WIN32 { size_t len = strlen( progname ); if ( len > 4 && strcasecmp( &progname[len - 4], ".exe" ) == 0 ) progname[len - 4] = '\0'; } #endif return progname; }
false
false
false
false
false
0
link_sna_to_packet(g2_packet_t *target, union combo_addr *source) { /* We Assume network byte order for the IP */ if(AF_INET == source->s.fam){ target->data_trunk.data = (void *)&source->in.sin_addr.s_addr; target->data_trunk.capacity = sizeof(uint32_t); } else { target->data_trunk.data = (void *)source->in6.sin6_addr.s6_addr; target->data_trunk.capacity = INET6_ADDRLEN; } target->data_trunk_is_freeable = false; buffer_clear(target->data_trunk); target->big_endian = HOST_IS_BIGENDIAN; }
false
false
false
false
false
0
csd_lock_wait(struct call_single_data *csd) { while (smp_load_acquire(&csd->flags) & CSD_FLAG_LOCK) cpu_relax(); }
false
false
false
false
false
0
code_write(const output::pointer &fp, int code, int code_size) { trace(("code_write(fp = %08lX, code = 0x%.*X, code_size = %d)", (long)fp.get(), (code_size + 3) / 4, code, code_size)); pack_buffer |= code << pack_buffer_len; pack_buffer_len += code_size; trace(("pack_buffer = 0x%.*lX", (pack_buffer_len + 3) / 4, pack_buffer)); trace(("pack_buffer_len = %d;", pack_buffer_len)); while (pack_buffer_len >= 8) { oof(fp, pack_buffer & 0xFF); pack_buffer >>= 8; pack_buffer_len -= 8; trace(("pack_buffer = 0x%.*lX", (pack_buffer_len + 3) / 4, pack_buffer)); trace(("pack_buffer_len = %d;", pack_buffer_len)); } }
false
false
false
false
false
0
ace_allocate_descriptors(struct net_device *dev) { struct ace_private *ap = netdev_priv(dev); int size; size = (sizeof(struct rx_desc) * (RX_STD_RING_ENTRIES + RX_JUMBO_RING_ENTRIES + RX_MINI_RING_ENTRIES + RX_RETURN_RING_ENTRIES)); ap->rx_std_ring = pci_alloc_consistent(ap->pdev, size, &ap->rx_ring_base_dma); if (ap->rx_std_ring == NULL) goto fail; ap->rx_jumbo_ring = ap->rx_std_ring + RX_STD_RING_ENTRIES; ap->rx_mini_ring = ap->rx_jumbo_ring + RX_JUMBO_RING_ENTRIES; ap->rx_return_ring = ap->rx_mini_ring + RX_MINI_RING_ENTRIES; size = (sizeof(struct event) * EVT_RING_ENTRIES); ap->evt_ring = pci_alloc_consistent(ap->pdev, size, &ap->evt_ring_dma); if (ap->evt_ring == NULL) goto fail; /* * Only allocate a host TX ring for the Tigon II, the Tigon I * has to use PCI registers for this ;-( */ if (!ACE_IS_TIGON_I(ap)) { size = (sizeof(struct tx_desc) * MAX_TX_RING_ENTRIES); ap->tx_ring = pci_alloc_consistent(ap->pdev, size, &ap->tx_ring_dma); if (ap->tx_ring == NULL) goto fail; } ap->evt_prd = pci_alloc_consistent(ap->pdev, sizeof(u32), &ap->evt_prd_dma); if (ap->evt_prd == NULL) goto fail; ap->rx_ret_prd = pci_alloc_consistent(ap->pdev, sizeof(u32), &ap->rx_ret_prd_dma); if (ap->rx_ret_prd == NULL) goto fail; ap->tx_csm = pci_alloc_consistent(ap->pdev, sizeof(u32), &ap->tx_csm_dma); if (ap->tx_csm == NULL) goto fail; return 0; fail: /* Clean up. */ ace_init_cleanup(dev); return 1; }
false
false
false
false
false
0
find_charmap(const unsigned char *name) { unsigned char buf[1024]; unsigned char *p; struct charmap *m; struct builtin_charmap *b; FILE *f = NULL; int y; if (!name) return 0; /* Install some initial character maps */ if (!charmaps) load_builtins(); /* Alias? */ for (y=0; alias_table[y].alias; ++y) if (!map_name_cmp(alias_table[y].alias,name)) { name = alias_table[y].builtin; break; } /* Already loaded? */ for (m=charmaps; m; m=m->next) if (!map_name_cmp(m->name,name)) return m; /* Check ~/.joe/charmaps */ p = (unsigned char *)getenv("HOME"); if (p) { joe_snprintf_2((char *)buf,sizeof(buf),"%s/.joe/charmaps/%s",p,name); f = fopen((char *)buf,"r"); } /* Check JOERCcharmaps */ if (!f) { joe_snprintf_2((char *)buf,sizeof(buf),"%scharmaps/%s",JOERC,name); f = fopen((char *)buf,"r"); } /* Parse and install character map from file */ if (f && (b = parse_charmap(name,f))) return process_builtin(b); /* Check builtin sets */ for (y=0; y!=sizeof(builtin_charmaps)/sizeof(struct builtin_charmap); ++y) if (!map_name_cmp(builtin_charmaps[y].name,name)) return process_builtin(builtin_charmaps + y); return NULL; }
false
false
false
false
false
0
_getFloatConstantLogicalIndexUse( size_t logicalIndex, size_t requestedSize, uint16 variability) { if (mFloatLogicalToPhysical.isNull()) return 0; GpuLogicalIndexUse* indexUse = 0; OGRE_LOCK_MUTEX(mFloatLogicalToPhysical->mutex); GpuLogicalIndexUseMap::iterator logi = mFloatLogicalToPhysical->map.find(logicalIndex); if (logi == mFloatLogicalToPhysical->map.end()) { if (requestedSize) { size_t physicalIndex = mFloatConstants.size(); // Expand at buffer end mFloatConstants.insert(mFloatConstants.end(), requestedSize, 0.0f); // Record extended size for future GPU params re-using this information mFloatLogicalToPhysical->bufferSize = mFloatConstants.size(); // low-level programs will not know about mapping ahead of time, so // populate it. Other params objects will be able to just use this // accepted mapping since the constant structure will be the same // Set up a mapping for all items in the count size_t currPhys = physicalIndex; size_t count = requestedSize / 4; GpuLogicalIndexUseMap::iterator insertedIterator; for (size_t logicalNum = 0; logicalNum < count; ++logicalNum) { GpuLogicalIndexUseMap::iterator it = mFloatLogicalToPhysical->map.insert( GpuLogicalIndexUseMap::value_type( logicalIndex + logicalNum, GpuLogicalIndexUse(currPhys, requestedSize, variability))).first; currPhys += 4; if (logicalNum == 0) insertedIterator = it; } indexUse = &(insertedIterator->second); } else { // no match & ignore return 0; } } else { size_t physicalIndex = logi->second.physicalIndex; indexUse = &(logi->second); // check size if (logi->second.currentSize < requestedSize) { // init buffer entry wasn't big enough; could be a mistake on the part // of the original use, or perhaps a variable length we can't predict // until first actual runtime use e.g. world matrix array size_t insertCount = requestedSize - logi->second.currentSize; FloatConstantList::iterator insertPos = mFloatConstants.begin(); std::advance(insertPos, physicalIndex); mFloatConstants.insert(insertPos, insertCount, 0.0f); // shift all physical positions after this one for (GpuLogicalIndexUseMap::iterator i = mFloatLogicalToPhysical->map.begin(); i != mFloatLogicalToPhysical->map.end(); ++i) { if (i->second.physicalIndex > physicalIndex) i->second.physicalIndex += insertCount; } mFloatLogicalToPhysical->bufferSize += insertCount; for (AutoConstantList::iterator i = mAutoConstants.begin(); i != mAutoConstants.end(); ++i) { const GpuProgramParameters::AutoConstantDefinition* def = getAutoConstantDefinition(i->paramType); if (i->physicalIndex > physicalIndex && def && def->elementType == ET_REAL) { i->physicalIndex += insertCount; } } if (!mNamedConstants.isNull()) { for (GpuConstantDefinitionMap::iterator i = mNamedConstants->map.begin(); i != mNamedConstants->map.end(); ++i) { if (i->second.isFloat() && i->second.physicalIndex > physicalIndex) i->second.physicalIndex += insertCount; } mNamedConstants->floatBufferSize += insertCount; } logi->second.currentSize += insertCount; } } if (indexUse) indexUse->variability = variability; return indexUse; }
false
false
false
false
false
0
getbeforeafter(widecharbuf &wbefore, widecharbuf &wafter) { std::vector<unicode_char> before, after; text.get_contents(before, after); wbefore.init_unicode(before.begin(), before.end()); wafter.init_unicode(after.begin(), after.end()); }
false
false
false
false
false
0
irqhandler(int irq, struct uio_info *info) { struct uio_pci_generic_dev *gdev = to_uio_pci_generic_dev(info); if (!pci_check_and_mask_intx(gdev->pdev)) return IRQ_NONE; /* UIO core will signal the user process. */ return IRQ_HANDLED; }
false
false
false
false
false
0
pg_toupper(unsigned char ch) { if (ch >= 'a' && ch <= 'z') ch += 'A' - 'a'; else if (IS_HIGHBIT_SET(ch) && islower(ch)) ch = toupper(ch); return ch; }
false
false
false
false
false
0
my_compose_create_hook(gpointer cw, gpointer data) { gint ii; GSList *walk; GtkActionEntry *entries; GtkActionGroup *action_group; Compose *compose = (Compose*)cw; guint num_entries = g_slist_length(python_compose_scripts_names); action_group = gtk_action_group_new("PythonPlugin"); gtk_action_group_add_actions(action_group, compose_tools_python_actions, 1, NULL); entries = g_new0(GtkActionEntry, num_entries); ii = 0; for(walk = python_compose_scripts_names; walk; walk = walk->next) { ComposeActionData *dat; entries[ii].name = walk->data; entries[ii].label = walk->data; entries[ii].callback = G_CALLBACK(python_compose_script_callback); dat = g_new0(ComposeActionData, 1); dat->name = g_strdup(walk->data); dat->compose = compose; gtk_action_group_add_actions_full(action_group, &(entries[ii]), 1, dat, ComposeActionData_destroy_cb); ii++; } gtk_ui_manager_insert_action_group(compose->ui_manager, action_group, 0); MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Tools", "PythonScripts", "Tools/PythonScripts", GTK_UI_MANAGER_MENU) for(ii = 0; ii < num_entries; ii++) { MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/" PYTHON_SCRIPTS_ACTION_PREFIX, entries[ii].label, entries[ii].name, GTK_UI_MANAGER_MENUITEM) } g_free(entries); run_auto_script_file_if_it_exists(PYTHON_SCRIPTS_AUTO_COMPOSE, compose); return FALSE; }
false
false
false
false
false
0
CreateMatrixOffsetOp(OpRcPtrVec & ops, const float * m44, const float * offset4, TransformDirection direction) { bool mtxIsIdentity = IsM44Identity(m44); bool offsetIsIdentity = IsVecEqualToZero(offset4, 4); if(mtxIsIdentity && offsetIsIdentity) return; ops.push_back( MatrixOffsetOpRcPtr(new MatrixOffsetOp(m44, offset4, direction)) ); }
false
false
false
false
false
0
i915_gem_open(struct drm_device *dev, struct drm_file *file) { struct drm_i915_file_private *file_priv; int ret; DRM_DEBUG_DRIVER("\n"); file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL); if (!file_priv) return -ENOMEM; file->driver_priv = file_priv; file_priv->dev_priv = dev->dev_private; file_priv->file = file; INIT_LIST_HEAD(&file_priv->rps.link); spin_lock_init(&file_priv->mm.lock); INIT_LIST_HEAD(&file_priv->mm.request_list); file_priv->bsd_ring = -1; ret = i915_gem_context_open(dev, file); if (ret) kfree(file_priv); return ret; }
false
false
false
false
false
0
HTS_Model_add_parameter(HTS_Model * model, size_t state_index, const char *string, double *mean, double *vari, double *msd, double weight) { size_t i; size_t tree_index, pdf_index; size_t len = model->vector_length * model->num_windows; HTS_Model_get_index(model, state_index, string, &tree_index, &pdf_index); for (i = 0; i < len; i++) { mean[i] += weight * model->pdf[tree_index][pdf_index][i]; vari[i] += weight * model->pdf[tree_index][pdf_index][i + len]; } if (msd != NULL && model->is_msd == TRUE) *msd += weight * model->pdf[tree_index][pdf_index][len + len]; }
false
false
false
false
false
0
oc_index_name_cmp( const void *v_name, const void *v_oir ) { const struct berval *name = v_name; const struct oindexrec *oir = v_oir; int i = name->bv_len - oir->oir_name.bv_len; if (i) return i; return strncasecmp( name->bv_val, oir->oir_name.bv_val, name->bv_len ); }
false
false
false
false
false
0
find_rsb_nodir(struct dlm_ls *ls, char *name, int len, uint32_t hash, uint32_t b, int dir_nodeid, int from_nodeid, unsigned int flags, struct dlm_rsb **r_ret) { struct dlm_rsb *r = NULL; int our_nodeid = dlm_our_nodeid(); int recover = (flags & R_RECEIVE_RECOVER); int error; retry: error = pre_rsb_struct(ls); if (error < 0) goto out; spin_lock(&ls->ls_rsbtbl[b].lock); error = dlm_search_rsb_tree(&ls->ls_rsbtbl[b].keep, name, len, &r); if (error) goto do_toss; /* * rsb is active, so we can't check master_nodeid without lock_rsb. */ kref_get(&r->res_ref); goto out_unlock; do_toss: error = dlm_search_rsb_tree(&ls->ls_rsbtbl[b].toss, name, len, &r); if (error) goto do_new; /* * rsb found inactive. No other thread is using this rsb because * it's on the toss list, so we can look at or update * res_master_nodeid without lock_rsb. */ if (!recover && (r->res_master_nodeid != our_nodeid) && from_nodeid) { /* our rsb is not master, and another node has sent us a request; this should never happen */ log_error(ls, "find_rsb toss from_nodeid %d master %d dir %d", from_nodeid, r->res_master_nodeid, dir_nodeid); dlm_print_rsb(r); error = -ENOTBLK; goto out_unlock; } if (!recover && (r->res_master_nodeid != our_nodeid) && (dir_nodeid == our_nodeid)) { /* our rsb is not master, and we are dir; may as well fix it; this should never happen */ log_error(ls, "find_rsb toss our %d master %d dir %d", our_nodeid, r->res_master_nodeid, dir_nodeid); dlm_print_rsb(r); r->res_master_nodeid = our_nodeid; r->res_nodeid = 0; } rb_erase(&r->res_hashnode, &ls->ls_rsbtbl[b].toss); error = rsb_insert(r, &ls->ls_rsbtbl[b].keep); goto out_unlock; do_new: /* * rsb not found */ error = get_rsb_struct(ls, name, len, &r); if (error == -EAGAIN) { spin_unlock(&ls->ls_rsbtbl[b].lock); goto retry; } if (error) goto out_unlock; r->res_hash = hash; r->res_bucket = b; r->res_dir_nodeid = dir_nodeid; r->res_master_nodeid = dir_nodeid; r->res_nodeid = (dir_nodeid == our_nodeid) ? 0 : dir_nodeid; kref_init(&r->res_ref); error = rsb_insert(r, &ls->ls_rsbtbl[b].keep); out_unlock: spin_unlock(&ls->ls_rsbtbl[b].lock); out: *r_ret = r; return error; }
false
false
false
false
false
0
iw_add_segment(IndexWriter *iw, SegmentReader *sr) { SegmentInfo *si = sis_new_segment(iw->sis, 0, iw->store); FieldInfos *fis = iw->fis; FieldInfos *sub_fis = sr->ir.fis; int j; const int fis_size = sub_fis->size; bool must_map_fields = false; si->doc_cnt = IR(sr)->max_doc(IR(sr)); /* Merge FieldInfos */ for (j = 0; j < fis_size; j++) { FieldInfo *fi = sub_fis->fields[j]; FieldInfo *new_fi = fis_get_field(fis, fi->name); if (NULL == new_fi) { new_fi = fi_new(fi->name, 0, 0, 0); new_fi->bits = fi->bits; fis_add_field(fis, new_fi); } new_fi->bits |= fi->bits; if (fi->number != new_fi->number) { must_map_fields = true; } } if (must_map_fields) { iw_cp_map_files(iw, sr, si); } else { iw_cp_files(iw, sr, si); } }
false
false
false
false
false
0
arizona_identify_headphone(struct arizona_extcon_info *info) { struct arizona *arizona = info->arizona; int ret; if (info->hpdet_done) return; dev_dbg(arizona->dev, "Starting HPDET\n"); /* Make sure we keep the device enabled during the measurement */ pm_runtime_get(info->dev); info->hpdet_active = true; if (info->mic) arizona_stop_mic(info); arizona_extcon_hp_clamp(info, true); ret = regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1, ARIZONA_ACCDET_MODE_MASK, arizona->pdata.hpdet_channel); if (ret != 0) { dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret); goto err; } ret = regmap_update_bits(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1, ARIZONA_HP_POLL, ARIZONA_HP_POLL); if (ret != 0) { dev_err(arizona->dev, "Can't start HPDETL measurement: %d\n", ret); goto err; } return; err: regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1, ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC); /* Just report headphone */ ret = extcon_set_cable_state_(info->edev, EXTCON_JACK_HEADPHONE, true); if (ret != 0) dev_err(arizona->dev, "Failed to report headphone: %d\n", ret); if (info->mic) arizona_start_mic(info); info->hpdet_active = false; }
false
false
false
false
false
0
writeEntry(const QString& key, bool value) { setValue(key, value); }
false
false
false
false
false
0
pforward_pass(int midi, int t, int tl, int A, int B, int N, pwint * HH, pwint * DD) { int i, j; int s, f, g, h, hh, e; for (i = 1; i <= midi; i++) { s = HH[0]; HH[0] = hh = t = t + tl; f = t - open_penalty1(A + i, B + 1); for (j = 1; j <= N; j++) { g = open_penalty1(A + i, B + j); h = ext_penalty1(A + i, B + j); if ((hh = hh - g - h) > (f = f - h)) f = hh; g = open_penalty2(A + i, B + j); h = ext_penalty2(A + i, B + j); if ((hh = HH[j] - g - h) > (e = DD[j] - h)) e = hh; hh = s + prfscore(A + i, B + j); if (f > hh) hh = f; if (e > hh) hh = e; s = HH[j]; HH[j] = hh; DD[j] = e; } } return; }
false
false
false
false
false
0
sprint_realloc_null(u_char ** buf, size_t * buf_len, size_t * out_len, int allow_realloc, const netsnmp_variable_list * var, const struct enum_list *enums, const char *hint, const char *units) { if ((var->type != ASN_NULL) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { u_char str[] = "Wrong Type (should be NULL): "; if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { return sprint_realloc_by_type(buf, buf_len, out_len, allow_realloc, var, NULL, NULL, NULL); } else { return 0; } } else { u_char str[] = "NULL"; return snmp_strcat(buf, buf_len, out_len, allow_realloc, str); } }
false
false
false
false
false
0
insert_block(data_t *new_data) { static int next_block_spot = 0; if(BlocksInUse == MaxNumBlocks) { /* hit max, trigger garbage collection */ // gc_run_with_block(new_data); gc_run(); if(BlocksInUse == MaxNumBlocks) { printf("max number of blocks hit\n"); exit(1); } } /* find spot in block list to insert this */ do { if(BlockList[next_block_spot] == NULL) { BlockList[next_block_spot++] = new_data; next_block_spot %= MaxNumBlocks; break; } ++next_block_spot; next_block_spot %= MaxNumBlocks; } while(1); ++BlocksInUse; return true; }
false
true
false
false
false
1
RegisterSpaceGroup (int nb, ...) { if (m_HMName.length () > 0 && _SpaceGroups.sgbn[m_HMName] == NULL) _SpaceGroups.sgbn[m_HMName] = this; if (m_HallName.length () > 0 && _SpaceGroups.sgbn[m_HallName] == NULL) _SpaceGroups.sgbn[m_HallName] = this; if (nb == 0) return; va_list args; va_start (args, nb); string name; for (int i = 0; i < nb; i++) { name=va_arg (args, const char *); if (name.length () > 0 && _SpaceGroups.sgbn[name] == NULL) _SpaceGroups.sgbn[name] = this; } va_end (args); }
false
false
false
false
false
0
free_ref_list(struct ref_list *ref_list) { int i; for (i = 0; i < ref_list->index; i++) { free(ref_list->list[i].name); free(ref_list->list[i].dest); } free(ref_list->list); }
false
false
false
false
false
0
trio_isfinite TRIO_ARGS1((number), double number) { int dummy; switch (trio_fpclassify_and_signbit(number, &dummy)) { case TRIO_FP_INFINITE: case TRIO_FP_NAN: return 0; default: return 1; } }
false
false
false
false
false
0
GetYear(JSContext *cx, JSBool fullyear, jsval *vp) { jsdouble result; if (!GetAndCacheLocalTime(cx, JS_THIS_OBJECT(cx, vp), vp, &result)) return JS_FALSE; if (JSDOUBLE_IS_FINITE(result)) { result = YearFromTime(result); /* Follow ECMA-262 to the letter, contrary to IE JScript. */ if (!fullyear) result -= 1900; } return js_NewNumberInRootedValue(cx, result, vp); }
false
false
false
false
false
0
xsh_pfits_get_bias_right_stdev(cpl_propertylist * plist) { double returnvalue = 0; check_msg (xsh_get_property_value (plist, XSH_BIAS_RIGHT_STDEV, CPL_TYPE_DOUBLE,&returnvalue), "Error reading keyword '%s'", XSH_BIAS_RIGHT_STDEV); cleanup: return returnvalue; }
false
false
false
false
false
0
SizeGF_IPMPX_SendWatermark(GF_IPMPX_Data *_p) { u32 size; GF_IPMPX_SendWatermark *p = (GF_IPMPX_SendWatermark*)_p; size = 1; if (p->payload) size += GF_IPMPX_GetByteArraySize(p->payload); if (p->opaqueData) size += GF_IPMPX_GetByteArraySize(p->opaqueData); return size; }
false
false
false
false
false
0
update_view (void) { // in case there is no mailbox to update view from if (!mailbox_) return; // Insert the values of the options into the GUI widgets and update // widget status mailbox_->update_gui (OPTSGUI_UPDATE, OPTGRP_MAILBOX, gtkbuilder_, filename_); type_view (); }
false
false
false
false
false
0
processRunning(HttpConn *conn) { int canProceed; // MOB - refactor canProceed = 1; if (conn->connError) { httpSetState(conn, HTTP_STATE_COMPLETE); } else { if (conn->endpoint) { httpProcessPipeline(conn); if (conn->connError || conn->connectorComplete) { httpSetState(conn, HTTP_STATE_COMPLETE); } else { httpWritable(conn); canProceed = httpServiceQueues(conn); } } else { httpServiceQueues(conn); httpFinalize(conn); httpSetState(conn, HTTP_STATE_COMPLETE); } } return canProceed; }
false
false
false
false
false
0
getword(int c, char **token_r, gnc_t gnc, void *closure) { char buf[256]; int i = 0; c = skip_whitespace(c, gnc, closure); if(c < 0) return c; if(c == '"' || c == '\n') return -2; do { if(i >= 255) return -2; buf[i++] = c; c = gnc(closure); } while(c != ' ' && c != '\t' && c != '\n' && c >= 0); buf[i] = '\0'; *token_r = strdup(buf); return c; }
false
false
false
false
false
0
PR_LockFile(PRFileDesc *fd) { PRStatus status = PR_SUCCESS; if (pt_TestAbort()) return PR_FAILURE; PR_Lock(_pr_flock_lock); while (-1 == fd->secret->lockCount) PR_WaitCondVar(_pr_flock_cv, PR_INTERVAL_NO_TIMEOUT); if (0 == fd->secret->lockCount) { fd->secret->lockCount = -1; PR_Unlock(_pr_flock_lock); status = _PR_MD_LOCKFILE(fd->secret->md.osfd); PR_Lock(_pr_flock_lock); fd->secret->lockCount = (PR_SUCCESS == status) ? 1 : 0; PR_NotifyAllCondVar(_pr_flock_cv); } else { fd->secret->lockCount += 1; } PR_Unlock(_pr_flock_lock); return status; }
false
false
false
false
false
0
ntext_mdrag(GtkWidget *widget, GdkEventMotion *em, gpointer data) { NText *me = (NText *) data; TPoint c; int x,y; if (!em) return FALSE; if (!me->havesel) return FALSE; if (em->state & GDK_BUTTON1_MASK) { x = (int)(em->x); y = (int)(em->y); if (y > me->ch) { me->lineDown(1); return TRUE; } if (y < 0) { me->lineUp(1); return TRUE; } if (me->calcTP(c, x, y)) { me->B = c; me->scheduleRepaint(); } } return TRUE; }
false
false
false
false
false
0
JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim) { TRACE("JVM_NewMultiArray(env=%p, eltClass=%p, dim=%p)", env, eltClass, dim); if(eltClass == NULL || dim == NULL) { signalException(java_lang_NullPointerException, NULL); return NULL; } else { int i; char *array_name; intptr_t *dim_ptr; Object *array_class; int len = ARRAY_LEN((Class*)dim); int *dim_data = ARRAY_DATA((Class*)dim, int); ClassBlock *cb = CLASS_CB((Class*)eltClass); if(len == 0 || cb->dim + len > 255) { signalException(java_lang_IllegalArgumentException, NULL); return NULL; } if(IS_PRIMITIVE(cb)) { /* If the element is a primitive class, we need to convert from primitive class name to primitive char (e.g. "int" -> "I") */ static char type_name[] = {'Z', 'B', 'C', 'S', 'I', 'F', 'L', 'D'}; int type = getPrimTypeIndex(cb); if(type == PRIM_IDX_VOID) { signalException(java_lang_IllegalArgumentException, "cannot create a void array"); return NULL; } /* Construct primitive array name, e.g. "[[I" */ array_name = alloca(len + 2); array_name[len] = type_name[type - 1]; array_name[len + 1] = '\0'; } else { /* Construct object array name, e.g. "[[Ljava/lang/String;" */ int name_len = strlen(cb->name); if(IS_ARRAY(cb)) { array_name = alloca(len + name_len + 1); memcpy(array_name + len, cb->name, name_len); array_name[len + name_len] = '\0'; } else { array_name = alloca(len + name_len + 3); array_name[len] = 'L'; memcpy(array_name + len + 1, cb->name, name_len); array_name[len + name_len + 1] = ';'; array_name[len + name_len + 2] = '\0'; } } /* Add a [ for each dimension */ memset(array_name, '[', len); /* allocMultiArray expects dimensions to be an array of intptr_t. If int is the same size as a pointer, we can use the int array data "as is" otherwise we need to convert */ if(sizeof(int) != sizeof(intptr_t)) dim_ptr = alloca(sizeof(intptr_t) * len); else dim_ptr = (intptr_t*)dim_data; for(i = 0; i < len; i++) { if(dim_data[i] < 0) { signalException(java_lang_NegativeArraySizeException, NULL); return NULL; } /* Trivially optimised out if dim_pntr == dim_data */ dim_ptr[i] = dim_data[i]; } array_class = findArrayClassFromClass(array_name, (Class*)eltClass); if(array_class == NULL) return NULL; return allocMultiArray(array_class, len, dim_ptr); } }
false
true
false
false
false
1
set_version(int v) { if(v<1||v>40){ this->status|=QR_VERSIONINFO_INVALID; throw(0); } this->version=v; this->cells_par_side=this->version*4+17; return(this->version); }
false
false
false
false
false
0
kvm_cpu_accept_dm_intr(struct kvm_vcpu *vcpu) { return (!lapic_in_kernel(vcpu) || kvm_apic_accept_pic_intr(vcpu)); }
false
false
false
false
false
0
commit_path (gpointer key, gpointer value, gpointer user_data) { IBusInputPadConfig *config; const gchar *path = (const gchar *) key; SavedTable *saved_table = (SavedTable *) value; gchar *p; gchar *section; gchar *name; g_return_if_fail (key != NULL && value != NULL); g_return_if_fail (IBUS_IS_INPUT_PAD_CONFIG (user_data)); config = IBUS_INPUT_PAD_CONFIG (user_data); p = g_strrstr (path, "/"); g_return_if_fail (p != NULL && p > path); section = g_strndup (path, p - path); name = g_strdup (p + 1); if (saved_table->type == CONFIG_VALUE_TYPE_STRING) { ibus_input_pad_config_commit_str (config, section, name, saved_table->value.str); } else { ibus_input_pad_config_commit_int (config, section, name, saved_table->value.i); } }
false
false
false
false
false
0
init_eq_buf(struct mlx5_eq *eq) { struct mlx5_eqe *eqe; int i; for (i = 0; i < eq->nent; i++) { eqe = get_eqe(eq, i); eqe->owner = MLX5_EQE_OWNER_INIT_VAL; } }
false
false
false
false
false
0
defineHDF5LibraryException(int maj_num) { H5E_major_t err_num = (H5E_major_t) maj_num; if (H5E_ARGS == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5FunctionArgumentException"; else if (H5E_RESOURCE == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5ResourceUnavailableException"; else if (H5E_INTERNAL == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5InternalErrorException"; else if (H5E_FILE == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5FileInterfaceException"; else if (H5E_IO == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5LowLevelIOException"; else if (H5E_FUNC == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5FunctionEntryExitException"; else if (H5E_ATOM == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5AtomException"; else if (H5E_CACHE == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5MetaDataCacheException"; else if (H5E_BTREE == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5BtreeException"; else if (H5E_SYM == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5SymbolTableException"; else if (H5E_HEAP == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5HeapException"; else if (H5E_OHDR == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5ObjectHeaderException"; else if (H5E_DATATYPE == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5DatatypeInterfaceException"; else if (H5E_DATASPACE == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5DataspaceInterfaceException"; else if (H5E_DATASET == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5DatasetInterfaceException"; else if (H5E_STORAGE == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5DataStorageException"; else if (H5E_PLIST == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5PropertyListInterfaceException"; else if (H5E_ATTR == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5AttributeException"; else if (H5E_PLINE == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5DataFiltersException"; else if (H5E_EFL == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5ExternalFileListException"; else if (H5E_REFERENCE == err_num) return "ncsa/hdf/hdf5lib/exceptions/HDF5ReferenceException"; return "ncsa/hdf/hdf5lib/exceptions/HDF5LibraryException"; }
false
false
false
false
false
0
finish_profile(pTHX) { /* can be called after the perl interp is destroyed, via libcexit */ int saved_errno = errno; #ifdef MULTIPLICITY if (orig_my_perl && my_perl != orig_my_perl) if (trace_level) { logwarn("~ finish_profile call from different interpreter ignored\n"); return; } #endif if (trace_level >= 1) logwarn("~ finish_profile (overhead %gt, is_profiling %d)\n", cumulative_overhead_ticks, is_profiling); /* write data for final statement, unless DB_leave has already */ if (!profile_leave || opt_use_db_sub) DB_stmt(aTHX_ NULL, NULL); disable_profile(aTHX); close_output_file(aTHX); if (trace_level >= 2) { hash_stats(&fidhash, 0); hash_stats(&strhash, 0); } /* reset sub profiler data */ if (HvKEYS(sub_callers_hv)) { /* HvKEYS check avoids hv_clear() if interp has been destroyed RT#86548 */ hv_clear(sub_callers_hv); } /* reset other state */ cumulative_overhead_ticks = 0; cumulative_subr_ticks = 0; SETERRNO(saved_errno, 0); }
false
false
false
false
false
0
e_credentials_equal (const ECredentials *credentials1, const ECredentials *credentials2) { struct equal_data ed; if (!credentials1 && !credentials2) return TRUE; if (credentials1 == credentials2) return TRUE; if (!credentials1 || !credentials2) return FALSE; g_return_val_if_fail (credentials1->priv != NULL, FALSE); g_return_val_if_fail (credentials1->priv->keys != NULL, FALSE); g_return_val_if_fail (credentials2->priv != NULL, FALSE); g_return_val_if_fail (credentials2->priv->keys != NULL, FALSE); if (g_hash_table_size (credentials1->priv->keys) != g_hash_table_size (credentials2->priv->keys)) return FALSE; ed.equal = TRUE; ed.keys = credentials2->priv->keys; g_hash_table_foreach (credentials1->priv->keys, check_equal_cb, &ed); return ed.equal; }
false
false
false
false
false
0
gfs2_setattr_size(struct inode *inode, u64 newsize) { struct gfs2_inode *ip = GFS2_I(inode); int ret; u64 oldsize; BUG_ON(!S_ISREG(inode->i_mode)); ret = inode_newsize_ok(inode, newsize); if (ret) return ret; ret = get_write_access(inode); if (ret) return ret; inode_dio_wait(inode); ret = gfs2_rs_alloc(ip); if (ret) goto out; oldsize = inode->i_size; if (newsize >= oldsize) { ret = do_grow(inode, newsize); goto out; } gfs2_rs_deltree(ip->i_res); ret = do_shrink(inode, oldsize, newsize); out: put_write_access(inode); return ret; }
false
false
false
false
false
0
Perl_ck_repeat(pTHX_ OP *o) { PERL_ARGS_ASSERT_CK_REPEAT; if (cBINOPo->op_first->op_flags & OPf_PARENS) { o->op_private |= OPpREPEAT_DOLIST; cBINOPo->op_first = force_list(cBINOPo->op_first); } else scalar(o); return o; }
false
false
false
false
false
0
load_file( const char *path ) { gchar *file; struct stat s; void *data; int fd, r; g_assert( path != NULL ); fd = open( path, O_RDONLY ); if ( fd == -1 ) { g_error( "Can't open %s: %m", path ); return NULL; } r = fstat( fd, &s ); g_assert( r == 0 ); data = mmap( NULL, s.st_size, PROT_READ, MAP_SHARED, fd, 0 ); g_assert( data != MAP_FAILED ); file = g_strndup( data, s.st_size ); g_assert( file != NULL ); r = munmap( data, s.st_size ); g_assert( r == 0 ); r = close(fd); g_assert( r == 0 ); return file; }
false
false
false
false
false
0
go_font_ref (GOFont const *font) { g_return_val_if_fail (font != NULL, NULL); ((GOFont *)font)->ref_count++; ref_debug (g_warning ("ref added %p = %d", font, font->ref_count);); return font; }
false
false
false
false
false
0
scopedNameToDecl(const char* file, int line, const ScopedName* sn) { const Scope::Entry* se = Scope::current()->findScopedName(sn, file, line); if (se) { switch (se->kind()) { case Scope::Entry::E_MODULE: case Scope::Entry::E_DECL: case Scope::Entry::E_CALLABLE: case Scope::Entry::E_INHERITED: return se->decl(); default: { char* ssn = sn->toString(); IdlError(file, line, "'%s' is not a declaration", ssn); IdlErrorCont(se->file(), se->line(), "('%s' created here)", ssn); delete [] ssn; } } } return 0; }
false
false
false
false
false
0
lbs_set_mac_control_sync(struct lbs_private *priv) { struct cmd_ds_mac_control cmd; int ret = 0; lbs_deb_enter(LBS_DEB_CMD); cmd.hdr.size = cpu_to_le16(sizeof(cmd)); cmd.action = cpu_to_le16(priv->mac_control); cmd.reserved = 0; ret = lbs_cmd_with_response(priv, CMD_MAC_CONTROL, &cmd); lbs_deb_leave(LBS_DEB_CMD); return ret; }
false
false
false
false
false
0
channel_pos (int cycles) { const int *diag; if (cycles < 0) return 0; diag = get_ch (); if (cycles < diag[0]) return cycles; cycles -= diag[0]; cycles %= diag[0]; return cycles; }
false
false
false
false
false
0
menutils_Swap(StreamInteractor* S) { if(!S->menutils_CheckStackSize(2)) return; std::string a = S->popString(); std::string b = S->popString(); S->mystack->push(a); S->mystack->push(b); }
false
false
false
false
false
0
GetId(std::string username) { LoginDatabase.escape_string(username); QueryResult* result = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str()); if (!result) return 0; else { uint32 id = (*result)[0].GetUInt32(); delete result; return id; } }
false
false
false
false
false
0
hdf_num_attrs(NC *handle,/* IN: handle to SDS */ int32 vg /* IN: ref of top Vgroup */) { int count = 0; int t, n; int32 vs, tag; int32 id = -1; char class[H4_MAX_NC_CLASS] = ""; intn ret_value = FAIL; #ifdef HDF_NUM_ATTRS fprintf(stderr, "hdf_num_attrs: I've been called, handle->hdf_file = %d\n", handle->hdf_file); #endif n = Vntagrefs(vg); if (n == FAIL) { #ifdef HDF_NUM_ATTRS fprintf(stderr,"hdf_read_attrs: Vntagrefs failed \n"); #endif ret_value = FAIL; goto done; } #ifdef HDF_NUM_ATTRS fprintf(stderr,"hdf_num_attrs: Vntagrefs returned =%d \n",n); #endif /* * look through for a Vdata of class _HDF_ATTRIBUTE */ for (t = 0; t < n; t++) { if (Vgettagref(vg, t, &tag, &id) == FAIL) { ret_value = FAIL; goto done; } if(tag == DFTAG_VH) { vs = VSattach(handle->hdf_file, id, "r"); if(vs == FAIL) { ret_value = FAIL; goto done; } if (VSgetclass(vs, class) == FAIL) { ret_value = FAIL; goto done; } if(!HDstrcmp(class, _HDF_ATTRIBUTE)) count++; if (VSdetach(vs) == FAIL) { ret_value = FAIL; goto done; } } } #ifdef HDF_NUM_ATTRS fprintf(stderr, "hdf_num_attrs: number of attributes is %d \n", count); #endif ret_value = count; done: if (ret_value == FAIL) { /* Failure cleanup */ } /* Normal cleanup */ return ret_value; }
false
false
false
false
false
0
PyFFLayer_docompare(PyFF_Layer *self,PyObject *other, double pt_err, double spline_err) { SplineSet *ss, *ss2; int ret; SplinePoint *badpoint; ss = SSFromLayer(self); if ( PyType_IsSubtype(&PyFF_ContourType,((PyObject *)other)->ob_type) ) { ss2 = SSFromContour((PyFF_Contour *) other,NULL); } else if ( PyType_IsSubtype(&PyFF_LayerType,((PyObject *)other)->ob_type) ) { ss2 = SSFromLayer((PyFF_Layer *) other); } else { PyErr_Format(PyExc_TypeError, "Unexpected type"); return( -1 ); } ret = SSsCompare(ss,ss2,pt_err,spline_err,&badpoint); SplinePointListsFree(ss); SplinePointListsFree(ss2); return(ret); }
false
false
false
false
false
0
igorplugusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *udev; struct usb_host_interface *idesc; struct usb_endpoint_descriptor *ep; struct igorplugusb *ir; struct rc_dev *rc; int ret; udev = interface_to_usbdev(intf); idesc = intf->cur_altsetting; if (idesc->desc.bNumEndpoints != 1) { dev_err(&intf->dev, "incorrect number of endpoints"); return -ENODEV; } ep = &idesc->endpoint[0].desc; if (!usb_endpoint_dir_in(ep) || !usb_endpoint_xfer_control(ep)) { dev_err(&intf->dev, "endpoint incorrect"); return -ENODEV; } ir = devm_kzalloc(&intf->dev, sizeof(*ir), GFP_KERNEL); if (!ir) return -ENOMEM; ir->dev = &intf->dev; setup_timer(&ir->timer, igorplugusb_timer, (unsigned long)ir); ir->request.bRequest = GET_INFRACODE; ir->request.bRequestType = USB_TYPE_VENDOR | USB_DIR_IN; ir->request.wLength = cpu_to_le16(sizeof(ir->buf_in)); ir->urb = usb_alloc_urb(0, GFP_KERNEL); if (!ir->urb) return -ENOMEM; usb_fill_control_urb(ir->urb, udev, usb_rcvctrlpipe(udev, 0), (uint8_t *)&ir->request, ir->buf_in, sizeof(ir->buf_in), igorplugusb_callback, ir); usb_make_path(udev, ir->phys, sizeof(ir->phys)); rc = rc_allocate_device(); rc->input_name = DRIVER_DESC; rc->input_phys = ir->phys; usb_to_input_id(udev, &rc->input_id); rc->dev.parent = &intf->dev; rc->driver_type = RC_DRIVER_IR_RAW; /* * This device can only store 36 pulses + spaces, which is not enough * for the NEC protocol and many others. */ rc->allowed_protocols = RC_BIT_ALL & ~(RC_BIT_NEC | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SONY20 | RC_BIT_MCE_KBD | RC_BIT_SANYO); rc->priv = ir; rc->driver_name = DRIVER_NAME; rc->map_name = RC_MAP_HAUPPAUGE; rc->timeout = MS_TO_NS(100); rc->rx_resolution = 85333; ir->rc = rc; ret = rc_register_device(rc); if (ret) { dev_err(&intf->dev, "failed to register rc device: %d", ret); rc_free_device(rc); usb_free_urb(ir->urb); return ret; } usb_set_intfdata(intf, ir); igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY); return 0; }
false
false
false
false
false
0
isAxisymmetricElement(char* abq_name) { if ( LibFront::ncEqualPartial(abq_name, "CAX") || LibFront::ncEqualPartial(abq_name, "CGAX") || LibFront::ncEqualPartial(abq_name, "DCAX") ) return true; return false; }
false
false
false
false
false
0
make_ioa_addr(const u08bits* saddr, int port, ioa_addr *addr) { if(!saddr || !addr) return -1; ns_bzero(addr, sizeof(ioa_addr)); if((strlen((const s08bits*)saddr) == 0)|| (inet_pton(AF_INET, (const s08bits*)saddr, &addr->s4.sin_addr) == 1)) { addr->s4.sin_family = AF_INET; #if defined(TURN_HAS_SIN_LEN) /* tested when configured */ addr->s4.sin_len = sizeof(struct sockaddr_in); #endif addr->s4.sin_port = nswap16(port); } else if (inet_pton(AF_INET6, (const s08bits*)saddr, &addr->s6.sin6_addr) == 1) { addr->s6.sin6_family = AF_INET6; #if defined(SIN6_LEN) /* this define is required by IPv6 if used */ addr->s6.sin6_len = sizeof(struct sockaddr_in6); #endif addr->s6.sin6_port = nswap16(port); } else { struct addrinfo addr_hints; struct addrinfo *addr_result = NULL; int err; memset(&addr_hints, 0, sizeof(struct addrinfo)); addr_hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ addr_hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */ addr_hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */ addr_hints.ai_protocol = 0; /* Any protocol */ addr_hints.ai_canonname = NULL; addr_hints.ai_addr = NULL; addr_hints.ai_next = NULL; err = getaddrinfo((const char*)saddr, NULL, &addr_hints, &addr_result); if ((err != 0)||(!addr_result)) { fprintf(stderr,"error resolving '%s' hostname: %s\n",saddr,gai_strerror(err)); return -1; } int family = AF_INET; struct addrinfo *addr_result_orig = addr_result; int found = 0; beg_af: while(!found && addr_result) { if(addr_result->ai_family == family) { ns_bcopy(addr_result->ai_addr, addr, addr_result->ai_addrlen); if (addr_result->ai_family == AF_INET) { addr->s4.sin_port = nswap16(port); #if defined(TURN_HAS_SIN_LEN) /* tested when configured */ addr->s4.sin_len = sizeof(struct sockaddr_in); #endif } else if (addr_result->ai_family == AF_INET6) { addr->s6.sin6_port = nswap16(port); #if defined(SIN6_LEN) /* this define is required by IPv6 if used */ addr->s6.sin6_len = sizeof(struct sockaddr_in6); #endif } else { continue; } found = 1; } addr_result = addr_result->ai_next; } if(!found && family == AF_INET) { family = AF_INET6; addr_result = addr_result_orig; goto beg_af; } freeaddrinfo(addr_result_orig); } return 0; }
false
false
false
false
false
0
lua_user_input_string(lua_State *L) { const char *title = luaL_checkstring(L, 1); const char *default_str = luaL_optstring(L, 2, ""); const char *str = GetEditableStringInPopupWindow(100, title, default_str); if (!str) str = strdup(""); lua_pushstring(L, str); free((void *)str); return 1; }
false
false
false
false
false
0
optionsUpdate() { if(type_ == Group || type_ == Profile) { drawGroupIcon(); } else if(type_ == Contact) { if(!d->alerting) resetStatus(); else resetAnim(); } }
false
false
false
false
false
0
peas_plugin_loader_python_garbage_collect (PeasPluginLoader *loader) { PeasPluginLoaderPython *pyloader = PEAS_PLUGIN_LOADER_PYTHON (loader); /* * We both run the GC right now and we schedule * a further collection in the main loop. */ run_gc_protected (); if (pyloader->priv->idle_gc == 0) pyloader->priv->idle_gc = g_idle_add ((GSourceFunc) run_gc, pyloader); }
false
false
false
false
false
0
__declcnv_tostr(char *s, word32 *wp, int32 trimblen, int32 widnumlen) { register int32 chi; word32 *quot, *u, r0; int32 wlen; struct xstk_t *xsp; wlen = wlen_(trimblen); push_xstk_(xsp, wlen*WBITS/2); quot = xsp->ap; memset(quot, 0, wlen*WRDBYTES); push_xstk_(xsp, wlen*WBITS/2); u = xsp->ap; cp_walign_(u, wp, trimblen); s[widnumlen] = '\0'; /* repeatedly divide by 10 filling from end to front */ for (chi = widnumlen - 1;;) { __by16_ldivmod(quot, &r0, u, (word32) 10, trimblen); s[chi--] = (char) (r0 + '0'); if (vval_is0_(quot, trimblen)) break; if (chi < 0) __case_terr(__FILE__, __LINE__); /* know value shorter so retrim */ trimblen = __trim1_0val(quot, trimblen); cp_walign_(u, quot, trimblen); memset(quot, 0, wlen_(trimblen)*WRDBYTES); } for (; chi >= 0; chi--) s[chi] = ' '; __pop_xstk(); __pop_xstk(); }
false
false
false
false
true
1
operator()(double focal) const { Mat3 K; K << focal, 0, principal_point_(0), 0, focal, principal_point_(1), 0, 0, 1; Mat3 E; EssentialFromFundamental(F_, K, K, &E); Mat3 R; Vec3 t; MotionFromEssentialAndCorrespondence(E, K, x1_.col(0), K, x2_.col(0), &R, &t); vector<Mat34> Ps(2); P_From_KRt(K, Mat3::Identity(), Vec3::Zero(), &Ps[0]); P_From_KRt(K, R, t, &Ps[1]); double error = 0; for (int j = 0; j < x1_.cols(); ++j) { Vec4 X; Mat2X x(2,2); x.col(0) = x1_.col(j); x.col(1) = x2_.col(j); NViewTriangulate(x, Ps, &X); Vec3 x1_reproj = Ps[0] * X; Vec3 x2_reproj = Ps[1] * X; double threshold = 1.; double d1 = Depth(Mat3::Identity(), Vec3::Zero(), X); double d2 = Depth(R, t, X); if (d1 < 0 || d2 < 0) { error += 2 * Square(threshold); } else { error += std::min(Square(threshold), (x1_.col(j) - HomogeneousToEuclidean(x1_reproj)).squaredNorm()); error += std::min(Square(threshold), (x2_.col(j) - HomogeneousToEuclidean(x2_reproj)).squaredNorm()); } } return error; }
false
false
false
false
false
0
gap_story_selection_all_set(GapStoryBoard *stb, gboolean sel_state) { GapStoryElem *stb_elem; GapStorySection *section; if(stb == NULL) { return; } for(section = stb->stb_section; section != NULL; section = section->next) { for(stb_elem = section->stb_elem; stb_elem != NULL; stb_elem = stb_elem->next) { stb_elem->selected = sel_state; } } }
false
false
false
false
false
0
WriteImageInformation(void) { itkDebugMacro(<< "WriteImageInformation()"); // the IORegion is not required to be set so we must use GetNumberOfDimensions if ( this->GetNumberOfDimensions() != 2 ) { itkExceptionMacro( "JPEG2000ImageIO failed to write file: " << this->GetFileName() << std::endl << "Reason: " << "JPEG 2000 writer can only write 2-dimensional images" ); } if ( this->GetComponentType() != UCHAR && this->GetComponentType() != USHORT ) { itkExceptionMacro( "JPEG2000ImageIO failed to write file: " << this->GetFileName() << std::endl << "Reason: " << "JPEG 2000 writer only supports unsigned char/unsigned short int" ); } if ( this->GetNumberOfComponents() != 1 && this->GetNumberOfComponents() != 3 ) { itkExceptionMacro( "JPEG2000ImageIO failed to write file: " << this->GetFileName() << std::endl << "Reason: " << "JPEG 2000 writer only supports supports 1 or 3 components" ); } }
false
false
false
false
false
0
test_str_xor_normal() { string s1 = "hit the bull's eye"; string s2 = "the kid don't play"; string temp = ""; temp.push_back('\0'); string expected = "\x1c\x01\x11"; expected += temp; expected += "\x1f\x01\x01"; expected += temp; expected += "\x06\x1a\x02KSSP\t\x18\x1c"; string got = str_xor(s1, s2); if(expected.compare(got) != 0) { cout << "<<<String XOR Normal Functionality: FAIL>>>" << endl; cerr << "Got is: " << got << endl; return 0; } cout << "<<<String XOR Normal Functionality: PASS>>>" << endl; return 1; }
false
false
false
false
false
0
permissionsList(const char *pattern) { PQExpBufferData buf; PGresult *res; printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, true, false, false, false}; initPQExpBuffer(&buf); /* * we ignore indexes and toast tables since they have no meaningful rights */ printfPQExpBuffer(&buf, "SELECT n.nspname as \"%s\",\n" " c.relname as \"%s\",\n" " CASE c.relkind" " WHEN 'r' THEN '%s'" " WHEN 'v' THEN '%s'" " WHEN 'm' THEN '%s'" " WHEN 'S' THEN '%s'" " WHEN 'f' THEN '%s'" " END as \"%s\",\n" " ", gettext_noop("Schema"), gettext_noop("Name"), gettext_noop("table"), gettext_noop("view"), gettext_noop("materialized view"), gettext_noop("sequence"), gettext_noop("foreign table"), gettext_noop("Type")); printACLColumn(&buf, "c.relacl"); if (pset.sversion >= 80400) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT attname || E':\\n ' || pg_catalog.array_to_string(attacl, E'\\n ')\n" " FROM pg_catalog.pg_attribute a\n" " WHERE attrelid = c.oid AND NOT attisdropped AND attacl IS NOT NULL\n" " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); if (pset.sversion >= 90500) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" " || CASE WHEN polcmd != '*' THEN\n" " E' (' || polcmd || E'):'\n" " ELSE E':' \n" " END\n" " || CASE WHEN polqual IS NOT NULL THEN\n" " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" " ELSE E''\n" " END\n" " || CASE WHEN polwithcheck IS NOT NULL THEN\n" " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" " ELSE E''\n" " END" " || CASE WHEN polroles <> '{0}' THEN\n" " E'\\n to: ' || pg_catalog.array_to_string(\n" " ARRAY(\n" " SELECT rolname\n" " FROM pg_catalog.pg_roles\n" " WHERE oid = ANY (polroles)\n" " ORDER BY 1\n" " ), E', ')\n" " ELSE E''\n" " END\n" " FROM pg_catalog.pg_policy pol\n" " WHERE polrelid = c.oid), E'\\n')\n" " AS \"%s\"", gettext_noop("Policies")); appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" "WHERE c.relkind IN ('r', 'v', 'm', 'S', 'f')\n"); /* * Unless a schema pattern is specified, we suppress system and temp * tables, since they normally aren't very interesting from a permissions * point of view. You can see 'em by explicit request though, eg with \z * pg_catalog.* */ processSQLNamePattern(pset.db, &buf, pattern, true, false, "n.nspname", "c.relname", NULL, "n.nspname !~ '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)"); appendPQExpBufferStr(&buf, "ORDER BY 1, 2;"); res = PSQLexec(buf.data); if (!res) { termPQExpBuffer(&buf); return false; } myopt.nullPrint = NULL; printfPQExpBuffer(&buf, _("Access privileges")); myopt.title = buf.data; myopt.translate_header = true; myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); printQuery(res, &myopt, pset.queryFout, pset.logfile); termPQExpBuffer(&buf); PQclear(res); return true; }
false
false
false
false
false
0
lexer_InvokeMacro(Macro *m) { if(!m) return; if(verbose &4) cout << "Invoking macro: " << m->name() << endl; theMacroChain.push(m); m->prepareForInvocation(); int i=0; bool bValidParameter = false; do { i++; char s[256]; bValidParameter = getNextMacroParameter(s,sizeof(s)); if(bValidParameter) { m->add_parameter(s); if(verbose &4) cout << "macro param: " << s << endl; } } while (bValidParameter && i<m->nParameters()); m->invoke(); }
false
false
false
false
false
0
StartReplication(StartReplicationCmd *cmd) { StringInfoData buf; /* * Let postmaster know that we're streaming. Once we've declared us as a * WAL sender process, postmaster will let us outlive the bgwriter and * kill us last in the shutdown sequence, so we get a chance to stream all * remaining WAL at shutdown, including the shutdown checkpoint. Note that * there's no going back, and we mustn't write any WAL records after this. */ MarkPostmasterChildWalSender(); SendPostmasterSignal(PMSIGNAL_ADVANCE_STATE_MACHINE); /* * Check that we're logging enough information in the WAL for * log-shipping. * * NOTE: This only checks the current value of wal_level. Even if the * current setting is not 'minimal', there can be old WAL in the pg_xlog * directory that was created with 'minimal'. So this is not bulletproof, * the purpose is just to give a user-friendly error message that hints * how to configure the system correctly. */ if (wal_level == WAL_LEVEL_MINIMAL) ereport(FATAL, (errcode(ERRCODE_CANNOT_CONNECT_NOW), errmsg("standby connections not allowed because wal_level=minimal"))); /* * When we first start replication the standby will be behind the primary. * For some applications, for example, synchronous replication, it is * important to have a clear state for this initial catchup mode, so we * can trigger actions when we change streaming state later. We may stay * in this state for a long time, which is exactly why we want to be able * to monitor whether or not we are still here. */ WalSndSetState(WALSNDSTATE_CATCHUP); /* Send a CopyBothResponse message, and start streaming */ pq_beginmessage(&buf, 'W'); pq_sendbyte(&buf, 0); pq_sendint(&buf, 0, 2); pq_endmessage(&buf); pq_flush(); /* * Initialize position to the received one, then the xlog records begin to * be shipped from that position */ sentPtr = cmd->startpoint; }
false
false
false
false
false
0
write_ontologies_gvdb (gboolean overwrite, GError **error) { gchar *filename; filename = g_build_filename (g_get_user_cache_dir (), "tracker", "ontologies.gvdb", NULL); if (overwrite || !g_file_test (filename, G_FILE_TEST_EXISTS)) { tracker_ontologies_write_gvdb (filename, error); } g_free (filename); }
false
false
false
false
false
0
init_display(struct fbtft_par *par) { par->fbtftops.reset(par); write_reg(par, 0xEF, 0x03, 0x80, 0x02); write_reg(par, 0xCF, 0x00, 0XC1, 0X30); write_reg(par, 0xED, 0x64, 0x03, 0X12, 0X81); write_reg(par, 0xE8, 0x85, 0x00, 0x78); write_reg(par, 0xCB, 0x39, 0x2C, 0x00, 0x34, 0x02); write_reg(par, 0xF7, 0x20); write_reg(par, 0xEA, 0x00, 0x00); /* Power Control 1 */ write_reg(par, 0xC0, 0x23); /* Power Control 2 */ write_reg(par, 0xC1, 0x10); /* VCOM Control 1 */ write_reg(par, 0xC5, 0x3e, 0x28); /* VCOM Control 2 */ write_reg(par, 0xC7, 0x86); /* COLMOD: Pixel Format Set */ /* 16 bits/pixel */ write_reg(par, 0x3A, 0x55); /* Frame Rate Control */ /* Division ratio = fosc, Frame Rate = 79Hz */ write_reg(par, 0xB1, 0x00, 0x18); /* Display Function Control */ write_reg(par, 0xB6, 0x08, 0x82, 0x27); /* Gamma Function Disable */ write_reg(par, 0xF2, 0x00); /* Gamma curve selected */ write_reg(par, 0x26, 0x01); /* Positive Gamma Correction */ write_reg(par, 0xE0, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00); /* Negative Gamma Correction */ write_reg(par, 0xE1, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F); /* Sleep OUT */ write_reg(par, 0x11); mdelay(120); /* Display ON */ write_reg(par, 0x29); return 0; }
false
false
false
false
false
0
toString() const { return QString("Color [red: %1][green: %2][blue: %3][alpha: %4]").arg(mColor.red()).arg(green()).arg(blue()).arg(alpha()); }
false
false
false
false
false
0
oct_permute_dimensions(ap_manager_t* man, bool destructive, oct_t* a, ap_dimperm_t* permutation) { oct_internal_t* pr = oct_init_from_manager(man,AP_FUNID_ADD_DIMENSIONS,0); bound_t* m = a->closed ? a->closed : a->m; bound_t* mm; arg_assert(permutation->size==a->dim,return NULL;); if (!m) mm = NULL; else { /* check (only bounds, not injectivity) */ size_t i,j; for (i=0;i<a->dim;i++) arg_assert(permutation->dim[i]<a->dim,return NULL;); /* permuted copy */ mm = hmat_alloc(pr,a->dim); hmat_permute(mm,m,a->dim,a->dim,permutation->dim); } /* always exact, respects closure */ if (a->closed) return oct_set_mat(pr,a,NULL,mm,destructive); else return oct_set_mat(pr,a,mm,NULL,destructive); }
false
false
false
false
false
0
getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const { btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin); btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin); //avoid an illegal AABB when there are no children if (!m_children.size()) { localHalfExtents.setValue(0,0,0); localCenter.setValue(0,0,0); } localHalfExtents += btVector3(getMargin(),getMargin(),getMargin()); btMatrix3x3 abs_b = trans.getBasis().absolute(); btVector3 center = trans(localCenter); btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents), abs_b[1].dot(localHalfExtents), abs_b[2].dot(localHalfExtents)); aabbMin = center-extent; aabbMax = center+extent; }
false
false
false
false
false
0
insert(FXint *ptr,FXint op,FXint arg){ if(code){ memmove(ptr+2,ptr,sizeof(FXint)*(pc-ptr)); ptr[0]=op; ptr[1]=arg; } pc+=2; return ptr; }
false
false
false
false
false
0
gem2tos_color(int nbpl, int index) { switch(nbpl) { case 1: return ((unsigned int)index<1 ? index : 1); case 2: return ((unsigned int)index<4 ? gem2tos_2bpl[index] : 3); case 4: return ((unsigned int)index<16 ? gem2tos_4bpl[index] : 15); case 8: return ((unsigned int)index<16 ? gem2tos_4bpl[index] : (index<256 ? index : 255)); default: /* TrueColor mode, use 256 virtual pens */ return ((unsigned int)index<256 ? index : 255); } }
false
false
false
false
false
0
esl_hmm_Create(const ESL_ALPHABET *abc, int M) { ESL_HMM *hmm = NULL; int k,x; int status; ESL_ALLOC(hmm, sizeof(ESL_HMM)); hmm->t = NULL; hmm->e = NULL; ESL_ALLOC(hmm->t, sizeof(float *) * M); ESL_ALLOC(hmm->e, sizeof(float *) * M); ESL_ALLOC(hmm->eo, sizeof(float *) * abc->Kp); hmm->t[0] = NULL; hmm->e[0] = NULL; hmm->eo[0] = NULL; ESL_ALLOC(hmm->t[0], sizeof(float) * M * (M+1)); /* state M is the implicit end state */ ESL_ALLOC(hmm->e[0], sizeof(float) * M * abc->K); ESL_ALLOC(hmm->eo[0], sizeof(float) * abc->Kp * M); ESL_ALLOC(hmm->pi, sizeof(float) * (M+1)); /* initial transition to state M means a L=0 sequence */ for (k = 1; k < M; k++) { hmm->t[k] = hmm->t[0] + k*(M+1); hmm->e[k] = hmm->e[0] + k*abc->K; } for (x = 1; x < abc->Kp; x++) hmm->eo[x] = hmm->eo[0] + x*M; hmm->M = M; hmm->K = abc->K; hmm->abc = abc; return hmm; ERROR: esl_hmm_Destroy(hmm); return NULL; }
false
true
false
false
false
1
xmmsv_list_move (xmmsv_t *listv, int old_pos, int new_pos) { x_return_val_if_fail (listv, 0); x_return_val_if_fail (xmmsv_is_type (listv, XMMSV_TYPE_LIST), 0); return _xmmsv_list_move (listv->value.list, old_pos, new_pos); }
false
false
false
false
false
0
output_console_line(struct octeon_device *oct, struct octeon_console *console, size_t console_num, char *console_buffer, s32 bytes_read) { char *line; s32 i; line = console_buffer; for (i = 0; i < bytes_read; i++) { /* Output a line at a time, prefixed */ if (console_buffer[i] == '\n') { console_buffer[i] = '\0'; if (console->leftover[0]) { dev_info(&oct->pci_dev->dev, "%lu: %s%s\n", console_num, console->leftover, line); console->leftover[0] = '\0'; } else { dev_info(&oct->pci_dev->dev, "%lu: %s\n", console_num, line); } line = &console_buffer[i + 1]; } } /* Save off any leftovers */ if (line != &console_buffer[bytes_read]) { console_buffer[bytes_read] = '\0'; strcpy(console->leftover, line); } }
false
true
false
false
false
1
show_event(ivl_event_t net) { unsigned idx; fprintf(out, " event %s (%u pos, %u neg, %u any);\n", ivl_event_basename(net), ivl_event_npos(net), ivl_event_nneg(net), ivl_event_nany(net)); for (idx = 0 ; idx < ivl_event_nany(net) ; idx += 1) { ivl_nexus_t nex = ivl_event_any(net, idx); fprintf(out, " ANYEDGE: %p\n", nex); } for (idx = 0 ; idx < ivl_event_nneg(net) ; idx += 1) { ivl_nexus_t nex = ivl_event_neg(net, idx); fprintf(out, " NEGEDGE: %p\n", nex); } for (idx = 0 ; idx < ivl_event_npos(net) ; idx += 1) { ivl_nexus_t nex = ivl_event_pos(net, idx); fprintf(out, " POSEDGE: %p\n", nex); } }
false
false
false
false
false
0
WriteSourceFiles(int h, dprograms_t *progs, pbool sourceaswell) { includeddatafile_t *idf; qcc_cachedsourcefile_t *f; int num=0; int ofs; /* for (f = qcc_sourcefile; f ; f=f->next) { if (f->type == FT_CODE && !sourceaswell) continue; SafeWrite(h, f->filename, strlen(f->filename)+1); i = PRLittleLong(f->size); SafeWrite(h, &i, sizeof(int)); i = PRLittleLong(encrpytmode); SafeWrite(h, &i, sizeof(int)); if (encrpytmode) for (i = 0; i < f->size; i++) f->file[i] ^= 0xA5; SafeWrite(h, f->file, f->size); }*/ for (f = qcc_sourcefile,num=0; f ; f=f->next) { if (f->type == FT_CODE && !sourceaswell) continue; num++; } if (!num) return 0; idf = qccHunkAlloc(sizeof(includeddatafile_t)*num); for (f = qcc_sourcefile,num=0; f ; f=f->next) { if (f->type == FT_CODE && !sourceaswell) continue; strcpy(idf[num].filename, f->filename); idf[num].size = f->size; #ifdef AVAIL_ZLIB idf[num].compmethod = 2; #else idf[num].compmethod = 1; #endif idf[num].ofs = SafeSeek(h, 0, SEEK_CUR); idf[num].compsize = QC_encode(progfuncs, f->size, idf[num].compmethod, f->file, h); num++; } ofs = SafeSeek(h, 0, SEEK_CUR); SafeWrite(h, &num, sizeof(int)); SafeWrite(h, idf, sizeof(includeddatafile_t)*num); qcc_sourcefile = NULL; return ofs; }
false
true
false
false
false
1
pci_pos_write(cpu_gen_t *cpu,struct pci_device *dev, int reg,m_uint32_t value) { struct pos_oc3_data *d = dev->priv_data; #if DEBUG_ACCESS POS_LOG(d,"write 0x%x to PCI register 0x%x\n",value,reg); #endif switch(reg) { case PCI_REG_BAR0: vm_map_device(cpu->vm,&d->dev,(m_uint64_t)value); POS_LOG(d,"registers are mapped at 0x%x\n",value); break; } }
false
false
false
false
false
0
isAtomic() const { if (getType().isBool()) { return isBoolConst(); } if (validIsAtomicFlag()) { return getIsAtomicFlag(); } for (int k = 0; k < arity(); ++k) { if (!(*this)[k].isAtomic()) { setIsAtomicFlag(false); return false; } } setIsAtomicFlag(true); return true; }
false
false
false
false
false
0
speex_bits_peek_unsigned(SpeexBits *bits, int nbBits) { unsigned int d=0; int bitPtr, charPtr; char *chars; if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+nbBits>bits->nbBits) bits->overflow=1; if (bits->overflow) return 0; bitPtr=bits->bitPtr; charPtr=bits->charPtr; chars = bits->chars; while(nbBits) { d<<=1; d |= (chars[charPtr]>>(BITS_PER_CHAR-1 - bitPtr))&1; bitPtr++; if (bitPtr==BITS_PER_CHAR) { bitPtr=0; charPtr++; } nbBits--; } return d; }
false
false
false
false
false
0
AddMarkSet(int line, int valueSet) { if (line < 0 || line > LinesTotal()) { return; } unsigned int m = valueSet; for (int i = 0; m; i++, m >>= 1) if (m & 1) static_cast<LineMarkers *>(perLineData[ldMarkers])-> AddMark(line, i, LinesTotal()); DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); NotifyModified(mh); }
false
false
false
false
false
0
open_files(std::vector<std::string>& f) { for (unsigned int x = 0; x < f.size(); x++) { mdi.create_document(f[x]); } if (f.size() == 0) { mdi.create_document(); } present(); }
false
false
false
false
false
0
d_message(const int level, const char* ifmt, const char *msg) { char* fmt; if (debug < level) return; fprintf(stderr,"DEBUG: "); fmt = (char *)ifmt; if (!fmt) fmt = (char *)"%s\n"; fprintf(stderr, fmt, msg); fflush(stderr); }
false
false
false
false
false
0
ttusb2_frontend_tda10023_attach(struct dvb_usb_adapter *adap) { if (usb_set_interface(adap->dev->udev, 0, 3) < 0) err("set interface to alts=3 failed"); if (adap->fe_adap[0].fe == NULL) { /* FE 0 DVB-C */ adap->fe_adap[0].fe = dvb_attach(tda10023_attach, &tda10023_config, &adap->dev->i2c_adap, 0x48); if (adap->fe_adap[0].fe == NULL) { deb_info("TDA10023 attach failed\n"); return -ENODEV; } tt3650_ci_init(adap); } else { adap->fe_adap[1].fe = dvb_attach(tda10048_attach, &tda10048_config, &adap->dev->i2c_adap); if (adap->fe_adap[1].fe == NULL) { deb_info("TDA10048 attach failed\n"); return -ENODEV; } /* tuner is behind TDA10023 I2C-gate */ adap->fe_adap[1].fe->ops.i2c_gate_ctrl = ttusb2_ct3650_i2c_gate_ctrl; } return 0; }
false
false
false
false
false
0
get_request_uri () const { ACE::IOS::CString_OStream sos; if (!this->proxy_host_.empty ()) { sos << this->get_scheme ().c_str () << "://" << ACE::INet::URL_INetBase::get_host ().c_str (); if (ACE::INet::URL_INetBase::get_port () != HTTP_PORT) { sos << ':' << ACE::INet::URL_INetBase::get_port (); } } // if path is empty we're requesting the root sos << (this->get_path ().empty () ? "/" : this->get_path ().c_str ()); if (!this->get_query ().empty ()) sos << '?' << this->get_query ().c_str (); if (!this->get_fragment ().empty ()) sos << '#' << this->get_fragment ().c_str (); return sos.str (); }
false
false
false
false
false
0
__lambda15_ (Block4Data* _data4_, GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r) { AggregationTests * self; GeeSet* _tmp0_ = NULL; GeeSet* _tmp1_ = NULL; #line 630 "/home/treitter/collabora/folks/tests/folks/aggregation.vala" self = _data4_->self; #line 630 "/home/treitter/collabora/folks/tests/folks/aggregation.vala" g_return_if_fail (added != NULL); #line 630 "/home/treitter/collabora/folks/tests/folks/aggregation.vala" g_return_if_fail (removed != NULL); #line 632 "/home/treitter/collabora/folks/tests/folks/aggregation.vala" _tmp0_ = added; #line 632 "/home/treitter/collabora/folks/tests/folks/aggregation.vala" _tmp1_ = removed; #line 632 "/home/treitter/collabora/folks/tests/folks/aggregation.vala" _aggregation_tests_test_user_individuals_changed (self, FALSE, (GeeCollection*) _tmp0_, _tmp1_, &_data4_->user_individual); #line 3658 "aggregation.c" }
false
false
false
false
false
0
errorSymbol( EMSG_T *mesg, char *name, WORD32 col ) { char linecol[12]; char *s; if( pass == 2 ) { s = ( name == NULL ) ? "" : name ; errors++; sprintf( linecol, "(%d:%d)", lineno, col + 1 ); fprintf( errorfile, "%s%-9s : error: %s \"%s\" at Loc = %5.5o\n", filename, linecol, mesg->file, s, clc ); saveError( mesg->list, col ); } error_in_line = TRUE; }
false
false
false
false
false
0
ews_next_request (gpointer _cnc) { EEwsConnection *cnc = _cnc; GSList *l; EwsNode *node; QUEUE_LOCK (cnc); l = cnc->priv->jobs; if (!l || g_slist_length (cnc->priv->active_job_queue) >= EWS_CONNECTION_MAX_REQUESTS) { QUEUE_UNLOCK (cnc); return FALSE; } node = (EwsNode *) l->data; if (g_getenv ("EWS_DEBUG") && (atoi (g_getenv ("EWS_DEBUG")) == 1)) { soup_buffer_free (soup_message_body_flatten (SOUP_MESSAGE (node->msg)->request_body)); /* print request's body */ printf ("\n The request headers"); fputc ('\n', stdout); fputs (SOUP_MESSAGE (node->msg)->request_body->data, stdout); fputc ('\n', stdout); } /* Remove the node from the priority queue */ cnc->priv->jobs = g_slist_remove (cnc->priv->jobs, (gconstpointer *) node); /* Add to active job queue */ cnc->priv->active_job_queue = g_slist_append (cnc->priv->active_job_queue, node); if (cnc->priv->soup_session) { soup_session_queue_message (cnc->priv->soup_session, SOUP_MESSAGE (node->msg), ews_response_cb, node); QUEUE_UNLOCK (cnc); } else { QUEUE_UNLOCK (cnc); ews_cancel_request (NULL, node); } return FALSE; }
false
false
false
false
false
0
SetFITSUnsignedPixels(const size_t length, const size_t bits_per_pixel,unsigned char *pixels) { register ssize_t i; for (i=0; i < (ssize_t) length; i++) { *pixels^=0x80; pixels+=bits_per_pixel >> 3; } }
false
false
false
false
false
0
gwy_3d_label_user_size(Gwy3DLabel *label, gdouble user_size) { g_return_val_if_fail(GWY_IS_3D_LABEL(label), 0.0); if (label->fixed_size) return label->size; if (label->size != user_size) { label->size = user_size; g_object_notify(G_OBJECT(label), "size"); } return user_size; }
false
false
false
false
false
0