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
boundary_chk(const char *p, size_t l, void *ptr) { static size_t i, j; for (j=i=0; i<l; i++) { if (p[i] == '\n') { boundary_chk_add(p+j, i-j); if (boundary_chk_buflen >= boundary_chk_val_len+2 && boundary_chk_buf[0] == '-' && boundary_chk_buf[1] == '-' && strncasecmp(boundary_chk_val, boundary_chk_buf+2, boundary_chk_val_len) == 0) boundary_chk_flag=1; boundary_chk_buflen=0; j=i+1; } } boundary_chk_add(p+j, l-j); return (0); }
false
false
false
false
false
0
changeCoordinatesReference( const CPose3D &newReferenceBase ) { MRPT_START switch (m_typePDF) { case pdfMonteCarlo: m_locationMC.changeCoordinatesReference(newReferenceBase); break; case pdfGauss: m_locationGauss.changeCoordinatesReference(newReferenceBase); break; case pdfSOG: m_locationSOG.changeCoordinatesReference(newReferenceBase); break; default: THROW_EXCEPTION("ERROR: Invalid 'm_typePDF' value"); }; MRPT_END }
false
false
false
false
false
0
__ecereNameSpace__ecere__com___malloc(unsigned int size) { void * pointer; __ecereMethod___ecereNameSpace__ecere__sys__Mutex_Wait(__ecereNameSpace__ecere__com__memMutex); pointer = size ? __ecereNameSpace__ecere__com___mymalloc(size + 2 * 0) : (((void *)0)); __ecereMethod___ecereNameSpace__ecere__sys__Mutex_Release(__ecereNameSpace__ecere__com__memMutex); return pointer ? ((unsigned char *)pointer + 0) : (((void *)0)); }
false
false
false
false
false
0
scm_i_mask32 (scm_t_uint32 m) { return (m < 0x100 ? scm_masktab[m] : (m < 0x10000 ? scm_masktab[m >> 8] << 8 | 0xff : (m < 0x1000000 ? scm_masktab[m >> 16] << 16 | 0xffff : scm_masktab[m >> 24] << 24 | 0xffffff))); }
false
false
false
false
false
0
clutter_script_unmerge_objects (ClutterScript *script, guint merge_id) { ClutterScriptPrivate *priv; UnmergeData data; GSList *l; g_return_if_fail (CLUTTER_IS_SCRIPT (script)); g_return_if_fail (merge_id > 0); priv = script->priv; data.script = script; data.merge_id = merge_id; data.ids = NULL; g_hash_table_foreach (priv->objects, remove_by_merge_id, &data); for (l = data.ids; l != NULL; l = l->next) g_hash_table_remove (priv->objects, l->data); g_slist_foreach (data.ids, (GFunc) g_free, NULL); g_slist_free (data.ids); clutter_script_ensure_objects (script); }
false
false
false
false
false
0
efx_mcdi_get_phy_cfg(struct efx_nic *efx, struct efx_mcdi_phy_data *cfg) { MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_PHY_CFG_OUT_LEN); size_t outlen; int rc; BUILD_BUG_ON(MC_CMD_GET_PHY_CFG_IN_LEN != 0); BUILD_BUG_ON(MC_CMD_GET_PHY_CFG_OUT_NAME_LEN != sizeof(cfg->name)); rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_CFG, NULL, 0, outbuf, sizeof(outbuf), &outlen); if (rc) goto fail; if (outlen < MC_CMD_GET_PHY_CFG_OUT_LEN) { rc = -EIO; goto fail; } cfg->flags = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_FLAGS); cfg->type = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_TYPE); cfg->supported_cap = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_SUPPORTED_CAP); cfg->channel = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_CHANNEL); cfg->port = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_PRT); cfg->stats_mask = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_STATS_MASK); memcpy(cfg->name, MCDI_PTR(outbuf, GET_PHY_CFG_OUT_NAME), sizeof(cfg->name)); cfg->media = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_MEDIA_TYPE); cfg->mmd_mask = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_MMD_MASK); memcpy(cfg->revision, MCDI_PTR(outbuf, GET_PHY_CFG_OUT_REVISION), sizeof(cfg->revision)); return 0; fail: netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); return rc; }
false
false
false
false
false
0
is_double_delim_escaped(const char* cur, const char* end) { return ((cur + 1) < end) && *(cur+1) == *cur; }
false
false
false
false
false
0
describe_origin(textblock *tb, const object_type *o_ptr) { char origin_text[80]; if (o_ptr->origin_depth) strnfmt(origin_text, sizeof(origin_text), "%d feet (level %d)", o_ptr->origin_depth * 50, o_ptr->origin_depth); else my_strcpy(origin_text, "town", sizeof(origin_text)); switch (o_ptr->origin) { case ORIGIN_NONE: case ORIGIN_MIXED: case ORIGIN_STOLEN: return FALSE; case ORIGIN_BIRTH: textblock_append(tb, "An inheritance from your family.\n"); break; case ORIGIN_STORE: textblock_append(tb, "Bought from a store.\n"); break; case ORIGIN_FLOOR: textblock_append(tb, "Found lying on the floor %s %s.\n", (o_ptr->origin_depth ? "at" : "in"), origin_text); break; case ORIGIN_PIT: textblock_append(tb, "Found lying on the floor in a pit at %s.\n", origin_text); break; case ORIGIN_VAULT: textblock_append(tb, "Found lying on the floor in a vault at %s.\n", origin_text); break; case ORIGIN_SPECIAL: textblock_append(tb, "Found lying on the floor of a special room at %s.\n", origin_text); break; case ORIGIN_LABYRINTH: textblock_append(tb, "Found lying on the floor of a labyrinth at %s.\n", origin_text); break; case ORIGIN_CAVERN: textblock_append(tb, "Found lying on the floor of a cavern at %s.\n", origin_text); break; case ORIGIN_RUBBLE: textblock_append(tb, "Found under some rubble at %s.\n", origin_text); break; case ORIGIN_DROP: case ORIGIN_DROP_SPECIAL: case ORIGIN_DROP_PIT: case ORIGIN_DROP_VAULT: case ORIGIN_DROP_SUMMON: case ORIGIN_DROP_BREED: case ORIGIN_DROP_POLY: case ORIGIN_DROP_WIZARD: { const char *name; if (r_info[o_ptr->origin_xtra].ridx) name = r_info[o_ptr->origin_xtra].name; else name = "monster lost to history"; textblock_append(tb, "Dropped by "); if (rf_has(r_info[o_ptr->origin_xtra].flags, RF_UNIQUE)) textblock_append(tb, "%s", name); else textblock_append(tb, "%s%s", is_a_vowel(name[0]) ? "an " : "a ", name); textblock_append(tb, " %s %s.\n", (o_ptr->origin_depth ? "at" : "in"), origin_text); break; } case ORIGIN_DROP_UNKNOWN: textblock_append(tb, "Dropped by an unknown monster %s %s.\n", (o_ptr->origin_depth ? "at" : "in"), origin_text); break; case ORIGIN_ACQUIRE: textblock_append(tb, "Conjured forth by magic %s %s.\n", (o_ptr->origin_depth ? "at" : "in"), origin_text); break; case ORIGIN_CHEAT: textblock_append(tb, "Created by debug option.\n"); break; case ORIGIN_CHEST: textblock_append(tb, "Found in a chest from %s.\n", origin_text); break; } textblock_append(tb, "\n"); return TRUE; }
true
true
false
false
false
1
append_mapping(const char *name, const char *driver, const char *database, const char *table, int priority) { struct ast_config_map *map; char *dst; int length; length = sizeof(*map); length += strlen(name) + 1; length += strlen(driver) + 1; length += strlen(database) + 1; if (table) length += strlen(table) + 1; if (!(map = ast_calloc(1, length))) return -1; dst = map->stuff; /* writable space starts here */ map->name = strcpy(dst, name); dst += strlen(dst) + 1; map->driver = strcpy(dst, driver); dst += strlen(dst) + 1; map->database = strcpy(dst, database); if (table) { dst += strlen(dst) + 1; map->table = strcpy(dst, table); } map->priority = priority; map->next = config_maps; config_maps = map; ast_verb(2, "Binding %s to %s/%s/%s\n", map->name, map->driver, map->database, map->table ? map->table : map->name); return 0; }
false
false
false
false
false
0
gearman_job_reducer_string(const gearman_job_st *job) { if (job) { if (job->assigned.command == GEARMAN_COMMAND_JOB_ASSIGN_ALL and job->assigned.arg_size[3] > 1) { gearman_string_t temp= { job->assigned.arg[3], job->assigned.arg_size[3] -1 }; return temp; } static gearman_string_t null_temp= { gearman_literal_param("") }; return null_temp; } static gearman_string_t ret= {0, 0}; return ret; }
false
false
false
false
false
0
i5000_process_fatal_error_info(struct mem_ctl_info *mci, struct i5000_error_info *info, int handle_errors) { char msg[EDAC_MC_LABEL_LEN + 1 + 160]; char *specific = NULL; u32 allErrors; int channel; int bank; int rank; int rdwr; int ras, cas; /* mask off the Error bits that are possible */ allErrors = (info->ferr_fat_fbd & FERR_FAT_MASK); if (!allErrors) return; /* if no error, return now */ channel = EXTRACT_FBDCHAN_INDX(info->ferr_fat_fbd); /* Use the NON-Recoverable macros to extract data */ bank = NREC_BANK(info->nrecmema); rank = NREC_RANK(info->nrecmema); rdwr = NREC_RDWR(info->nrecmema); ras = NREC_RAS(info->nrecmemb); cas = NREC_CAS(info->nrecmemb); edac_dbg(0, "\t\tCSROW= %d Channel= %d (DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n", rank, channel, bank, rdwr ? "Write" : "Read", ras, cas); /* Only 1 bit will be on */ switch (allErrors) { case FERR_FAT_M1ERR: specific = "Alert on non-redundant retry or fast " "reset timeout"; break; case FERR_FAT_M2ERR: specific = "Northbound CRC error on non-redundant " "retry"; break; case FERR_FAT_M3ERR: { static int done; /* * This error is generated to inform that the intelligent * throttling is disabled and the temperature passed the * specified middle point. Since this is something the BIOS * should take care of, we'll warn only once to avoid * worthlessly flooding the log. */ if (done) return; done++; specific = ">Tmid Thermal event with intelligent " "throttling disabled"; } break; } /* Form out message */ snprintf(msg, sizeof(msg), "Bank=%d RAS=%d CAS=%d FATAL Err=0x%x (%s)", bank, ras, cas, allErrors, specific); /* Call the helper to output message */ edac_mc_handle_error(HW_EVENT_ERR_FATAL, mci, 1, 0, 0, 0, channel >> 1, channel & 1, rank, rdwr ? "Write error" : "Read error", msg); }
false
false
false
false
false
0
read_sor_desc(FILE *f) #else read_sor_desc(f) FILE *f; #endif { AST *root = NULL; zzline = 1; ANTLR(sordesc(&root), f); if ( found_error ) return NULL; if ( print_guts ) { fprintf(stderr, "Internal Represenation of Tree Grammar:\n"); lisp(root, stderr); fprintf(stderr, "\n"); } last_valid_token = token_type; end_of_input = token_type++;/* end of input token type is 1 + last real token */ epsilon = token_type++; /* epsilon token type is 2 + last real token */ wild_card = token_type++; /* wild_card_token is 3 + last real token */ token_association(end_of_input, "$"); token_association(epsilon, "[Ep]"); token_association(wild_card, "."); zzdouble_link(root, NULL, NULL); rules = root; if ( root!=NULL ) build_GLA(root); if ( print_guts ) { fprintf(stderr, "Internal Represenation of Grammar Lookahead Automaton:\n"); dump_GLAs(root); fprintf(stderr, "\n"); } return root; }
false
false
false
false
false
0
resource_tree_create (MonoArray *win32_resources) { ResTreeNode *tree, *res_node, *type_node, *lang_node; GSList *l; int i; tree = g_new0 (ResTreeNode, 1); for (i = 0; i < mono_array_length (win32_resources); ++i) { MonoReflectionWin32Resource *win32_res = (MonoReflectionWin32Resource*)mono_array_addr (win32_resources, MonoReflectionWin32Resource, i); /* Create node */ /* FIXME: BUG: this stores managed references in unmanaged memory */ lang_node = g_new0 (ResTreeNode, 1); lang_node->id = win32_res->lang_id; lang_node->win32_res = win32_res; /* Create type node if neccesary */ type_node = NULL; for (l = tree->children; l; l = l->next) if (((ResTreeNode*)(l->data))->id == win32_res->res_type) { type_node = (ResTreeNode*)l->data; break; } if (!type_node) { type_node = g_new0 (ResTreeNode, 1); type_node->id = win32_res->res_type; /* * The resource types have to be sorted otherwise * Windows Explorer can't display the version information. */ tree->children = g_slist_insert_sorted (tree->children, type_node, resource_tree_compare_by_id); } /* Create res node if neccesary */ res_node = NULL; for (l = type_node->children; l; l = l->next) if (((ResTreeNode*)(l->data))->id == win32_res->res_id) { res_node = (ResTreeNode*)l->data; break; } if (!res_node) { res_node = g_new0 (ResTreeNode, 1); res_node->id = win32_res->res_id; type_node->children = g_slist_append (type_node->children, res_node); } res_node->children = g_slist_append (res_node->children, lang_node); } return tree; }
false
false
false
false
false
0
menu_init (win_struct *win) { menu = gtk_menu_new(); command_menu_struct command; gint i; GtkWidget *title = gtk_menu_item_new_with_label(" AllTray"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), title); gtk_widget_set_sensitive(title, FALSE); GtkWidget *separator1 = gtk_menu_item_new(); gtk_widget_show(separator1); gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator1); if (debug) printf ("command_menu->len: %d\n", win->command_menu->len); if (win->command_menu->len >0) { for (i=0; i < win->command_menu->len; i++) { command=g_array_index (win->command_menu, command_menu_struct, i); if (debug) printf ("found command.entry: %s\n", command.entry); GtkWidget *item = gtk_menu_item_new_with_label(command.entry); g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(command_menu_call), (gpointer) command.command); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); } GtkWidget *separator2 = gtk_menu_item_new(); gtk_widget_show(separator2); gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator2); gtk_widget_set_sensitive(separator2, FALSE); } show_item = gtk_menu_item_new_with_label("Show/Hide"); g_signal_connect(G_OBJECT(show_item), "activate", G_CALLBACK(show_hide_call), (gpointer) win); gtk_menu_shell_append(GTK_MENU_SHELL(menu), show_item); GtkWidget *separator4 = gtk_menu_item_new(); gtk_widget_show(separator4); gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator4); gtk_widget_set_sensitive(separator4, FALSE); undock_item = gtk_menu_item_new_with_label("Undock"); g_signal_connect(G_OBJECT(undock_item), "activate", G_CALLBACK(undock_call), (gpointer) win); gtk_menu_shell_append(GTK_MENU_SHELL(menu), undock_item); GtkWidget *separator3 = gtk_menu_item_new(); gtk_widget_show(separator3); gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator3); gtk_widget_set_sensitive(separator3, FALSE); exit_item = gtk_menu_item_new_with_label("Exit"); g_signal_connect(G_OBJECT(exit_item), "activate", G_CALLBACK(exit_call), (gpointer) win); gtk_menu_shell_append(GTK_MENU_SHELL(menu), exit_item); gtk_widget_show_all(menu); }
false
false
false
false
false
0
fdisk_sun_set_xcyl(struct fdisk_context *cxt) { struct sun_disklabel *sunlabel = self_disklabel(cxt); uintmax_t res; int rc = fdisk_ask_number(cxt, 0, /* low */ be16_to_cpu(sunlabel->apc), /* default */ cxt->geom.sectors, /* high */ _("Extra sectors per cylinder"), /* query */ &res); /* result */ if (rc) return rc; sunlabel->apc = cpu_to_be16(res); return 0; }
false
false
false
false
false
0
choiceType() const { FormWidgetChoice* fwc = static_cast<FormWidgetChoice*>(m_formData->fm); if (fwc->isCombo()) return FormFieldChoice::ComboBox; return FormFieldChoice::ListBox; }
false
false
false
false
false
0
vcc_NumVal(struct vcc *tl, double *d, int *frac) { double e = 0.1; const char *p; *frac = 0; *d = 0.0; Expect(tl, CNUM); if (tl->err) { *d = NAN; return; } for (p = tl->t->b; p < tl->t->e; p++) { *d *= 10; *d += *p - '0'; } vcc_NextToken(tl); if (tl->t->tok != '.') return; *frac = 1; vcc_NextToken(tl); if (tl->t->tok != CNUM) return; for (p = tl->t->b; p < tl->t->e; p++) { *d += (*p - '0') * e; e *= 0.1; } vcc_NextToken(tl); }
false
false
false
false
false
0
makeRandomFilename(const char* sourceName) { int sourceNameLen; char* newName; char randomStr[RANDOM_STR_NAME_LEN]; int numRandomCharsFilled; if(strlen(sourceName) > MAX_RANDOM_BASE_NAME_LEN) sourceNameLen = MAX_RANDOM_BASE_NAME_LEN; else sourceNameLen = strlen(sourceName); newName = malloc(sourceNameLen + RANDOM_STR_NAME_LEN + 2); if(newName == NULL) fatalError("newName = malloc(sourceNameLen + RANDOM_STR_NAME_LEN + 2) failed\n"); numRandomCharsFilled = 0; while(numRandomCharsFilled < RANDOM_STR_NAME_LEN) { char oneRandomChar; bool gotGoodChar; gotGoodChar = false; while(!gotGoodChar) { oneRandomChar = random(); if(64 < oneRandomChar && oneRandomChar < 91) { gotGoodChar = true; } } randomStr[numRandomCharsFilled] = oneRandomChar; numRandomCharsFilled++; } strncpy(newName, randomStr, RANDOM_STR_NAME_LEN); newName[RANDOM_STR_NAME_LEN] = '\0'; strcat(newName, "-"); strncat(newName, sourceName, sourceNameLen); newName[RANDOM_STR_NAME_LEN + sourceNameLen + 1] = '\0'; return newName; }
false
false
false
false
false
0
close_file(fdtype fd, const char* logkey) { int res = closefile(fd); if (res) { perror("close file"); ERR("%s: Errors on closing file, after write, could indicate write back cache problems, especially under NFS. Ignoring the error. euid=%d egid=%d", logkey, geteuid(), getegid()); } return res; }
false
false
false
false
false
0
encodeUndefined() { // GNASH_REPORT_FUNCTION; boost::shared_ptr<Buffer> buf(new Buffer(1)); *buf = Element::UNDEFINED_AMF0; return buf; }
false
false
false
false
false
0
convert_double_u32_scaled (double min_val, double max_val, uint32_t min, uint32_t max, char *src, char *dst, int src_pitch, int dst_pitch, long n) { while (n--) { double dval = *(double *) src; uint32_t u32val; if (dval < min_val) u32val = min; else if (dval > max_val) u32val = max; else u32val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); *(uint32_t *) dst = u32val; dst += dst_pitch; src += src_pitch; } return n; }
false
false
false
false
false
0
mb862xx_pci_remove(struct pci_dev *pdev) { struct fb_info *fbi = pci_get_drvdata(pdev); struct mb862xxfb_par *par = fbi->par; unsigned long reg; dev_dbg(fbi->dev, "%s release\n", fbi->fix.id); /* display off */ reg = inreg(disp, GC_DCM1); reg &= ~(GC_DCM01_DEN | GC_DCM01_L0E); outreg(disp, GC_DCM1, reg); if (par->type == BT_CARMINE) { outreg(ctrl, GC_CTRL_INT_MASK, 0); outreg(ctrl, GC_CTRL_CLK_ENABLE, 0); } else { outreg(host, GC_IMASK, 0); } mb862xx_i2c_exit(par); device_remove_file(&pdev->dev, &dev_attr_dispregs); unregister_framebuffer(fbi); fb_dealloc_cmap(&fbi->cmap); free_irq(par->irq, (void *)par); iounmap(par->mmio_base); iounmap(par->fb_base); pci_release_regions(pdev); framebuffer_release(fbi); pci_disable_device(pdev); }
false
false
false
false
false
0
put_composewindow_into_module(Compose *compose) { PyObject *pycompose; pycompose = clawsmail_compose_new(cm_module, compose); PyObject_SetAttrString(cm_module, "compose_window", pycompose); Py_DECREF(pycompose); }
false
false
false
false
false
0
my_wc_mb_utf8mb4(CHARSET_INFO *cs __attribute__((unused)), my_wc_t wc, uchar *r, uchar *e) { int count; if (r >= e) return MY_CS_TOOSMALL; if (wc < 0x80) count= 1; else if (wc < 0x800) count= 2; else if (wc < 0x10000) count= 3; else if (wc < 0x200000) count= 4; else return MY_CS_ILUNI; if (r + count > e) return MY_CS_TOOSMALLN(count); switch (count) { /* Fall through all cases!!! */ case 4: r[3] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x10000; case 3: r[2] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x800; case 2: r[1] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0xc0; case 1: r[0] = (uchar) wc; } return count; }
false
false
false
false
false
0
internal_buildAuxPointsMap( const void *options ) const { if (!ptr_internal_build_points_map_from_scan2D) throw std::runtime_error("[CSensoryFrame::buildAuxPointsMap] ERROR: This function needs linking against mrpt-maps.\n"); for (const_iterator it = begin();it!=end();++it) if (IS_CLASS(*it,CObservation2DRangeScan)) (*ptr_internal_build_points_map_from_scan2D)( *((CObservation2DRangeScan*)it->pointer()),m_cachedMap, options); }
false
false
false
false
false
0
gtk_link_init (GtkLink *link) { GTK_WIDGET_SET_FLAGS(link, GTK_NO_WINDOW); link->x1 = -1; link->x2 = -1; link->y1 = -1; link->y2 = -1; link->xos=0; link->yos=0; }
false
false
false
false
false
0
mix3to1 (sample_t * samples, sample_t bias) { int i; for (i = 0; i < 256; i++) samples[i] += BIAS (samples[i + 256] + samples[i + 512]); }
false
false
false
false
false
0
OnViewMenuUpdateUI(wxUpdateUIEvent& event) { if (Manager::IsAppShuttingDown()) { event.Skip(); return; } wxMenuBar* mbar = GetMenuBar(); cbEditor* ed = Manager::Get()->GetEditorManager() ? Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor() : nullptr; bool manVis = m_LayoutManager.GetPane(m_pPrjManUI->GetNotebook()).IsShown(); mbar->Check(idViewManager, manVis); mbar->Check(idViewLogManager, m_LayoutManager.GetPane(m_pInfoPane).IsShown()); mbar->Check(idViewStartPage, Manager::Get()->GetEditorManager()->GetEditor(g_StartHereTitle)!=NULL); mbar->Check(idViewStatusbar, GetStatusBar() && GetStatusBar()->IsShown()); mbar->Check(idViewScriptConsole, m_LayoutManager.GetPane(m_pScriptConsole).IsShown()); mbar->Check(idViewHideEditorTabs, Manager::Get()->GetEditorManager()->GetNotebook()->GetTabCtrlHeight() == 0); mbar->Check(idViewFullScreen, IsFullScreen()); mbar->Enable(idViewFocusEditor, ed); mbar->Enable(idViewFocusManagement, manVis); mbar->Enable(idViewFocusLogsAndOthers, m_pInfoPane->IsShown()); // toolbars mbar->Check(idViewToolMain, m_LayoutManager.GetPane(m_pToolbar).IsShown()); mbar->Check(idViewToolDebugger, m_LayoutManager.GetPane(m_debuggerToolbarHandler->GetToolbar(false)).IsShown()); wxMenu* viewToolbars = nullptr; GetMenuBar()->FindItem(idViewToolMain, &viewToolbars); if (viewToolbars) { for (size_t i = 0; i < viewToolbars->GetMenuItemCount(); ++i) { wxMenuItem* item = viewToolbars->GetMenuItems()[i]; wxString pluginName = m_PluginIDsMap[item->GetId()]; if (!pluginName.IsEmpty()) { cbPlugin* plugin = Manager::Get()->GetPluginManager()->FindPluginByName(pluginName); if (plugin) item->Check(m_LayoutManager.GetPane(m_PluginsTools[plugin]).IsShown()); } } } event.Skip(); }
false
false
false
false
false
0
acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev, void (*work_func)(struct work_struct *work)) { acpi_status status = AE_ALREADY_EXISTS; if (!dev && !work_func) return AE_BAD_PARAMETER; mutex_lock(&acpi_pm_notifier_lock); if (adev->wakeup.flags.notifier_present) goto out; adev->wakeup.ws = wakeup_source_register(dev_name(&adev->dev)); adev->wakeup.context.dev = dev; if (work_func) INIT_WORK(&adev->wakeup.context.work, work_func); status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY, acpi_pm_notify_handler, NULL); if (ACPI_FAILURE(status)) goto out; adev->wakeup.flags.notifier_present = true; out: mutex_unlock(&acpi_pm_notifier_lock); return status; }
false
false
false
false
false
0
_elm_access_object_hilight(Evas_Object *obj) { Evas_Object *o; Evas_Coord x, y, w, h; o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp"); if (!o) { o = edje_object_add(evas_object_evas_get(obj)); evas_object_name_set(o, "_elm_access_disp"); evas_object_layer_set(o, ELM_OBJECT_LAYER_TOOLTIP); } else { Evas_Object *ptarget = evas_object_data_get(o, "_elm_access_target"); if (ptarget) { evas_object_data_del(o, "_elm_access_target"); evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_DEL, _access_obj_hilight_del_cb, NULL); evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_HIDE, _access_obj_hilight_hide_cb, NULL); evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_MOVE, _access_obj_hilight_move_cb, NULL); evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_RESIZE, _access_obj_hilight_resize_cb, NULL); } } evas_object_data_set(o, "_elm_access_target", obj); _elm_theme_object_set(obj, o, "access", "base", "default"); evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _access_obj_hilight_del_cb, NULL); evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _access_obj_hilight_hide_cb, NULL); evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _access_obj_hilight_move_cb, NULL); evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _access_obj_hilight_resize_cb, NULL); evas_object_raise(o); evas_object_geometry_get(obj, &x, &y, &w, &h); evas_object_move(o, x, y); evas_object_resize(o, w, h); evas_object_show(o); }
false
false
false
false
false
0
filePrint() { QPrinter printer; bool ok; QPrintDialog *printDialog = KdePrint::createPrintDialog(&printer, this); printDialog->setWindowTitle(i18n("Print %1", actionCollection()->action(playGround->currentGameboard())->iconText())); ok = printDialog->exec(); delete printDialog; if (!ok) return; playGround->repaint(); if (!playGround->printPicture(printer)) KMessageBox::error(this, i18n("Could not print picture.")); else KMessageBox::information(this, i18n("Picture successfully printed.")); }
false
false
false
false
false
0
getString(unsigned int i) { GLERC<GLEString> result; GLEMemoryCell* cell = &m_Data[i]; if (cell->Type == GLE_MC_OBJECT && cell->Entry.ObjectVal->getType() == GLEObjectTypeString) { result = static_cast<GLEString*>(cell->Entry.ObjectVal); } else { ostringstream out; gle_memory_cell_print(cell, out); result = new GLEString(out.str()); } return result; }
false
false
false
false
false
0
_isStyleInTOC(UT_UTF8String & sStyle, UT_UTF8String & sTOCStyle) { UT_UTF8String sTmpStyle = sStyle; const char * sLStyle = sTOCStyle.utf8_str(); xxx_UT_DEBUGMSG(("Looking at TOC Style %s \n",sLStyle)); xxx_UT_DEBUGMSG(("Base input style is %s \n",sTmpStyle.utf8_str())); if(g_ascii_strcasecmp(sLStyle,sTmpStyle.utf8_str()) == 0) { xxx_UT_DEBUGMSG(("Found initial match \n")); return true; } PD_Style * pStyle = NULL; m_pDoc->getStyle(sTmpStyle.utf8_str(), &pStyle); if(pStyle != NULL) { UT_sint32 iLoop = 0; while((pStyle->getBasedOn()) != NULL && (iLoop < 10)) { pStyle = pStyle->getBasedOn(); iLoop++; sTmpStyle = pStyle->getName(); xxx_UT_DEBUGMSG(("Level %d style is %s \n",iLoop,sTmpStyle.utf8_str())); if(g_ascii_strcasecmp(sLStyle,sTmpStyle.utf8_str()) == 0) { return true; } } } xxx_UT_DEBUGMSG(("No match Found \n")); return false; }
false
false
false
false
false
0
ShowManhattanLine(Layer,X1,Y1,X2,Y2) int Layer; int X1,Y1,X2,Y2; { int X1P,Y1P,X2P,Y2P; FBForeground(DISPLAY,Layer); if (Parameters.kpRedisplayControl != FINEVIEWPORTONLY And CurrentAOI.aInCoarse) { CoarseLToP(X1,Y1,X1P,Y1P); CoarseLToP(X2,Y2,X2P,Y2P); if (X1P == X2P) { if (X1P < CurrentAOI.aLC Or X1P > CurrentAOI.aRC) return; if (Y1P > Y2P) SwapInts(Y1P,Y2P); if (Y1P > CurrentAOI.aTC Or Y2P < CurrentAOI.aBC) return; if (Y1P < CurrentAOI.aBC) Y1P = CurrentAOI.aBC; if (Y2P > CurrentAOI.aTC) Y2P = CurrentAOI.aTC; } elif (Y1P == Y2P) { if (Y1P < CurrentAOI.aBC Or Y1P > CurrentAOI.aTC) return; if (X1P > X2P) SwapInts(X1P,X2P); if (X1P > CurrentAOI.aRC Or X2P < CurrentAOI.aLC) return; if (X1P < CurrentAOI.aLC) X1P = CurrentAOI.aLC; if (X2P > CurrentAOI.aRC) X2P = CurrentAOI.aRC; } else return; FBLine(X1P,Y1P,X2P,Y2P); } if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY And CurrentAOI.aInFine) { FineLToP(X1,Y1,X1P,Y1P); FineLToP(X2,Y2,X2P,Y2P); if (X1P == X2P) { if (X1P < CurrentAOI.aLF Or X1P > CurrentAOI.aRF) return; if (Y1P > Y2P) SwapInts(Y1P,Y2P); if (Y1P > CurrentAOI.aTF Or Y2P < CurrentAOI.aBF) return; if (Y1P < CurrentAOI.aBF) Y1P = CurrentAOI.aBF; if (Y2P > CurrentAOI.aTF) Y2P = CurrentAOI.aTF; } elif (Y1P == Y2P) { if (Y1P < CurrentAOI.aBF Or Y1P > CurrentAOI.aTF) return; if (X1P > X2P) SwapInts(X1P,X2P); if (X1P > CurrentAOI.aRF Or X2P < CurrentAOI.aLF) return; if (X1P < CurrentAOI.aLF) X1P = CurrentAOI.aLF; if (X2P > CurrentAOI.aRF) X2P = CurrentAOI.aRF; } else return; FBLine(X1P,Y1P,X2P,Y2P); } }
false
false
false
false
false
0
i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj, enum i915_cache_level cache_level) { struct drm_device *dev = obj->base.dev; struct i915_vma *vma, *next; bool bound = false; int ret = 0; if (obj->cache_level == cache_level) goto out; /* Inspect the list of currently bound VMA and unbind any that would * be invalid given the new cache-level. This is principally to * catch the issue of the CS prefetch crossing page boundaries and * reading an invalid PTE on older architectures. */ list_for_each_entry_safe(vma, next, &obj->vma_list, obj_link) { if (!drm_mm_node_allocated(&vma->node)) continue; if (vma->pin_count) { DRM_DEBUG("can not change the cache level of pinned objects\n"); return -EBUSY; } if (!i915_gem_valid_gtt_space(vma, cache_level)) { ret = i915_vma_unbind(vma); if (ret) return ret; } else bound = true; } /* We can reuse the existing drm_mm nodes but need to change the * cache-level on the PTE. We could simply unbind them all and * rebind with the correct cache-level on next use. However since * we already have a valid slot, dma mapping, pages etc, we may as * rewrite the PTE in the belief that doing so tramples upon less * state and so involves less work. */ if (bound) { /* Before we change the PTE, the GPU must not be accessing it. * If we wait upon the object, we know that all the bound * VMA are no longer active. */ ret = i915_gem_object_wait_rendering(obj, false); if (ret) return ret; if (!HAS_LLC(dev) && cache_level != I915_CACHE_NONE) { /* Access to snoopable pages through the GTT is * incoherent and on some machines causes a hard * lockup. Relinquish the CPU mmaping to force * userspace to refault in the pages and we can * then double check if the GTT mapping is still * valid for that pointer access. */ i915_gem_release_mmap(obj); /* As we no longer need a fence for GTT access, * we can relinquish it now (and so prevent having * to steal a fence from someone else on the next * fence request). Note GPU activity would have * dropped the fence as all snoopable access is * supposed to be linear. */ ret = i915_gem_object_put_fence(obj); if (ret) return ret; } else { /* We either have incoherent backing store and * so no GTT access or the architecture is fully * coherent. In such cases, existing GTT mmaps * ignore the cache bit in the PTE and we can * rewrite it without confusing the GPU or having * to force userspace to fault back in its mmaps. */ } list_for_each_entry(vma, &obj->vma_list, obj_link) { if (!drm_mm_node_allocated(&vma->node)) continue; ret = i915_vma_bind(vma, cache_level, PIN_UPDATE); if (ret) return ret; } } list_for_each_entry(vma, &obj->vma_list, obj_link) vma->node.color = cache_level; obj->cache_level = cache_level; out: /* Flush the dirty CPU caches to the backing storage so that the * object is now coherent at its new cache level (with respect * to the access domain). */ if (obj->cache_dirty && obj->base.write_domain != I915_GEM_DOMAIN_CPU && cpu_write_needs_clflush(obj)) { if (i915_gem_clflush_object(obj, true)) i915_gem_chipset_flush(obj->base.dev); } return 0; }
false
false
false
false
false
0
shutdown(){ if (started) { mutex_data.lock(); flags|=FLAG_SHUTDOWN; mutex_data.unlock(); wakeup(); join(); started=false; } /// Save Session FXApp::instance()->reg().writeStringEntry("LastFM","session",session.text()); FXApp::instance()->reg().writeBoolEntry("LastFM","client-banned",(flags&FLAG_BANNED)); }
false
false
false
false
false
0
do_recursive_list(GConfEngine* conf, const gchar** args) { if (args == NULL) { g_printerr (_("Must specify one or more directories to recursively list.\n")); return 1; } while (*args) { GSList* subdirs; subdirs = gconf_engine_all_dirs(conf, *args, NULL); list_pairs_in_dir(conf, *args, 0); recurse_subdir_list(conf, subdirs, *args, 1); ++args; } return 0; }
false
false
false
false
false
0
cache_read_including_broken(httrackp * opt, cache_back * cache, const char *adr, const char *fil) { htsblk r = cache_read(opt, cache, adr, fil, NULL, NULL); if (r.statuscode == -1) { lien_back *itemback = NULL; if (back_unserialize_ref(opt, adr, fil, &itemback) == 0) { r = itemback->r; /* cleanup */ back_clear_entry(itemback); /* delete entry content */ freet(itemback); /* delete item */ itemback = NULL; return r; } } return r; }
false
false
false
false
false
0
SortIntArray ( int *array, int *anz ) // ----------------------------------------------------------------------------- { qsort(array,*anz,sizeof(int),int_compare); int source; int dest = 1; int lastelem = array[0]; for (source = 1; source < *anz; source++) { if (array[source] != lastelem){ array[dest++] = lastelem = array[source]; } } *anz = dest; }
false
false
false
false
false
0
amdgpu_uvd_resume(struct amdgpu_device *adev) { unsigned size; void *ptr; const struct common_firmware_header *hdr; unsigned offset; if (adev->uvd.vcpu_bo == NULL) return -EINVAL; hdr = (const struct common_firmware_header *)adev->uvd.fw->data; offset = le32_to_cpu(hdr->ucode_array_offset_bytes); memcpy(adev->uvd.cpu_addr, (adev->uvd.fw->data) + offset, (adev->uvd.fw->size) - offset); cancel_delayed_work_sync(&adev->uvd.idle_work); size = amdgpu_bo_size(adev->uvd.vcpu_bo); size -= le32_to_cpu(hdr->ucode_size_bytes); ptr = adev->uvd.cpu_addr; ptr += le32_to_cpu(hdr->ucode_size_bytes); memset(ptr, 0, size); return 0; }
false
true
false
false
false
1
isprimepower (Rep& q, const Rep& u) const { unsigned long int prime; unsigned long int n, n2; int i; unsigned long int rem; Integer t(u); int exact; int usize = int(u.size()); if (usize == 0) return 1; /* consider 0 a perfect power */ n2 = (unsigned int)u; if ( ( n2 & 3UL) == 2UL) return 0; /* 2 divides exactly once. */ n2=0; for( ; !( ((unsigned int)t) & 0x1) ; t>>=1, ++n2) { } if (usize<0 && n2 >0 && (n2 & 1) ==0) return 0; if (n2 >0) { if (t == 1) { q = 2; return (unsigned int) (n2); } else { return 0; } } Integer u2; for (i = 1; primes[i] != 0; i++) { u2 = u; prime = primes[i]; rem = (unsigned long)(u2 % prime); if (rem == 0) /* divisable by this prime? */ { Integer::divmod(q,rem,u2,prime * prime); if (rem != 0) return 0; /* prime divides exactly once, reject */ swap (q, u2); for (n = 2;;++n) { Integer::divmod(q, rem, u2, prime); if (rem != 0) break; swap (q, u2); } if ((n & 1) == 0 && usize < 0) return 0; /* even multiplicity with negative U, reject */ if (n > 0) { if (GIVABS(u2) == 1) { q = Integer(prime); return (unsigned int) (n); } else { return 0; } } } } /* We found no factors above; have to check all values of n. */ unsigned long int nth; for (nth = (usize < 0 ? 3 : 2);; ++nth) { if (! isprime (nth)) continue; exact = root (q, u2, (unsigned int)nth); if (exact) { if (isprime(q)) return (unsigned int)nth; else return 0; } if (GIVABS(q) < SMALLEST_OMITTED_PRIME) return 0; } } }
false
false
false
false
false
0
set_local_array_for_static_assign(Module_table *mhead) { int level = 1; if (cmp_static_slot_assign) { set_sm_block_only_flg(); no_lm_flg = TRUE; construct_IntSet(localized_func_set, get_max_module_entry(MODULE_FUNC) + 1); construct_IntSet(localized_sub_set, get_max_module_entry(MODULE_SUB) + 1); construct_array_access_tab(); get_count_of_array_access_block(mhead->block_head, get_max_array_entry(mhead->array_head)); localize_block_next(mhead->block_head, NULL, level); destruct_IntSet(localized_func_set); destruct_IntSet(localized_sub_set); destruct_array_access_tab(); no_lm_flg = FALSE; reset_sm_block_only_flg(); } }
false
false
false
false
false
0
stsz_Size(GF_Box *s) { GF_Err e; u32 i, fieldSize, size; GF_SampleSizeBox *ptr = (GF_SampleSizeBox *)s; e = gf_isom_full_box_get_size(s); if (e) return e; ptr->size += 8; if (!ptr->sampleCount) return GF_OK; //regular table if (ptr->type == GF_ISOM_BOX_TYPE_STSZ) { if (ptr->sampleSize) return GF_OK; ptr->size += (4 * ptr->sampleCount); return GF_OK; } fieldSize = 4; size = ptr->sizes[0]; for (i=0; i < ptr->sampleCount; i++) { if (ptr->sizes[i] <= 0xF) continue; //switch to 8-bit table else if (ptr->sizes[i] <= 0xFF) { fieldSize = 8; } //switch to 16-bit table else if (ptr->sizes[i] <= 0xFFFF) { fieldSize = 16; } //switch to 32-bit table else { fieldSize = 32; } //check the size if (size != ptr->sizes[i]) size = 0; } //if all samples are of the same size, switch to regular (more compact) if (size) { ptr->type = GF_ISOM_BOX_TYPE_STSZ; ptr->sampleSize = size; gf_free(ptr->sizes); ptr->sizes = NULL; } if (fieldSize == 32) { //oops, doesn't fit in a compact table ptr->type = GF_ISOM_BOX_TYPE_STSZ; ptr->size += (4 * ptr->sampleCount); return GF_OK; } //make sure we are a compact table (no need to change the mem representation) ptr->type = GF_ISOM_BOX_TYPE_STZ2; ptr->sampleSize = fieldSize; if (fieldSize == 4) { //do not forget the 0 padding field for odd count ptr->size += (ptr->sampleCount + 1) / 2; } else { ptr->size += (ptr->sampleCount) * (fieldSize/8); } return GF_OK; }
false
false
false
false
false
0
FindWindowRecursively(const wxWindow* parent, const wxString& partialLabel) // ---------------------------------------------------------------------------- { if ( parent ) { #if defined(LOGGING) //LOGIT( _T("Parent[%p]Label[%s]Name[%s]"), parent, parent->GetLabel().c_str(), parent->GetName().c_str() ); #endif // see if this is the one we're looking for if ( parent->GetLabel().Matches(partialLabel) ) return (wxWindow *)parent; if ( parent->GetName().Matches(partialLabel) ) return (wxWindow *)parent; // It wasn't, so check all its children for ( wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst(); node; node = node->GetNext() ) { // recursively check each child wxWindow *win = (wxWindow *)node->GetData(); wxWindow *retwin = FindWindowRecursively(win, partialLabel); if (retwin) return retwin; } } // Not found return NULL; }
false
false
false
false
false
0
button1Release(const XEvent *event_) { if (isProtected()==MSFalse) { if (event_->xbutton.button==Button2) activateCallback("button2up"); else if (event_->xbutton.button==Button3) activateCallback("button3up"); } }
false
false
false
false
false
0
guilddb_txt_delete_sub(void *key, void *data, va_list ap) { struct guild *g = (struct guild *)data; int guild_id = va_arg(ap, int); int i; for(i = 0; i < MAX_GUILDALLIANCE; i++) { if(g->alliance[i].guild_id == guild_id) { g->alliance[i].guild_id = 0; #ifdef TXT_JOURNAL if( guild_journal_enable ) journal_write( &guild_journal, g->guild_id, g ); #endif } } return 0; }
false
false
false
false
false
0
ceph_zero_partial_page( struct inode *inode, loff_t offset, unsigned size) { struct page *page; pgoff_t index = offset >> PAGE_CACHE_SHIFT; page = find_lock_page(inode->i_mapping, index); if (page) { wait_on_page_writeback(page); zero_user(page, offset & (PAGE_CACHE_SIZE - 1), size); unlock_page(page); page_cache_release(page); } }
false
false
false
false
false
0
lib3ds_light_new(const char *name) { Lib3dsLight *light; ASSERT(name); ASSERT(strlen(name)<64); light=(Lib3dsLight*)calloc(sizeof(Lib3dsLight), 1); if (!light) { return(0); } strcpy(light->name, name); return(light); }
false
false
false
false
false
0
exynos4_jpeg_parse_decode_h_tbl(struct s5p_jpeg_ctx *ctx) { struct s5p_jpeg *jpeg = ctx->jpeg; struct vb2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); struct s5p_jpeg_buffer jpeg_buffer; unsigned int word; int c, x, components; jpeg_buffer.size = 2; /* Ls */ jpeg_buffer.data = (unsigned long)vb2_plane_vaddr(vb, 0) + ctx->out_q.sos + 2; jpeg_buffer.curr = 0; word = 0; if (get_word_be(&jpeg_buffer, &word)) return; jpeg_buffer.size = (long)word - 2; jpeg_buffer.data += 2; jpeg_buffer.curr = 0; components = get_byte(&jpeg_buffer); if (components == -1) return; while (components--) { c = get_byte(&jpeg_buffer); if (c == -1) return; x = get_byte(&jpeg_buffer); if (x == -1) return; exynos4_jpeg_select_dec_h_tbl(jpeg->regs, c, (((x >> 4) & 0x1) << 1) | (x & 0x1)); } }
false
false
false
false
false
0
top10_write_stats (gboolean locally, gint lang) { gint i; gchar *filename; gchar *lsfile; FILE *fh; Statistics *top10; top10 = locally ? top10_local : top10_global; if (!g_file_test (main_path_score (), G_FILE_TEST_IS_DIR)) g_mkdir_with_parents (main_path_score (), DIR_PERM); filename = top10_get_score_file (locally, lang); lsfile = g_build_filename (main_path_score (), filename, NULL); fh = g_fopen (lsfile, "w"); if (fh == NULL) { g_warning ("Could not write the scores file in %s", main_path_score ()); g_free (filename); g_free (lsfile); return; } for (i = 0; i < 10; i++) { fputc (top10[i].lang[0], fh); fputc (top10[i].lang[1], fh); fputc (top10[i].genv, fh); //fwrite (&top10[i].when, sizeof (time_t), 1, fh); fwrite (&top10[i].when, sizeof (gint32), 1, fh); fwrite (&top10[i].nchars, sizeof (gint32), 1, fh); fwrite (&top10[i].accur, sizeof (gfloat), 1, fh); fwrite (&top10[i].velo, sizeof (gfloat), 1, fh); fwrite (&top10[i].fluid, sizeof (gfloat), 1, fh); fwrite (&top10[i].score, sizeof (gfloat), 1, fh); fwrite (&top10[i].name_len, sizeof (gint32), 1, fh); if (top10[i].name && top10[i].name_len > 0) fputs (top10[i].name, fh); } fputs ("KLAVARO!", fh); fclose (fh); g_free (filename); g_free (lsfile); }
false
false
false
false
false
0
MutableMessage(int number, FieldType type, const MessageLite& prototype) { Extension* extension; if (MaybeNewExtension(number, &extension)) { extension->type = type; GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); extension->is_repeated = false; extension->message_value = prototype.New(); } else { GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); } extension->is_cleared = false; return extension->message_value; }
false
false
false
false
false
0
resolve_addr4(const char *name, struct in_addr *inp) { if (inp->s_addr == INADDR_ANY) { puts("any"); return; } if (inp->s_addr == INADDR_LOOPBACK) { puts("loopback"); return; } if (inp->s_addr == INADDR_BROADCAST) { puts("broadcast"); return; } print_hostbyaddr(name, (const char *) inp, sizeof(*inp), AF_INET); }
false
false
false
false
false
0
is_dhcp_discover(void *wh, int len) { if( (memcmp(wh+4, BROADCAST, 6) == 0 || memcmp(wh+16, BROADCAST, 6) == 0) && (len >= 360 - 24 - 4 - 4 && len <= 380 - 24 - 4 - 4 ) ) return 1; return 0; }
false
false
false
false
false
0
MakeUidList(char *uidnames) { struct UidList *uidlist; struct Item *ip, *tmplist; char uidbuff[CF_BUFSIZE]; char *sp; int offset; struct passwd *pw; char *machine, *user, *domain, buffer[CF_EXPANDSIZE], *usercopy=NULL; int uid; int tmp = -1; uidlist = NULL; buffer[0] = '\0'; ExpandVarstring(uidnames,buffer,""); for (sp = buffer; *sp != '\0'; sp+=strlen(uidbuff)) { if (*sp == ',') { sp++; } if (sscanf(sp,"%[^,]",uidbuff)) { if (uidbuff[0] == '+') /* NIS group - have to do this in a roundabout */ { /* way because calling getpwnam spoils getnetgrent */ offset = 1; if (uidbuff[1] == '@') { offset++; } setnetgrent(uidbuff+offset); tmplist = NULL; while (getnetgrent(&machine,&user,&domain)) { if (user != NULL) { AppendItem(&tmplist,user,NULL); } } endnetgrent(); for (ip = tmplist; ip != NULL; ip=ip->next) { if ((pw = getpwnam(ip->name)) == NULL) { if (!PARSING) { snprintf(OUTPUT,CF_BUFSIZE*2,"Unknown user [%s]\n",ip->name); CfLog(cferror,OUTPUT,""); } uid = CF_UNKNOWN_OWNER; /* signal user not found */ usercopy = ip->name; } else { uid = pw->pw_uid; } AddSimpleUidItem(&uidlist,uid,usercopy); } DeleteItemList(tmplist); continue; } if (isdigit((int)uidbuff[0])) { sscanf(uidbuff,"%d",&tmp); uid = (uid_t)tmp; } else { if (strcmp(uidbuff,"*") == 0) { uid = CF_SAME_OWNER; /* signals wildcard */ } else if ((pw = getpwnam(uidbuff)) == NULL) { if (!PARSING) { snprintf(OUTPUT,CF_BUFSIZE,"Unknown user %s\n",uidbuff); CfLog(cferror,OUTPUT,""); } uid = CF_UNKNOWN_OWNER; /* signal user not found */ usercopy = uidbuff; } else { uid = pw->pw_uid; } } AddSimpleUidItem(&uidlist,uid,usercopy); } } if (uidlist == NULL) { AddSimpleUidItem(&uidlist,CF_SAME_OWNER,(char *) NULL); } return (uidlist); }
false
false
false
false
false
0
run_selfcheck(struct cli_all_bc *bcs) { struct cli_bc_ctx *ctx; struct cli_bc *bc = &bcs->all_bcs[bcs->count-1]; int rc; if (bc->state != bc_jit && bc->state != bc_interp) { cli_errmsg("Failed to prepare selfcheck bytecode\n"); return CL_EBYTECODE; } ctx = cli_bytecode_context_alloc(); if (!ctx) { cli_errmsg("Failed to allocate bytecode context\n"); return CL_EMEM; } cli_bytecode_context_setfuncid(ctx, bc, 0); cli_dbgmsg("bytecode self test running\n"); ctx->bytecode_timeout = 0; rc = cli_bytecode_run(bcs, bc, ctx); cli_bytecode_context_destroy(ctx); if (rc != CL_SUCCESS) { cli_errmsg("bytecode self test failed: %s\n", cl_strerror(rc)); } else { cli_dbgmsg("bytecode self test succeeded\n"); } return rc; }
false
false
false
false
false
0
pixWriteMixedToPS(PIX *pixb, PIX *pixc, l_float32 scale, l_int32 pageno, const char *fileout) { char *tnameb, *tnamec; const char *op; l_int32 resb, resc, endpage, maskop, ret; PROCNAME("pixWriteMixedToPS"); if (!pixb && !pixc) return ERROR_INT("pixb and pixc both undefined", procName, 1); if (!fileout) return ERROR_INT("fileout not defined", procName, 1); /* Compute the resolution that fills a letter-size page. */ if (!pixc) resb = getResLetterPage(pixGetWidth(pixb), pixGetHeight(pixb), 0); else { resc = getResLetterPage(pixGetWidth(pixc), pixGetHeight(pixc), 0); if (pixb) resb = (l_int32)(scale * resc); } /* Write the jpeg image first */ if (pixc) { tnamec = genTempFilename("/tmp", ".jpg"); pixWrite(tnamec, pixc, IFF_JFIF_JPEG); endpage = (pixb) ? FALSE : TRUE; op = (pageno <= 1) ? "w" : "a"; ret = convertJpegToPS(tnamec, fileout, op, 0, 0, resc, 1.0, pageno, endpage); FREE(tnamec); if (ret) return ERROR_INT("jpeg data not written", procName, 1); } /* Write the binary data, either directly or, if there is * a jpeg image on the page, through the mask. */ if (pixb) { tnameb = genTempFilename("/tmp", ".tif"); pixWrite(tnameb, pixb, IFF_TIFF_G4); op = (pageno <= 1 && !pixc) ? "w" : "a"; maskop = (pixc) ? 1 : 0; ret = convertTiffG4ToPS(tnameb, fileout, op, 0, 0, resb, 1.0, pageno, maskop, 1); FREE(tnameb); if (ret) return ERROR_INT("tiff data not written", procName, 1); } return 0; }
false
false
false
false
false
0
registerTimer(YTimer *t) { t->fPrev = 0; t->fNext = fFirstTimer; if (fFirstTimer) fFirstTimer->fPrev = t; else fLastTimer = t; fFirstTimer = t; }
false
false
false
false
false
0
initialiseParams(std::string const & data) { InsetCommandParams p(insetCode()); if (!InsetCommand::string2params(data, p)) return false; keywordED->setText(toqstr(p["name"])); return true; }
false
false
false
false
false
0
prof_handler(int sig, siginfo_t*, void* signal_ucontext, void* cpu_profiler) { CpuProfiler* instance = static_cast<CpuProfiler*>(cpu_profiler); if (instance->filter_ == NULL || (*instance->filter_)(instance->filter_arg_)) { void* stack[ProfileData::kMaxStackDepth]; // The top-most active routine doesn't show up as a normal // frame, but as the "pc" value in the signal handler context. stack[0] = GetPC(*reinterpret_cast<ucontext_t*>(signal_ucontext)); // We skip the top two stack trace entries (this function and one // signal handler frame) since they are artifacts of profiling and // should not be measured. Other profiling related frames may be // removed by "pprof" at analysis time. Instead of skipping the top // frames, we could skip nothing, but that would increase the // profile size unnecessarily. int depth = GetStackTraceWithContext(stack + 1, arraysize(stack) - 1, 2, signal_ucontext); depth++; // To account for pc value in stack[0]; instance->collector_.Add(depth, stack); } }
false
false
false
false
false
0
Pop(vtkIdType location, double &priority) { vtkIdType id, i, j, idx; vtkPriorityQueue::Item temp; if ( this->MaxId < 0 ) { return -1; } id = this->Array[location].id; priority = this->Array[location].priority; // move the last item to the location specified and push into the tree this->Array[location].id = this->Array[this->MaxId].id; this->Array[location].priority = this->Array[this->MaxId].priority; this->ItemLocation->SetValue(this->Array[location].id,location); this->ItemLocation->SetValue(id,-1); if ( --this->MaxId <= 0 ) { return id; } // percolate down the tree from the specified location int lastNodeToCheck = (this->MaxId-1)/2; for ( j=0, i=location; i <= lastNodeToCheck; i=j ) { idx = 2*i + 1; if ( this->Array[idx].priority < this->Array[idx+1].priority || idx == this->MaxId ) { j = idx; } else { j = idx + 1; } if ( this->Array[i].priority > this->Array[j].priority ) { temp = this->Array[i]; this->ItemLocation->SetValue(temp.id,j); this->Array[i] = this->Array[j]; this->ItemLocation->SetValue(this->Array[j].id,i); this->Array[j] = temp; } else { break; } } // percolate up the tree from the specified location for ( idx=0, i=location; i > 0; i=idx ) { idx = (i-1)/2; if ( this->Array[i].priority < this->Array[idx].priority ) { temp = this->Array[i]; this->ItemLocation->SetValue(temp.id,idx); this->Array[i] = this->Array[idx]; this->ItemLocation->SetValue(this->Array[idx].id,i); this->Array[idx] = temp; } else { break; } } return id; }
false
false
false
false
false
0
check_capacity(gpointer key, gpointer value, gpointer user_data) { int required = 0; int remaining = 0; struct capacity_data *data = user_data; required = crm_parse_int(value, "0"); remaining = crm_parse_int(g_hash_table_lookup(data->node->details->utilization, key), "0"); if (required > remaining) { pe_rsc_debug(data->rsc, "Node %s has no enough %s for resource %s: required=%d remaining=%d", data->node->details->uname, (char *)key, data->rsc->id, required, remaining); data->is_enough = FALSE; } }
false
false
false
false
false
0
usb_unanchor_urb(struct urb *urb) { unsigned long flags; struct usb_anchor *anchor; if (!urb) return; anchor = urb->anchor; if (!anchor) return; spin_lock_irqsave(&anchor->lock, flags); /* * At this point, we could be competing with another thread which * has the same intention. To protect the urb from being unanchored * twice, only the winner of the race gets the job. */ if (likely(anchor == urb->anchor)) __usb_unanchor_urb(urb, anchor); spin_unlock_irqrestore(&anchor->lock, flags); }
false
false
false
false
false
0
dc_hurt(int script, int* yield, int* preturnint, int sprite, int damage) { STOP_IF_BAD_SPRITE(sprite); if (dversion >= 108) { // With v1.07 hurt(&sthing, -1) would run hit(), with v1.08 it // doesn't (after redink1 tried to fix a game freeze bug that I // can't reproduce) if (damage < 0) return; } if (hurt_thing(sprite, damage, 0) > 0) random_blood(spr[sprite].x, spr[sprite].y-40, sprite); if (spr[sprite].nohit != 1 && spr[sprite].script != 0 && locate(spr[sprite].script, "HIT")) { if (rinfo[script]->sprite != 1000) { *penemy_sprite = rinfo[script]->sprite; //redink1 addition of missle_source stuff if (dversion >= 108) *pmissle_source = rinfo[script]->sprite; } kill_returning_stuff(spr[sprite].script); run_script(spr[sprite].script); } }
false
false
false
false
false
0
cocktail_sort_debug(data array[], int len, STAT *stat) { int begin = 0; // array is to be sorted from position begin to end+1 int end = len-1; int i; // currently scanning position: comparing array[i] and array[i+1] int new_end = begin; int new_begin = end; data tmp; // temporary variable used to swap elements stat->space++; stat->allo++; while (begin < end) { // while array is not completely sorted new_end = begin; for (i = begin; i < end; i++) { // scan from begin to end if (array[i] > array[i+1]) { tmp = array[i]; array[i] = array[i+1]; array[i+1] = tmp; new_end = i; stat->swap++; // count swappings } stat->comp++; // count comparisons } end = new_end; new_begin = end; for (i = end-1; i >= begin; i--) { // scan from end to begin if (array[i] > array[i+1]) { tmp = array[i]; array[i] = array[i+1]; array[i+1] = tmp; new_begin = i; stat->swap++; // count swappings } stat->comp++; // count comparisons } begin = new_begin; } }
false
false
false
false
false
0
operator<< (ostream &o, const map <string, string> &m) { for (map <string, string>::const_iterator i = m.begin(); i != m.end(); i ++) o << (*i).first << " -> " << (*i).second << "\n"; return o; }
false
false
false
false
false
0
GetOperatorType (const int ch1, const int ch2) { int OpType = NO_OPERATOR; if ((ch1 == '+') || (ch1 == '-') || (ch1 == '*') || (ch1 == '/') || (ch1 == '#') || (ch1 == '(') || (ch1 == ')') || (ch1 == '~') || (ch1 == '&') || (ch1 == '|') || (ch1 == ',')) OpType = OPERATOR_1CHAR; else if ((ch1 == ch2) && (ch1 == '<' || ch1 == '>')) OpType = OPERATOR_2CHAR; return OpType; }
false
false
false
false
false
0
width(bool constrained) { unsigned int sz = 0; if (constrained) { if (d_array_var->send_p()) sz = d_array_var->width(constrained); } else { sz = d_array_var->width(constrained); } for (Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) { if (constrained) { if ((*i)->send_p()) sz += (*i)->width(constrained); } else { sz += (*i)->width(constrained); } } return sz; }
false
false
false
false
false
0
AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl<MachineOperand> &Cond, bool AllowModify) const { // If the block has no terminators, it just falls into the block after it. MachineBasicBlock::iterator I = MBB.getLastNonDebugInstr(); if (I == MBB.end()) return false; if (!isUnpredicatedTerminator(I)) return false; // Get the last instruction in the block. MachineInstr *LastInst = I; // If there is only one terminator instruction, process it. if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) { if (IsBRU(LastInst->getOpcode())) { TBB = LastInst->getOperand(0).getMBB(); return false; } XCore::CondCode BranchCode = GetCondFromBranchOpc(LastInst->getOpcode()); if (BranchCode == XCore::COND_INVALID) return true; // Can't handle indirect branch. // Conditional branch // Block ends with fall-through condbranch. TBB = LastInst->getOperand(1).getMBB(); Cond.push_back(MachineOperand::CreateImm(BranchCode)); Cond.push_back(LastInst->getOperand(0)); return false; } // Get the instruction before it if it's a terminator. MachineInstr *SecondLastInst = I; // If there are three terminators, we don't know what sort of block this is. if (SecondLastInst && I != MBB.begin() && isUnpredicatedTerminator(--I)) return true; unsigned SecondLastOpc = SecondLastInst->getOpcode(); XCore::CondCode BranchCode = GetCondFromBranchOpc(SecondLastOpc); // If the block ends with conditional branch followed by unconditional, // handle it. if (BranchCode != XCore::COND_INVALID && IsBRU(LastInst->getOpcode())) { TBB = SecondLastInst->getOperand(1).getMBB(); Cond.push_back(MachineOperand::CreateImm(BranchCode)); Cond.push_back(SecondLastInst->getOperand(0)); FBB = LastInst->getOperand(0).getMBB(); return false; } // If the block ends with two unconditional branches, handle it. The second // one is not executed, so remove it. if (IsBRU(SecondLastInst->getOpcode()) && IsBRU(LastInst->getOpcode())) { TBB = SecondLastInst->getOperand(0).getMBB(); I = LastInst; if (AllowModify) I->eraseFromParent(); return false; } // Likewise if it ends with a branch table followed by an unconditional branch. if (IsBR_JT(SecondLastInst->getOpcode()) && IsBRU(LastInst->getOpcode())) { I = LastInst; if (AllowModify) I->eraseFromParent(); return true; } // Otherwise, can't handle this. return true; }
false
false
false
true
false
1
rsi_sdio_device_init(struct rsi_common *common) { if (rsi_load_ta_instructions(common)) return -1; if (rsi_sdio_master_access_msword(common->priv, MISC_CFG_BASE_ADDR)) { rsi_dbg(ERR_ZONE, "%s: Unable to set ms word reg\n", __func__); return -1; } rsi_dbg(INIT_ZONE, "%s: Setting ms word to 0x41050000\n", __func__); return 0; }
false
false
false
false
false
0
kone_sysfs_show_weight(struct device *dev, struct device_attribute *attr, char *buf) { struct kone_device *kone; struct usb_device *usb_dev; int weight = 0; int retval; dev = dev->parent->parent; kone = hid_get_drvdata(dev_get_drvdata(dev)); usb_dev = interface_to_usbdev(to_usb_interface(dev)); mutex_lock(&kone->kone_lock); retval = kone_get_weight(usb_dev, &weight); mutex_unlock(&kone->kone_lock); if (retval) return retval; return snprintf(buf, PAGE_SIZE, "%d\n", weight); }
false
false
false
false
false
0
media_from_uri_cb (GrlSource *source, guint operation_id, GrlMedia *media, gpointer user_data, const GError *error) { struct MediaFromUriCallbackData *mfucd = (struct MediaFromUriCallbackData *) user_data; if (error) { mfucd->user_callback (NULL, 0, NULL, mfucd->user_data, error); } else if (media) { mfucd->user_callback (source, 0, media, mfucd->user_data, NULL); } else { GError *_error = g_error_new (GRL_CORE_ERROR, GRL_CORE_ERROR_MEDIA_FROM_URI_FAILED, _("Could not resolve media for URI '%s'"), mfucd->uri); mfucd->user_callback (source, 0, media, mfucd->user_data, _error); g_error_free (_error); } free_media_from_uri_data (mfucd); }
false
false
false
false
false
0
r6_surface_init_linear(struct radeon_surface_manager *surf_man, struct radeon_surface *surf, uint64_t offset, unsigned start_level) { uint32_t xalign, yalign, zalign; unsigned i; /* compute alignment */ if (!start_level) { surf->bo_alignment = MAX2(256, surf_man->hw_info.group_bytes); } /* the 32 alignment is for scanout, cb or db but to allow texture to be * easily bound as such we force this alignment to all surface */ xalign = MAX2(1, surf_man->hw_info.group_bytes / surf->bpe); yalign = 1; zalign = 1; if (surf->flags & RADEON_SURF_SCANOUT) { xalign = MAX2((surf->bpe == 1) ? 64 : 32, xalign); } /* build mipmap tree */ for (i = start_level; i <= surf->last_level; i++) { surf->level[i].mode = RADEON_SURF_MODE_LINEAR; surf_minify(surf, surf->level+i, surf->bpe, i, xalign, yalign, zalign, offset); /* level0 and first mipmap need to have alignment */ offset = surf->bo_size; if ((i == 0)) { offset = ALIGN(offset, surf->bo_alignment); } } return 0; }
false
false
false
false
false
0
attachment_dialog_dispose (GObject *object) { EAttachmentDialogPrivate *priv; priv = E_ATTACHMENT_DIALOG_GET_PRIVATE (object); if (priv->attachment != NULL) { g_object_unref (priv->attachment); priv->attachment = NULL; } if (priv->display_name_entry != NULL) { g_object_unref (priv->display_name_entry); priv->display_name_entry = NULL; } if (priv->description_entry != NULL) { g_object_unref (priv->description_entry); priv->description_entry = NULL; } if (priv->content_type_label != NULL) { g_object_unref (priv->content_type_label); priv->content_type_label = NULL; } if (priv->disposition_checkbox != NULL) { g_object_unref (priv->disposition_checkbox); priv->disposition_checkbox = NULL; } /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_attachment_dialog_parent_class)->dispose (object); }
false
false
false
false
false
0
MG_s_free_mem(MG_S_INFO *mg_s_info) { FUNCNAME("MG_s_free_mem"); MULTI_GRID_INFO *mg_info = NULL; int levels, i, *dofs_per_level; TEST_EXIT(mg_s_info && (mg_info = mg_s_info->mg_info), "no mg_s_info or mg_info\n"); TEST_EXIT(dofs_per_level = mg_s_info->dofs_per_level, "no dofs_per_level\n"); levels = mg_info->mg_levels; /* fine grid matrix uses rows from mg_s_info->mat */ for (i=0; i<mg_s_info->matrix[levels-1]->size; i++) mg_s_info->matrix[levels-1]->matrix_row[i] = nil; for (i = levels-1; i >= 0; i--) { MEM_FREE(mg_s_info->r_h[i], dofs_per_level[i], REAL); MEM_FREE(mg_s_info->u_h[i], dofs_per_level[i], REAL); MEM_FREE(mg_s_info->f_h[i], dofs_per_level[i], REAL); free_dof_matrix(mg_s_info->matrix[i]); } MEM_FREE(mg_s_info->dofs_per_level, mg_s_info->size, int); MEM_FREE(mg_s_info->r_h, mg_s_info->size, REAL *); MEM_FREE(mg_s_info->u_h, mg_s_info->size, REAL *); MEM_FREE(mg_s_info->f_h, mg_s_info->size, REAL *); MEM_FREE(mg_s_info->matrix, mg_s_info->size, DOF_MATRIX *); MEM_FREE(mg_s_info->sort_dof_invers, mg_s_info->sort_invers_size, int); MEM_FREE(mg_s_info->sort_bound, mg_s_info->sort_size, S_CHAR); MEM_FREE(mg_s_info->dof_level, mg_s_info->sort_size, U_CHAR); MEM_FREE(mg_s_info->dof_parent[1], mg_s_info->sort_size, DOF); MEM_FREE(mg_s_info->dof_parent[0], mg_s_info->sort_size, DOF); MEM_FREE(mg_s_info->sort_dof, mg_s_info->sort_size, int); mg_s_info->sort_dof_invers = nil; mg_s_info->dofs_per_level = nil; mg_s_info->f_h = mg_s_info->u_h = mg_s_info->r_h = nil; mg_s_info->matrix = nil; mg_s_info->sort_dof_invers = nil; mg_s_info->sort_bound = nil; mg_s_info->dof_level = nil; mg_s_info->dof_parent[0] = mg_s_info->dof_parent[1] = nil; mg_s_info->sort_dof = nil; mg_s_info->size = 0; mg_s_info->sort_size = 0; mg_s_info->sort_invers_size = 0; return; }
false
false
false
true
false
1
ocfs2_create_reflink_node(struct inode *s_inode, struct buffer_head *s_bh, struct inode *t_inode, struct buffer_head *t_bh, bool preserve) { int ret; struct buffer_head *ref_root_bh = NULL; struct ocfs2_cached_dealloc_ctxt dealloc; struct ocfs2_super *osb = OCFS2_SB(s_inode->i_sb); struct ocfs2_refcount_block *rb; struct ocfs2_dinode *di = (struct ocfs2_dinode *)s_bh->b_data; struct ocfs2_refcount_tree *ref_tree; ocfs2_init_dealloc_ctxt(&dealloc); ret = ocfs2_set_refcount_tree(t_inode, t_bh, le64_to_cpu(di->i_refcount_loc)); if (ret) { mlog_errno(ret); goto out; } if (OCFS2_I(s_inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { ret = ocfs2_duplicate_inline_data(s_inode, s_bh, t_inode, t_bh); if (ret) mlog_errno(ret); goto out; } ret = ocfs2_lock_refcount_tree(osb, le64_to_cpu(di->i_refcount_loc), 1, &ref_tree, &ref_root_bh); if (ret) { mlog_errno(ret); goto out; } rb = (struct ocfs2_refcount_block *)ref_root_bh->b_data; ret = ocfs2_duplicate_extent_list(s_inode, t_inode, t_bh, &ref_tree->rf_ci, ref_root_bh, &dealloc); if (ret) { mlog_errno(ret); goto out_unlock_refcount; } out_unlock_refcount: ocfs2_unlock_refcount_tree(osb, ref_tree, 1); brelse(ref_root_bh); out: if (ocfs2_dealloc_has_cluster(&dealloc)) { ocfs2_schedule_truncate_log_flush(osb, 1); ocfs2_run_deallocs(osb, &dealloc); } return ret; }
false
false
false
false
false
0
dump_cursor_direction(PLpgSQL_stmt_fetch *stmt) { dump_indent += 2; dump_ind(); switch (stmt->direction) { case FETCH_FORWARD: printf(" FORWARD "); break; case FETCH_BACKWARD: printf(" BACKWARD "); break; case FETCH_ABSOLUTE: printf(" ABSOLUTE "); break; case FETCH_RELATIVE: printf(" RELATIVE "); break; default: printf("??? unknown cursor direction %d", stmt->direction); } if (stmt->expr) { dump_expr(stmt->expr); printf("\n"); } else printf("%ld\n", stmt->how_many); dump_indent -= 2; }
false
false
false
false
false
0
BackRefMatchesNoCase(int from, int current, int len, Vector<const uc16> subject) { for (int i = 0; i < len; i++) { unibrow::uchar old_char = subject[from++]; unibrow::uchar new_char = subject[current++]; if (old_char == new_char) continue; unibrow::uchar old_string[1] = { old_char }; unibrow::uchar new_string[1] = { new_char }; interp_canonicalize.get(old_char, '\0', old_string); interp_canonicalize.get(new_char, '\0', new_string); if (old_string[0] != new_string[0]) { return false; } } return true; }
false
false
false
false
false
0
hat_event (GooCanvasItem *item, GooCanvasItem *target, GdkEventButton *event, gpointer data) { if (board_paused) return FALSE; if ((event->type == GDK_BUTTON_PRESS) && (event->button == 1)) { // disconnect hat and hat_event, so that hat can not be clicked any more g_signal_handler_disconnect(hat, hat_event_id); // 'open' the hat goo_canvas_item_animate (item, 0, 0, 1, -30, FALSE, 40 * 20, 40, GOO_CANVAS_ANIMATE_FREEZE); // Make the items move from/out the hat, depending on the mode // Wait a few seconds between the two frames move_stars(&frame1); timer_id = g_timeout_add(1200, (GSourceFunc) move_stars, &frame2); // Wait again a few seconds before closing the hat. Then the game is ready to start timer_id = g_timeout_add(2600, (GSourceFunc) close_hat, NULL); } return FALSE; }
false
false
false
false
false
0
DoPlanarConfiguration(std::istream &is, std::ostream &os) { // FIXME: Do some stupid work: std::streampos start = is.tellg(); assert( 0 - start == 0 ); is.seekg( 0, std::ios::end); size_t buf_size = (size_t)is.tellg(); //assert(buf_size < INT_MAX); char *dummy_buffer = new char[(unsigned int)buf_size]; is.seekg(start, std::ios::beg); is.read( dummy_buffer, buf_size); is.seekg(start, std::ios::beg); // reset //SwapCode sc = is.GetSwapCode(); // US-RGB-8-epicard.dcm //assert( image.GetNumberOfDimensions() == 3 ); assert( buf_size % 3 == 0 ); unsigned long size = (unsigned long)buf_size/3; char *copy = new char[ (unsigned int)buf_size ]; //memmove( copy, dummy_buffer, buf_size); const char *r = dummy_buffer /*copy*/; const char *g = dummy_buffer /*copy*/ + size; const char *b = dummy_buffer /*copy*/ + size + size; char *p = copy /*dummy_buffer*/; for (unsigned long j = 0; j < size; ++j) { *(p++) = *(r++); *(p++) = *(g++); *(p++) = *(b++); } delete[] dummy_buffer /*copy*/; os.write(copy /*dummy_buffer*/, buf_size); delete[] copy; return true; }
false
false
false
false
false
0
on_treeselection_changed(void) { const int rows = gtk_tree_selection_count_selected_rows(gui.treeselection); gtk_widget_set_sensitive(GTK_WIDGET(gui.toolbutton_remove), (rows > 0)); gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_treeview_remove), (rows > 0)); gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_treeview_copy), (rows == 1)); if (rows == 1) { for (int i = 0; i < HASH_FUNCS_N; i++) { if (!hash.funcs[i].enabled) continue; char *digest = list_get_selected_digest(i); gtk_widget_set_sensitive(GTK_WIDGET( gui.hash_widgets[i].menuitem_treeview_copy), (digest && *digest)); g_free(digest); } } }
false
false
false
false
false
0
est_border_str(void){ static int first = TRUE; static char border[ESTPATHBUFSIZ]; int t, p; if(first){ t = (int)(time(NULL) + est_random() * INT_MAX); p = (int)(getpid() + est_random() * INT_MAX); sprintf(border, "--------[%08X%08X]--------", dpouterhash((char *)&t, sizeof(int)), dpouterhash((char *)&p, sizeof(int))); first = FALSE; } return border; }
false
false
false
false
false
0
MakeUnixPath(string& path) { if (path.empty()) return; for (string::iterator c = path.begin(); c != path.end(); c++) { if (*c == '\\') *c = '/'; } }
false
false
false
false
false
0
uv__platform_loop_init(uv_loop_t* loop, int default_loop) { int fd; fd = uv__epoll_create1(UV__EPOLL_CLOEXEC); /* epoll_create1() can fail either because it's not implemented (old kernel) * or because it doesn't understand the EPOLL_CLOEXEC flag. */ if (fd == -1 && (errno == ENOSYS || errno == EINVAL)) { fd = uv__epoll_create(256); if (fd != -1) uv__cloexec(fd, 1); } loop->backend_fd = fd; loop->inotify_fd = -1; loop->inotify_watchers = NULL; if (fd == -1) return -1; return 0; }
false
false
false
false
false
0
LoadImage(int i) { Array3Df *image = new Array3Df; if (!ReadImage(filenames_[i].c_str(), image)) { delete image; // TODO(keir): Better error reporting? fprintf(stderr, "Failed loading image %d: %s\n", i, filenames_[i].c_str()); return 0; } return new Image(image); }
false
false
false
false
false
0
setup_header(hhdr, sz, kind, flags) register hdr * hhdr; word sz; /* object size in words */ int kind; unsigned char flags; { register word descr; /* Add description of valid object pointers */ if (!GC_add_map_entry(sz)) return(FALSE); hhdr -> hb_map = GC_obj_map[sz > MAXOBJSZ? 0 : sz]; /* Set size, kind and mark proc fields */ hhdr -> hb_sz = sz; hhdr -> hb_obj_kind = kind; hhdr -> hb_flags = flags; descr = GC_obj_kinds[kind].ok_descriptor; if (GC_obj_kinds[kind].ok_relocate_descr) descr += WORDS_TO_BYTES(sz); hhdr -> hb_descr = descr; /* Clear mark bits */ GC_clear_hdr_marks(hhdr); hhdr -> hb_last_reclaimed = (unsigned short)GC_gc_no; return(TRUE); }
false
false
false
false
false
0
gss_decapsulate_token (gss_const_buffer_t input_token, gss_const_OID token_oid, gss_buffer_t output_token) { gss_OID_desc tmpoid; char *oid = NULL, *out = NULL; size_t oidlen = 0, outlen = 0; if (!input_token) return GSS_S_CALL_INACCESSIBLE_READ; if (!token_oid) return GSS_S_CALL_INACCESSIBLE_READ; if (!output_token) return GSS_S_CALL_INACCESSIBLE_WRITE; if (_gss_decapsulate_token ((char *) input_token->value, input_token->length, &oid, &oidlen, &out, &outlen) != 0) return GSS_S_DEFECTIVE_TOKEN; tmpoid.length = oidlen; tmpoid.elements = oid; if (!gss_oid_equal (token_oid, &tmpoid)) return GSS_S_DEFECTIVE_TOKEN; output_token->length = outlen; output_token->value = malloc (outlen); if (!output_token->value) return GSS_S_FAILURE; memcpy (output_token->value, out, outlen); return GSS_S_COMPLETE; }
false
false
false
false
true
1
_e2_pane_current_focus_top (gpointer from, E2_ActionRuntime *art) { if (gtk_tree_model_iter_n_children (curr_view->model, NULL) > 0) { e2_fileview_focus_row (curr_view, 0, TRUE, TRUE, FALSE, TRUE); return TRUE; } return FALSE; }
false
false
false
false
false
0
repo_init_structure(const char *git_dir, int is_bare) { const int mode = 0755; /* or 0777 ? */ int error; char temp_path[GIT_PATH_MAX]; if (git_futils_mkdir_r(git_dir, mode)) return git__throw(GIT_ERROR, "Failed to initialize repository structure. Could not mkdir"); /* Hides the ".git" directory */ if (!is_bare) { #ifdef GIT_WIN32 error = p_hide_directory__w32(git_dir); if (error < GIT_SUCCESS) return git__rethrow(error, "Failed to initialize repository structure"); #endif } /* Creates the '/objects/info/' directory */ git_path_join(temp_path, git_dir, GIT_OBJECTS_INFO_DIR); error = git_futils_mkdir_r(temp_path, mode); if (error < GIT_SUCCESS) return git__rethrow(error, "Failed to initialize repository structure"); /* Creates the '/objects/pack/' directory */ git_path_join(temp_path, git_dir, GIT_OBJECTS_PACK_DIR); error = p_mkdir(temp_path, mode); if (error < GIT_SUCCESS) return git__throw(error, "Unable to create `%s` folder", temp_path); /* Creates the '/refs/heads/' directory */ git_path_join(temp_path, git_dir, GIT_REFS_HEADS_DIR); error = git_futils_mkdir_r(temp_path, mode); if (error < GIT_SUCCESS) return git__rethrow(error, "Failed to initialize repository structure"); /* Creates the '/refs/tags/' directory */ git_path_join(temp_path, git_dir, GIT_REFS_TAGS_DIR); error = p_mkdir(temp_path, mode); if (error < GIT_SUCCESS) return git__throw(error, "Unable to create `%s` folder", temp_path); /* TODO: what's left? templates? */ return GIT_SUCCESS; }
false
false
false
false
false
0
gt_bittab_show(const GtBittab *b, FILE *outfp) { unsigned long i; gt_assert(b && outfp); /* header line */ for (i = 0; i < b->num_of_bits; i++) fprintf(outfp, "%lu", i % 10); gt_xfputc('\n', outfp); /* actual bits */ for (i = 0; i < b->num_of_bits; i++) { if (gt_bittab_bit_is_set(b, i)) gt_xfputc('1', outfp); else gt_xfputc('0', outfp); } gt_xfputc('\n', outfp); }
false
false
false
false
false
0
file_list_status_changed (GiggleFileList *list) { GiggleFileListPriv *priv; GtkTreePath *path; if (gtk_tree_view_get_model (GTK_TREE_VIEW (list))) { return; } priv = GET_PRIV (list); gtk_tree_view_set_model (GTK_TREE_VIEW (list), priv->filter_model); /* expand the project folder */ path = gtk_tree_path_new_first (); gtk_tree_view_expand_row (GTK_TREE_VIEW (list), path, FALSE); gtk_tree_path_free (path); if (priv->selected_path) giggle_tree_view_select_row_by_string (GTK_WIDGET (list), COL_REL_PATH, priv->selected_path); }
false
false
false
false
false
0
isTagInDictionary(const DcmTagKey &search_key) { const DcmDataDictionary& globalDataDict = dcmDataDict.rdlock(); const DcmDictEntry *dicent = globalDataDict.findEntry(search_key,NULL); // successfull lookup in dictionary -> translate to tag and return dcmDataDict.unlock(); if (dicent) return OFTrue; else return OFFalse; }
false
false
false
false
false
0
orthogonalize (unsigned index, unsigned n, unsigned level, real_t min_norm, const word_t *domain_blocks, const coding_t *c) /* * Step 'n' of the Gram-Schmidt orthogonalization procedure: * vector 'index' is orthogonalized with respect to the set * {u_[0], ... , u_['n' - 1]}. The size of the image blocks is given by * 'level'. If the denominator gets smaller than 'min_norm' then * the corresponding domain is excluded from the list of available * domain blocks. * * No return value. * * Side effects: * The remainder values (numerator and denominator) of * all 'domain_blocks' are updated. */ { unsigned domain; ip_image_ortho_vector [n] = rem_numerator [index]; norm_ortho_vector [n] = rem_denominator [index]; /* * Compute inner products between all domain images and * vector n of the orthogonal basis: * for (i = 0, ... , wfa->states) * <s_i, o_n> := <s_i, v_n> - * \sum (k = 0, ... , n - 1){ <v_n, o_k> <s_i, o_k> / ||o_k||^2} * Moreover the denominator and numerator parts of the comparitive * value are updated. */ for (domain = 0; domain_blocks [domain] >= 0; domain++) if (!used [domain]) { unsigned k; real_t tmp = get_ip_state_state (domain_blocks [index], domain_blocks [domain], level, c); for (k = 0; k < n; k++) tmp -= ip_domain_ortho_vector [domain][k] / norm_ortho_vector [k] * ip_domain_ortho_vector [index][k]; ip_domain_ortho_vector [domain][n] = tmp; rem_denominator [domain] -= square (tmp) / norm_ortho_vector [n]; rem_numerator [domain] -= ip_image_ortho_vector [n] / norm_ortho_vector [n] * ip_domain_ortho_vector [domain][n] ; /* * Exclude vectors with small denominator */ if (!used [domain]) if (rem_denominator [domain] / size_of_level (level) < min_norm) used [domain] = YES; } }
false
false
false
false
false
0
UpScope(void) { cur_scope++; #if DEBUG printf("#Var.c# Scope ++ (%2d)\n",cur_scope); #endif if(cur_scope>=max_scope) { if(max_scope==0) variable=Malloc(16*sizeof(StringList2)); else variable=Realloc(variable,(max_scope+16)*sizeof(StringList2)); max_scope+=16; } variable[cur_scope]=NewStringList2(); }
false
false
false
false
false
0
next_packet_frame_wrapped(bgav_demuxer_context_t * ctx, bgav_stream_t * dummy) { if(ctx->next_packet_pos) { int ret = 0; while(1) { if(!process_packet_frame_wrapped(ctx)) return ret; else ret = 1; if(ctx->input->position >= ctx->next_packet_pos) return ret; } } else { return process_packet_frame_wrapped(ctx); } return 0; }
false
false
false
false
false
0
isUpper(const std::string &str) { for (unsigned int i = 0; i < str.length(); ++i) { if (str[i] >= 'a' && str[i] <= 'z') return false; } return true; }
false
false
false
false
false
0
GetKeyShuffleData(int) { QByteArray msg; QDataStream stream(&msg, QIODevice::WriteOnly); QSharedPointer<AsymmetricKey> pub_key(_anon_signing_key->GetPublicKey()); stream << pub_key; _key_shuffle_data = msg; return QPair<QByteArray, bool>(msg, false); }
false
false
false
false
false
0
sort_threads_and_collapse(THREADNODE *tree) { THREADNODE *newtree = NULL, *newbranchtree = NULL, *newtreefree = NULL; if(tree){ newtree = mail_newthreadnode(NULL); newtree->num = tree->num; /* * Only sort at the top level. Individual threads can * rely on collapse_threadnode_tree */ if(tree->next) newtree->next = collapse_threadnode_tree(tree->next); if(tree->branch){ /* * This recursive call returns an already re-sorted tree. * With that, we can loop through and inject ourselves * where we fit in with that sort, and pass back to the * caller to inject themselves. */ newbranchtree = sort_threads_and_collapse(tree->branch); } if(newtree->num) newtree = insert_tree_in_place(newtree, newbranchtree); else{ /* * If top node is a dummy, here is where we collapse it. */ newtreefree = newtree; newtree = insert_tree_in_place(newtree->next, newbranchtree); newtreefree->next = NULL; mail_free_threadnode(&newtreefree); } } return(newtree); }
false
false
false
false
false
0
glmWeld(GLMmodel* model, float epsilon) { float* vectors; float* copies; unsigned int numvectors; unsigned int i, welded; /* vertices */ numvectors = model->numvertices; vectors = model->vertices; copies = glmWeldVectors(vectors, &numvectors, epsilon); welded = model->numvertices - numvectors - 1; for (i = 0; i < model->numtriangles; i++) { T(i).vindices[0] = (unsigned int)vectors[3 * T(i).vindices[0] + 0]; T(i).vindices[1] = (unsigned int)vectors[3 * T(i).vindices[1] + 0]; T(i).vindices[2] = (unsigned int)vectors[3 * T(i).vindices[2] + 0]; } /* free space for old vertices */ free(vectors); /* allocate space for the new vertices */ model->numvertices = numvectors; model->vertices = (float*)malloc(sizeof(float) * 3 * (model->numvertices + 1)); /* copy the optimized vertices into the actual vertex list */ for (i = 1; i <= model->numvertices; i++) { model->vertices[3 * i + 0] = copies[3 * i + 0]; model->vertices[3 * i + 1] = copies[3 * i + 1]; model->vertices[3 * i + 2] = copies[3 * i + 2]; } free(copies); return welded; }
false
true
false
false
false
1
Initialize() { SizeValueType i, low, high; // build table // when using valley-func then the table values run from // lowest_my - 10 * sigma to highest_my + 10 * sigma low = 0; high = 0; SizeValueType noOfClasses = static_cast< SizeValueType >( m_Targets.size() ); for ( i = 0; i < noOfClasses; i++ ) { if ( m_Targets[i].GetMean() > m_Targets[high].GetMean() ) { high = i; } if ( m_Targets[i].GetMean() < m_Targets[low].GetMean() ) { low = i; } } m_LowerBound = m_Targets[low].GetMean() - 9.0 * m_Targets[low].GetSigma(); m_UpperBound = m_Targets[high].GetMean() + 9.0 * m_Targets[high].GetSigma(); CreateCache(m_LowerBound, m_UpperBound, 1000000); }
false
false
false
false
false
0
ipa_tm_propagate_irr (basic_block entry_block, bitmap new_irr, bitmap old_irr, bitmap exit_blocks) { VEC (basic_block, heap) *bbs; bitmap all_region_blocks; /* If this block is in the old set, no need to rescan. */ if (old_irr && bitmap_bit_p (old_irr, entry_block->index)) return; all_region_blocks = BITMAP_ALLOC (&tm_obstack); bbs = get_tm_region_blocks (entry_block, exit_blocks, NULL, all_region_blocks, false); do { basic_block bb = VEC_pop (basic_block, bbs); bool this_irr = bitmap_bit_p (new_irr, bb->index); bool all_son_irr = false; edge_iterator ei; edge e; /* Propagate up. If my children are, I am too, but we must have at least one child that is. */ if (!this_irr) { FOR_EACH_EDGE (e, ei, bb->succs) { if (!bitmap_bit_p (new_irr, e->dest->index)) { all_son_irr = false; break; } else all_son_irr = true; } if (all_son_irr) { /* Add block to new_irr if it hasn't already been processed. */ if (!old_irr || !bitmap_bit_p (old_irr, bb->index)) { bitmap_set_bit (new_irr, bb->index); this_irr = true; } } } /* Propagate down to everyone we immediately dominate. */ if (this_irr) { basic_block son; for (son = first_dom_son (CDI_DOMINATORS, bb); son; son = next_dom_son (CDI_DOMINATORS, son)) { /* Make sure block is actually in a TM region, and it isn't already in old_irr. */ if ((!old_irr || !bitmap_bit_p (old_irr, son->index)) && bitmap_bit_p (all_region_blocks, son->index)) bitmap_set_bit (new_irr, son->index); } } } while (!VEC_empty (basic_block, bbs)); BITMAP_FREE (all_region_blocks); VEC_free (basic_block, heap, bbs); }
false
false
false
false
false
0