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
glade_project_read_comments (GladeProject *project, GladeXmlNode *root) { GladeProjectPrivate *priv = project->priv; GladeXmlNode *node; /* We only support comments before the root element */ for (node = glade_xml_node_prev_with_comments (root); node; node = glade_xml_node_prev_with_comments (node)) { if (glade_xml_node_is_comment (node)) { gchar *start, *comment = glade_xml_get_content (node); /* Ignore leading spaces */ for (start = comment; *start && g_ascii_isspace (*start); start++); /* Do not load generated with glade comment! */ if (g_str_has_prefix (start, GLADE_XML_COMMENT)) { g_free (comment); continue; } /* Since we are reading in backwards order, * prepending gives us the right order */ priv->comments = g_list_prepend (priv->comments, comment); } } }
false
false
false
false
false
0
convert_iter_to_child_iter (PeasGtkPluginManagerView *view, GtkTreeIter *iter) { if (!view->priv->show_builtin) { GtkTreeModel *model; GtkTreeIter child_iter; model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &child_iter, iter); *iter = child_iter; } }
false
false
false
false
false
0
change_state_cb(GtkWidget *widget, gpointer user_data) { HybridAccount *account; HybridModule *module; HybridIMOps *im_ops; HybridAccountMenuData *data; data = (HybridAccountMenuData*)user_data; account = data->account; module = account->proto; im_ops = module->info->im_ops; if (im_ops->change_state) { account->state = data->presence_state; if (im_ops->change_state(account, data->presence_state)) { hybrid_account_set_state(account, data->presence_state); } } }
false
false
false
false
false
0
ur_string_map_get(ur_string_map* map, const ur_string_map_key_type key, ur_string_map_value_type *value) { if(!ur_string_map_valid(map)) return 0; else { string_list_header* slh = get_string_list_header(map, key); string_elem *elem = string_list_get(slh->list, key); if(elem) { if(value) *value=elem->value; return 1; } else { return 0; } } }
false
false
false
false
false
0
doselect(Object o, Object whichone, int whattype, int fexcept) { char *cp; int i; /* whichone default: return first group member or first member of list */ if (!whichone) { switch (whattype) { case IS_SERIES: if (fexcept) return omitnumberedseries((Series)o, NULL); else return selectnumberedseries((Series)o, NULL); case IS_GROUP: if (fexcept) return omitnumberedgroup((Group)o, NULL); else return selectnumberedgroup((Group)o, NULL); case IS_STRING: if (fexcept) return (Object)omitnumberedstring(o, NULL); else return (Object)selectnumberedstring(o, NULL); case IS_LIST: default: if (fexcept) return (Object)omitnumberedlist((Array)o, NULL); else return (Object)selectnumberedlist((Array)o, NULL); } } /* if user specified a name, select by name. if user specified an int, * select by enumerated member number (this is not series position, which * is a float.) */ if (DXExtractString(whichone, &cp) || DXExtractNthString(whichone, 0, &cp)) { switch (whattype) { case IS_SERIES: case IS_GROUP: if (fexcept) return omitnamedgroup((Group)o, whichone); else return selectnamedgroup((Group)o, whichone); case IS_STRING: DXSetError(ERROR_BAD_PARAMETER, "cannot extract items from a string by name"); return NULL; case IS_LIST: default: DXSetError(ERROR_BAD_PARAMETER, "cannot extract items from a list by name"); return NULL; } } else if (DXQueryParameter(whichone, TYPE_INT, 0, &i)) { switch (whattype) { case IS_SERIES: if (fexcept) return omitnumberedseries((Series)o, whichone); else return selectnumberedseries((Series)o, whichone); case IS_GROUP: if (fexcept) return omitnumberedgroup((Group)o, whichone); else return selectnumberedgroup((Group)o, whichone); case IS_STRING: if (fexcept) return (Object)omitnumberedstring(o, whichone); else return (Object)selectnumberedstring(o, whichone); case IS_LIST: default: if (fexcept) return (Object)omitnumberedlist((Array)o, whichone); else return (Object)selectnumberedlist((Array)o, whichone); } } DXSetError(ERROR_BAD_PARAMETER, "#10051", "which member"); return NULL; }
false
false
false
false
false
0
dump_llist(struct llist *list, void (*dump_func)(void *)) { struct list_elem *el; printf ("Dump of list at %p (length %d):\n", list, list->count); for (el = list->head; NULL != el; el = el->next) dump_func(el->data); }
false
false
false
false
false
0
left(void) { if (editorActivate()==MSTrue) { if (selectedColumn()>0) { clearSelection(); if (selectionMode()==MSMultiple) { lastBlock(selectedRow()); _selectionVector.append(selectedRow()); } selectedColumn(selectedColumn()-1); } } }
false
false
false
false
false
0
soup_request_file_get_content_type (SoupRequest *request) { SoupRequestFile *file = SOUP_REQUEST_FILE (request); if (!file->priv->mime_type) return "application/octet-stream"; return file->priv->mime_type; }
false
false
false
false
false
0
stb0899_dvbs2_get_dmd_status(struct stb0899_state *state, int timeout) { int time = -10, lock = 0, uwp, csm; u32 reg; do { reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_STATUS); dprintk(state->verbose, FE_DEBUG, 1, "DMD_STATUS=[0x%02x]", reg); if (STB0899_GETFIELD(IF_AGC_LOCK, reg)) dprintk(state->verbose, FE_DEBUG, 1, "------------->IF AGC LOCKED !"); reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_STAT2); dprintk(state->verbose, FE_DEBUG, 1, "----------->DMD STAT2=[0x%02x]", reg); uwp = STB0899_GETFIELD(UWP_LOCK, reg); csm = STB0899_GETFIELD(CSM_LOCK, reg); if (uwp && csm) lock = 1; time += 10; msleep(10); } while ((!lock) && (time <= timeout)); if (lock) { dprintk(state->verbose, FE_DEBUG, 1, "----------------> DVB-S2 LOCK !"); return DVBS2_DEMOD_LOCK; } else { return DVBS2_DEMOD_NOLOCK; } }
false
false
false
false
false
0
qualifyCompoundTag (const statementInfo *const st, const tokenInfo *const nameToken) { if (isType (nameToken, TOKEN_NAME)) { const tagType type = declToTagType (st->declaration); const boolean fileScoped = (boolean) (!(isLanguage (Lang_java) || isLanguage (Lang_csharp) || isLanguage (Lang_vera))); if (type != TAG_UNDEFINED) makeTag (nameToken, st, fileScoped, type); } }
false
false
false
false
false
0
isPad (asCell) char *asCell; { char *i, *ext; ext = NULL; for(i = asCell; *i != (char)0; i++) if (*i == '_') ext = i; if (ext == NULL) return (FALSE); if (strcmp (ext, "_sp")) return (FALSE); return (TRUE); }
false
false
false
false
false
0
libsmtp_int_send_quoted_header (const char *header, char *libsmtp_int_data, unsigned int libsmtp_int_length, struct libsmtp_session_struct *libsmtp_session) { /* These are the input buffer and the output buffer */ char libsmtp_int_ogroup[2056], libsmtp_int_obuffer[4]; unsigned char libsmtp_int_char; //unsigned char libsmtp_int_last_char; int libsmtp_int_finished=0, libsmtp_int_outbytes=0, libsmtp_int_width=0; /* This points into the data stream to the byte we are reading ATM */ unsigned int libsmtp_int_data_ptr=0; int len; /* Lets clear the buffers */ bzero (libsmtp_int_obuffer, 4); bzero (libsmtp_int_ogroup, 2056); libsmtp_int_char = 0; /* Adds the header name */ libsmtp_int_outbytes = sprintf(libsmtp_int_ogroup, "%s =?utf-8?q?", header); libsmtp_int_width = libsmtp_int_outbytes; /* The main parsing loop */ while (!libsmtp_int_finished) { /* We fetch a character from the input buffer */ //libsmtp_int_last_char = libsmtp_int_char; libsmtp_int_char = libsmtp_int_data[libsmtp_int_data_ptr++]; libsmtp_int_obuffer[0] = 0; len = 1; if (libsmtp_int_char == 32) libsmtp_int_char = '_'; else if (libsmtp_int_char < 33 || libsmtp_int_char > 126 || libsmtp_int_char == '_' || libsmtp_int_char == '=' || libsmtp_int_char == '?') len = sprintf(libsmtp_int_obuffer, "=%02X", libsmtp_int_char); if (libsmtp_int_char >= 128) len += (_utf8_char_length[libsmtp_int_char] - 1) * 3; /* After LINELEN characters in a line we need a soft linebreak */ if ((libsmtp_int_width + len) >= LINELEN) { libsmtp_int_outbytes += sprintf(&libsmtp_int_ogroup[libsmtp_int_outbytes], "?=\r\n"); libsmtp_int_width = sprintf(&libsmtp_int_ogroup[libsmtp_int_outbytes], " =?utf-8?q?"); libsmtp_int_outbytes += libsmtp_int_width; } /* Lets see ... */ if (libsmtp_int_obuffer[0]) { /* Something encoded */ strcpy(&libsmtp_int_ogroup[libsmtp_int_outbytes], libsmtp_int_obuffer); libsmtp_int_outbytes += 3; libsmtp_int_width += 3; #ifdef LIBSMTP_QUOTED_DEBUG printf ("Got encoded: %c = %s. Group: %s (%d)\n", libsmtp_int_char, libsmtp_int_obuffer, libsmtp_int_ogroup, libsmtp_int_outbytes); #endif } else { /* An unencoded character is added */ libsmtp_int_ogroup[libsmtp_int_outbytes] = libsmtp_int_char; libsmtp_int_ogroup[libsmtp_int_outbytes + 1] = 0; libsmtp_int_outbytes++; libsmtp_int_width++; #ifdef LIBSMTP_QUOTED_DEBUG printf ("Got unencoded: %c = %s. Group: %s (%d)\n", libsmtp_int_char, libsmtp_int_obuffer, libsmtp_int_ogroup, libsmtp_int_outbytes); #endif } /* Lets check that we don't read over the end of the input buffer */ if (libsmtp_int_data_ptr >= libsmtp_int_length) { libsmtp_int_finished = TRUE; libsmtp_int_outbytes += sprintf(&libsmtp_int_ogroup[libsmtp_int_outbytes], "?=\r\n"); } /* If we have more than 2K of data, we send it */ if (libsmtp_int_outbytes >= 2048 || libsmtp_int_finished) { libsmtp_int_ogroup[libsmtp_int_outbytes] = 0; if (libsmtp_int_send_body (libsmtp_int_ogroup, libsmtp_int_outbytes, libsmtp_session)) return LIBSMTP_ERRORSENDFATAL; #ifdef LIBSMTP_DEBUG printf ("libsmtp_send_quoted: out: %s\n", libsmtp_int_ogroup); #endif /* We reset the pointer into our outbuffer, too */ libsmtp_int_outbytes=0; } } return LIBSMTP_NOERR; }
true
true
false
false
false
1
GetAllChildren( ConstChildrenListType& output ) const { for ( IdentifierType i = 0; i < static_cast<IdentifierType>(this->GetNumberOfChildren()); i++ ) { const DOMNode* node = this->GetChild( i ); output.push_back( node ); } }
false
false
false
false
false
0
prepareForJobSubmissions(fxStr& emsg) { if (senderName == "" && !setupSenderIdentity(from, emsg)) return (false); /* * Prepare documents for transmission. */ if (typeRules == NULL) { typeRules = TypeRules::read(typeRulesFile); if (!typeRules) { emsg = NLS::TEXT("Unable to setup file typing and conversion rules"); return (false); } } typeRules->setVerbose(verbose); if (dialRules == NULL) { dialRules = new DialStringRules(dialRulesFile); dialRules->setVerbose(verbose); /* * NB: Not finding a client-side dialrules file is not fatal; it * used to generate a warning message but so many people were * confused by this that the message has been removed so I no * longer have to explain why it's not a problem. */ (void) dialRules->parse(false); } else dialRules->setVerbose(verbose); /* * Lock down job page size information. */ u_int i, n; for (i = 0, n = jobs->length(); i < n; i++) { SendFaxJob& job = (*jobs)[i]; if (job.getPageWidth() != 0 && job.getPageLength() != 0) continue; if (!job.setPageSize(job.getPageSize())) { emsg = NLS::TEXT("Unknown page size ") | job.getPageSize(); return (false); } } /* * NB: Not (currently) smart enough to recognize when * documents need to be reprocessed. For now we * just assume document conversions are not affected * by job state changes. */ totalPages = 0; for (i = 0, n = files->length(); i < n; i++) if (!prepareFile((*files)[i], emsg)) return (false); /* * Prepare cover pages. */ for (i = 0, n = jobs->length(); i < n; i++) { SendFaxJob& job = (*jobs)[i]; /* * Convert dialstrings to a displayable format. This * deals with problems like calling card access codes * getting stuck on the cover sheet and/or displayed in * status messages. */ job.setExternalNumber(dialRules->displayNumber(job.getDialString())); /* * Suppress the cover page if we're just doing a poll; * otherwise, generate a cover sheet for each destination * This done now so that we can be sure everything is ready * to send before we setup a connection to the server. */ if (job.getAutoCoverPage() && getNumberOfFiles() > 0) { fxStr file; if (!makeCoverPage(job, file, emsg)) return (false); job.setCoverPageFile(file, true); } } return (setup = true); }
false
false
false
false
false
0
update_cbp_model(jxr_image_t image, int c1, int norig) { const int ndiff = 3; struct cbp_model_s*hp_cbp_model = & (image->hp_cbp_model); hp_cbp_model->count0[c1] += norig - ndiff; SAT(hp_cbp_model->count0[c1]); hp_cbp_model->count1[c1] += 16 - norig - ndiff; SAT(hp_cbp_model->count1[c1]); if (hp_cbp_model->count0[c1] < 0) { if (hp_cbp_model->count0[c1] < hp_cbp_model->count1[c1]) hp_cbp_model->state[c1] = 1; else hp_cbp_model->state[c1] = 2; } else if (hp_cbp_model->count1[c1] < 0) { hp_cbp_model->state[c1] = 2; } else { hp_cbp_model->state[c1] = 0; } }
false
false
false
false
false
0
subroutine_add_call_site(struct subroutine *sub, const unsigned char *code, unsigned long call_site) { unsigned long *new_tab; int new_size; new_size = (sub->nr_call_sites + 1) * sizeof(unsigned long); new_tab = realloc(sub->call_sites, new_size); if (!new_tab) return warn("out of memory"), -ENOMEM; sub->call_sites = new_tab; sub->call_sites[sub->nr_call_sites++] = call_site; sub->call_sites_total_size += bc_insn_size(code, call_site); return 0; }
false
false
false
false
false
0
sge_setup_qmaster(sge_gdi_ctx_class_t *ctx, char* anArgv[]) { char err_str[1024]; const char *qualified_hostname = ctx->get_qualified_hostname(ctx); const char *act_qmaster_file = ctx->get_act_qmaster_file(ctx); DENTER(TOP_LAYER, "sge_setup_qmaster"); umask(022); /* this needs a better solution */ process_cmdline(anArgv); INFO((SGE_EVENT, MSG_STARTUP_BEGINWITHSTARTUP)); qmaster_unlock(QMASTER_LOCK_FILE); if (write_qm_name(qualified_hostname, act_qmaster_file, err_str)) { ERROR((SGE_EVENT, "%s\n", err_str)); SGE_EXIT(NULL, 1); } qmaster_init(ctx, anArgv); sge_write_pid(QMASTER_PID_FILE); DEXIT; return 0; }
true
true
false
false
true
1
panel_real_focus_out (IBusPanelService* base, const gchar* input_context_path) { Panel * self; gboolean _tmp0_ = FALSE; gboolean _tmp1_ = FALSE; gchar* _tmp2_ = NULL; self = (Panel*) base; g_return_if_fail (input_context_path != NULL); _tmp0_ = self->priv->m_use_global_engine; if (_tmp0_) { return; } _tmp1_ = self->priv->m_switcher_is_running; if (_tmp1_) { return; } _tmp2_ = g_strdup (""); _g_free0 (self->priv->m_current_context_path); self->priv->m_current_context_path = _tmp2_; }
false
false
false
false
false
0
getDbgValue(MDNode *MDPtr, const Value *C, uint64_t Off, DebugLoc DL, unsigned O) { return new (Allocator) SDDbgValue(MDPtr, C, Off, DL, O); }
false
false
false
false
false
0
format_cpu_data(CpuMon *cpu, gchar *src_string, gchar *buf, gint size) { GkrellmChart *cp; gchar c, *s; gint len, sys, user, nice = 0, total, t; if (!buf || size < 1) return; --size; *buf = '\0'; if (!src_string) return; cp = cpu->chart; sys = gkrellm_get_current_chartdata(cpu->sys_cd); user = gkrellm_get_current_chartdata(cpu->user_cd); total = sys + user; if (!nice_time_unsupported) { nice = gkrellm_get_current_chartdata(cpu->nice_cd); if (!omit_nice_mode && !gkrellm_get_chartdata_hide(cpu->nice_cd)) total += nice; } for (s = src_string; *s != '\0' && size > 0; ++s) { len = 1; if (*s == '$' && *(s + 1) != '\0') { t = -1; if ((c = *(s + 1)) == 'T') t = total; else if (c == 's') t = sys; else if (c == 'u') t = user; else if (c == 'n') t = nice; else if (c == 'L') len = snprintf(buf, size, "%s", cp->panel->label->string); else if (c == 'H') len = snprintf(buf, size, "%s", gkrellm_sys_get_host_name()); else { *buf = *s; if (size > 1) { *(buf + 1) = *(s + 1); ++len; } } if (t >= 0) { /* ChartData values have been scaled to the chart max scale | of CPU_TICKS_PER_SECOND. */ t = ((200 * t / CPU_TICKS_PER_SECOND) + 1) / 2; if (t > 100) t = 100; len = snprintf(buf, size, "%d%%", t); } ++s; } else *buf = *s; size -= len; buf += len; } *buf = '\0'; }
false
false
false
false
false
0
knot_tsig_create_key(const char *name, int algorithm, const char *b64secret, knot_tsig_key_t *key) { if (!name || !b64secret || !key) { return KNOT_EINVAL; } knot_dname_t *dname; dname = knot_dname_from_str(name); if (!dname) { return KNOT_ENOMEM; } knot_binary_t secret; int result = knot_binary_from_base64(b64secret, &secret); if (result != KNOT_EOK) { knot_dname_free(&dname); return result; } key->name = dname; key->algorithm = algorithm; key->secret = secret; return KNOT_EOK; }
false
false
false
false
false
0
thrmgr_setactivetask(const char *filename, const char* cmd) { struct task_desc *desc; pthread_once(&stats_tls_key_once, stats_tls_key_alloc); desc = pthread_getspecific(stats_tls_key); if(!desc) return; desc->filename = filename; if(cmd) { if(cmd == IDLE_TASK && desc->command == cmd) return; desc->command = cmd; gettimeofday(&desc->tv, NULL); } }
false
false
false
false
false
0
parse_syntax_error(PyObject *err, PyObject **message, const char **filename, int *lineno, int *offset, const char **text) { long hold; PyObject *v; _Py_IDENTIFIER(msg); _Py_IDENTIFIER(filename); _Py_IDENTIFIER(lineno); _Py_IDENTIFIER(offset); _Py_IDENTIFIER(text); *message = NULL; /* new style errors. `err' is an instance */ *message = _PyObject_GetAttrId(err, &PyId_msg); if (!*message) goto finally; v = _PyObject_GetAttrId(err, &PyId_filename); if (!v) goto finally; if (v == Py_None) { Py_DECREF(v); *filename = NULL; } else { *filename = _PyUnicode_AsString(v); Py_DECREF(v); if (!*filename) goto finally; } v = _PyObject_GetAttrId(err, &PyId_lineno); if (!v) goto finally; hold = PyLong_AsLong(v); Py_DECREF(v); if (hold < 0 && PyErr_Occurred()) goto finally; *lineno = (int)hold; v = _PyObject_GetAttrId(err, &PyId_offset); if (!v) goto finally; if (v == Py_None) { *offset = -1; Py_DECREF(v); } else { hold = PyLong_AsLong(v); Py_DECREF(v); if (hold < 0 && PyErr_Occurred()) goto finally; *offset = (int)hold; } v = _PyObject_GetAttrId(err, &PyId_text); if (!v) goto finally; if (v == Py_None) { Py_DECREF(v); *text = NULL; } else { *text = _PyUnicode_AsString(v); Py_DECREF(v); if (!*text) goto finally; } return 1; finally: Py_XDECREF(*message); return 0; }
false
false
false
false
false
0
Scm_MakeBignumFromDouble(double val) { int exponent, sign; ScmObj mantissa, b; if (val >= LONG_MIN && val <= LONG_MAX) { return Scm_MakeBignumFromSI((long)val); } mantissa = Scm_DecodeFlonum(val, &exponent, &sign); if (!SCM_NUMBERP(mantissa)) { Scm_Error("can't convert %lf to an integer", val); } b = Scm_Ash(mantissa, exponent); if (sign < 0) b = Scm_Negate(b); /* always returns bignum */ if (SCM_INTP(b)) { return Scm_MakeBignumFromSI(SCM_INT_VALUE(b)); } else { return b; } }
false
false
false
false
false
0
appParamsUnsigned32_get(dessertAppParamsTable_rowreq_ctx * rowreq_ctx, u_long * appParamsUnsigned32_val_ptr) { /** we should have a non-NULL pointer */ netsnmp_assert(NULL != appParamsUnsigned32_val_ptr); DEBUGMSGTL(("verbose:dessertAppParamsTable:appParamsUnsigned32_get", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:231:o: |-> Extract the current value of the appParamsUnsigned32 data. * copy (* appParamsUnsigned32_val_ptr ) from rowreq_ctx->data */ (*appParamsUnsigned32_val_ptr) = rowreq_ctx->data.appParamsUnsigned32; return MFD_SUCCESS; }
false
false
false
true
false
1
pthread_stop_world() { #ifndef NACL int i; int n_live_threads; int code; #if DEBUG_THREADS GC_printf1("Stopping the world from 0x%lx\n", pthread_self()); #endif n_live_threads = GC_suspend_all(); if (GC_retry_signals) { unsigned long wait_usecs = 0; /* Total wait since retry. */ # define WAIT_UNIT 3000 # define RETRY_INTERVAL 100000 for (;;) { int ack_count; sem_getvalue(&GC_suspend_ack_sem, &ack_count); if (ack_count == n_live_threads) break; if (wait_usecs > RETRY_INTERVAL) { int newly_sent = GC_suspend_all(); # ifdef CONDPRINT if (GC_print_stats) { GC_printf1("Resent %ld signals after timeout\n", newly_sent); } # endif sem_getvalue(&GC_suspend_ack_sem, &ack_count); if (newly_sent < n_live_threads - ack_count) { WARN("Lost some threads during GC_stop_world?!\n",0); n_live_threads = ack_count + newly_sent; } wait_usecs = 0; } usleep(WAIT_UNIT); wait_usecs += WAIT_UNIT; } } for (i = 0; i < n_live_threads; i++) { while (0 != (code = sem_wait(&GC_suspend_ack_sem))) { if (errno != EINTR) { GC_err_printf1("Sem_wait returned %ld\n", (unsigned long)code); ABORT("sem_wait for handler failed"); } } } #if DEBUG_THREADS GC_printf1("World stopped from 0x%lx\n", pthread_self()); #endif GC_stopping_thread = 0; /* debugging only */ #else /* NACL */ GC_thread p; int i; int num_sleeps = 0; #if DEBUG_THREADS GC_printf1("pthread_stop_world: num_threads %d\n", nacl_num_gc_threads - 1); #endif nacl_thread_parker = pthread_self(); __nacl_thread_suspension_needed = 1; while (1) { #define NACL_PARK_WAIT_NANOSECONDS 100000 #define NANOS_PER_SECOND 1000000000 int num_threads_parked = 0; struct timespec ts; int num_used = 0; /* Check the 'parked' flag for each thread the GC knows about */ for (i = 0; i < MAX_NACL_GC_THREADS && num_used < nacl_num_gc_threads; i++) { if (nacl_thread_used[i] == 1) { num_used++; if (nacl_thread_parked[i] == 1) { num_threads_parked++; } } } /* -1 for the current thread */ if (num_threads_parked >= nacl_num_gc_threads - 1) break; ts.tv_sec = 0; ts.tv_nsec = NACL_PARK_WAIT_NANOSECONDS; #if DEBUG_THREADS GC_printf1("sleeping waiting for %d threads to park...\n", nacl_num_gc_threads - num_threads_parked - 1); #endif nanosleep(&ts, 0); if (++num_sleeps > NANOS_PER_SECOND / NACL_PARK_WAIT_NANOSECONDS) { GC_printf1("GC appears stalled waiting for %d threads to park...\n", nacl_num_gc_threads - num_threads_parked - 1); num_sleeps = 0; } } #endif /* NACL */ }
false
true
false
false
true
1
free_sched_data(void *data) { struct sched_data *sched_data = (struct sched_data *) data; if (sched_data) { if (sched_data->itip) icalcomponent_free(sched_data->itip); if (sched_data->force_send) free(sched_data->force_send); free(sched_data); } }
false
false
false
false
false
0
Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen) { int i, j, k; u32 data, datal, datar; for (i = 0; i < 4; i++) { for (j = 0; j < 256; j++) ctx->S[i][j] = ORIG_S[i][j]; } j = 0; for (i = 0; i < N + 2; ++i) { data = 0x00000000; for (k = 0; k < 4; ++k) { data = (data << 8) | key[j]; j = j + 1; if (j >= keyLen) j = 0; } ctx->P[i] = ORIG_P[i] ^ data; } datal = 0x00000000; datar = 0x00000000; for (i = 0; i < N + 2; i += 2) { Blowfish_Encrypt(ctx, &datal, &datar); ctx->P[i] = datal; ctx->P[i + 1] = datar; } for (i = 0; i < 4; ++i) { for (j = 0; j < 256; j += 2) { Blowfish_Encrypt(ctx, &datal, &datar); ctx->S[i][j] = datal; ctx->S[i][j + 1] = datar; } } }
false
false
false
false
false
0
setObjectAt(int x, int y, Object &o) { if (x < 0 || x >= m_width || y < 0 || y >= m_height) { kDebug() << "Inexistent place accessed: (" << x << ", " << y << ")"; return; } m_playfield[x * m_height + y] = o; o.setCoordinates(x, y); }
false
false
false
false
false
0
flps_pieslice( int fill, int x, int y, int w, int h, int t1, int t2, FL_COLOR col ) { float sx = 1.0, sy = ( float ) h / w; flps_color( col ); flps_output( "gsave newpath %.1f %.1f translate %.1f %.1f scale\n", x + 0.5f * w, y + 0.5f * h, sx, sy ); if ( ! fill ) flps_output( "0 0 %.1f %.1f %.1f arc S grestore\n", w * 0.5, t1 * 0.1, t2 * 0.1 ); else flps_output( "0 0 M 0 0 %.1f %.1f %.1f arc C F grestore\n", w * 0.5, t1 * 0.1, t2 * 0.1 ); flps_invalidate_color_cache( ); }
false
false
false
false
false
0
__place_get_placement_flags( pl_flags_t *ret_flags, FvwmWindow *fw, window_style *pstyle, initial_window_options_t *win_opts, int mode, pl_reason_t *reason) { Bool override_ppos; Bool override_uspos; Bool has_ppos = False; Bool has_uspos = False; /* Windows use the position hint if these conditions are met: * * The program specified a USPosition hint and it is not overridden * with the No(Transient)USPosition style. * * OR * * The program specified a PPosition hint and it is not overridden * with the No(Transient)PPosition style. * * Windows without a position hint are placed using wm placement. */ if (IS_TRANSIENT(fw)) { override_ppos = SUSE_NO_TRANSIENT_PPOSITION(&pstyle->flags); override_uspos = SUSE_NO_TRANSIENT_USPOSITION(&pstyle->flags); } else { override_ppos = SUSE_NO_PPOSITION(&pstyle->flags); override_uspos = SUSE_NO_USPOSITION(&pstyle->flags); } if (fw->hints.flags & PPosition) { if (!override_ppos) { has_ppos = True; reason->pos.reason = PR_POS_USE_PPOS; } else { reason->pos.reason = PR_POS_IGNORE_PPOS; } } if (fw->hints.flags & USPosition) { if (!override_uspos) { has_uspos = True; reason->pos.reason = PR_POS_USE_USPOS; } else if (reason->pos.reason != PR_POS_USE_PPOS) { reason->pos.reason = PR_POS_IGNORE_USPOS; } } if (mode == PLACE_AGAIN) { ret_flags->do_not_use_wm_placement = 0; reason->pos.reason = PR_POS_PLACE_AGAIN; } else if (has_ppos || has_uspos) { ret_flags->do_not_use_wm_placement = 1; } else if (win_opts->flags.do_override_ppos) { ret_flags->do_not_use_wm_placement = 1; reason->pos.reason = PR_POS_CAPTURE; } else if (!ret_flags->do_honor_starts_on_page && fw->wmhints && (fw->wmhints->flags & StateHint) && fw->wmhints->initial_state == IconicState) { ret_flags->do_forbid_manual_placement = 1; reason->pos.do_not_manual_icon_placement = 1; } return; }
false
false
false
false
false
0
DrucChercheWindow ( TmpRectangleSource ) rdsrec_list *TmpRectangleSource; { static rdsrecwin_list StaticWindowSource2; if ( IsRdsOneWindow( TmpRectangleSource ) ) { StaticWindowSource2.WINDOW = (rdswin_list *)TmpRectangleSource->USER; StaticWindowSource2.NEXT = (rdsrecwin_list *) NULL; return ( & StaticWindowSource2 ); } else { return (rdsrecwin_list *)TmpRectangleSource->USER; } }
false
false
false
false
false
0
storeCompressedFrame(DcmOffsetList &offsetList, Uint8 *compressedData, Uint32 compressedLen, Uint32 fragmentSize) { if (compressedData == NULL) return EC_IllegalCall; OFCondition result = EC_Normal; if (fragmentSize >= 0x400000) fragmentSize = 0; // prevent overflow else fragmentSize <<= 10; // unit is kbytes if (fragmentSize == 0) fragmentSize = compressedLen; Uint32 offset = 0; Uint32 currentSize = 0; Uint32 numFragments = 0; DcmPixelItem *fragment = NULL; while ((offset < compressedLen) && (result.good())) { fragment = new DcmPixelItem(DcmTag(DCM_Item, EVR_OB)); if (fragment == NULL) result = EC_MemoryExhausted; else { insert(fragment); numFragments++; currentSize = fragmentSize; if (offset + currentSize > compressedLen) currentSize = compressedLen - offset; // if currentSize is odd this will be fixed during DcmOtherByteOtherWord::write() result = fragment->putUint8Array(compressedData + offset, currentSize); if (result.good()) offset += currentSize; } } currentSize = offset + (numFragments << 3); // 8 bytes extra for each item header // odd frame size requires padding, i.e. last fragment uses odd length pixel item if (currentSize & 1) currentSize++; offsetList.push_back(currentSize); return result; }
false
false
false
false
false
0
ExtractAnds( void *theEnv, struct lhsParseNode *andField, int testInPatternNetwork, struct expr **patternNetTest, struct expr **joinNetTest) { struct expr *newPNTest, *newJNTest; /*=================================================*/ /* Before starting, the subfield has no pattern or */ /* join network expressions associated with it. */ /*=================================================*/ *patternNetTest = NULL; *joinNetTest = NULL; /*=========================================*/ /* Loop through each of the subfields tied */ /* together by the & constraint. */ /*=========================================*/ for (; andField != NULL; andField = andField->right) { /*======================================*/ /* Extract the pattern and join network */ /* expressions from the subfield. */ /*======================================*/ ExtractFieldTest(theEnv,andField,testInPatternNetwork,&newPNTest,&newJNTest); /*=================================================*/ /* Add the new expressions to the list of pattern */ /* and join network expressions being constructed. */ /*=================================================*/ *patternNetTest = CombineExpressions(theEnv,*patternNetTest,newPNTest); *joinNetTest = CombineExpressions(theEnv,*joinNetTest,newJNTest); } }
false
false
false
false
false
0
tillToken (vString * const UNUSED (ident), objcToken what) { if (what == waitedToken) toDoNext = comeAfter; }
false
false
false
false
false
0
statusbar_item_register(const char *name, const char *value, STATUSBAR_FUNC func) { gpointer hkey, hvalue; statusbar_need_recreate_items = TRUE; if (value != NULL) { if (g_hash_table_lookup_extended(sbar_item_defs, name, &hkey, &hvalue)) { g_hash_table_remove(sbar_item_defs, name); g_free(hkey); g_free(hvalue); } g_hash_table_insert(sbar_item_defs, g_strdup(name), g_strdup(value)); } if (func != NULL) { if (g_hash_table_lookup(sbar_item_funcs, name) == NULL) { g_hash_table_insert(sbar_item_funcs, g_strdup(name), (void *) func); } } }
false
false
false
false
false
0
atc_pcm_playback_position(struct ct_atc *atc, struct ct_atc_pcm *apcm) { struct src *src = apcm->src; u32 size, max_cisz; int position; if (!src) return 0; position = src->ops->get_ca(src); if (position < apcm->vm_block->addr) { dev_dbg(atc->card->dev, "bad ca - ca=0x%08x, vba=0x%08x, vbs=0x%08x\n", position, apcm->vm_block->addr, apcm->vm_block->size); position = apcm->vm_block->addr; } size = apcm->vm_block->size; max_cisz = src->multi * src->rsc.msr; max_cisz = 128 * (max_cisz < 8 ? max_cisz : 8); return (position + size - max_cisz - apcm->vm_block->addr) % size; }
false
false
false
false
false
0
get_block(size_t size) { #ifdef HAVE_MMAP void *ptr = NULL; #ifndef MAP_ANON ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, dpfd.fd, 0); #else ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); #endif return ptr == MAP_FAILED ? NULL : ptr; #else return malloc(size); #endif }
false
false
false
false
false
0
instituteDestroyP ( void * instituteptr ) { int id; institute_t * i1 = ( institute_t * ) instituteptr; xassert ( i1 ); id = i1->self; if ( instituteptr ) free ( instituteptr ); reshRemove ( id, &instituteOps ); }
false
false
false
false
false
0
fastaannotatecdna(gchar *cdna_path, gchar *protein_path){ register FastaDB *cdna_fdb, *protein_fdb; register FastaDB_Seq *cdna = NULL, *protein = NULL; register gint ret_val = 0, total; register FastaDB_Mask mask = FastaDB_Mask_ID|FastaDB_Mask_SEQ; register Sequence *rc_seq; register gchar *protein_str; register Translate *translate = Translate_create(FALSE); register Alphabet *cdna_alphabet = Alphabet_create(Alphabet_Type_DNA, FALSE), *protein_alphabet = Alphabet_create(Alphabet_Type_PROTEIN, FALSE); cdna_fdb = FastaDB_open(cdna_path, cdna_alphabet); protein_fdb = FastaDB_open(protein_path, protein_alphabet); while((cdna = FastaDB_next(cdna_fdb, mask))){ protein = FastaDB_next(protein_fdb, mask); if(!protein){ g_print("ERROR: fastaannotatecdna: %s: protein: %s is absent\n", protein_path, cdna->seq->id); ret_val = 1; break; } if((protein->seq->len*3) > cdna->seq->len) g_print("ERROR: fastaannoatecdna: protein [%s](%d) too long for cdna [%s](%d)\n", protein->seq->id, protein->seq->len, cdna->seq->id, cdna->seq->len); protein_str = Sequence_get_str(protein->seq); /* forward */ total = find_translation(protein_str, protein->seq->len, cdna->seq, translate); /* revcomp */ rc_seq = Sequence_revcomp(cdna->seq); total += find_translation(protein_str, protein->seq->len, rc_seq, translate); if(total != 1){ g_print("ERROR: fastaannoatecdna: Found %d locations for protein [%s] in [%s]\n", total, protein->seq->id, cdna->seq->id); ret_val = 1; break; } Sequence_destroy(rc_seq); /**/ g_free(protein_str); FastaDB_Seq_destroy(cdna); FastaDB_Seq_destroy(protein); cdna = protein = NULL; } if(cdna) FastaDB_Seq_destroy(cdna); if(protein) FastaDB_Seq_destroy(protein); if(ret_val == 0){ protein = FastaDB_next(protein_fdb, mask); if(protein){ g_print("ERROR: fastaannoatecdna: %s: cdna: %s absent\n", cdna_path, protein->seq->id); ret_val = 1; FastaDB_Seq_destroy(protein); } } FastaDB_close(cdna_fdb); FastaDB_close(protein_fdb); Translate_destroy(translate); Alphabet_destroy(cdna_alphabet); Alphabet_destroy(protein_alphabet); return ret_val; }
false
false
false
false
false
0
hostiles_close_one(hostiles_t which) { uint i = which; g_assert(i < NUM_HOSTILES); iprange_free(&hostile_db[i]); }
false
false
false
false
false
0
tree_child(struct tree *tree, const char *label) { if (tree == NULL) return NULL; list_for_each(child, tree->children) { if (streqv(label, child->label)) return child; } return NULL; }
false
false
false
false
false
0
debugInt(string debugString, int value) { debugInt("DEBUG", debugString, value); }
false
false
false
false
false
0
SetColorTable( GDALColorTable *poCT ) { if( !CheckForColorTable() ) return CE_Failure; // no color tables on overviews. if( poFile == NULL ) return CE_Failure; try { /* -------------------------------------------------------------------- */ /* Are we trying to delete the color table? */ /* -------------------------------------------------------------------- */ if( poCT == NULL ) { delete poColorTable; poColorTable = NULL; if( nPCTSegNumber != -1 ) poFile->DeleteSegment( nPCTSegNumber ); poChannel->SetMetadataValue( "DEFAULT_PCT_REF", "" ); nPCTSegNumber = -1; return CE_None; } /* -------------------------------------------------------------------- */ /* Do we need to create the segment? If so, also set the */ /* default pct metadata. */ /* -------------------------------------------------------------------- */ if( nPCTSegNumber == -1 ) { nPCTSegNumber = poFile->CreateSegment( "PCTTable", "Default Pseudo-Color Table", SEG_PCT, 0 ); CPLString osRef; osRef.Printf( "gdb:/{PCT:%d}", nPCTSegNumber ); poChannel->SetMetadataValue( "DEFAULT_PCT_REF", osRef ); } /* -------------------------------------------------------------------- */ /* Write out the PCT. */ /* -------------------------------------------------------------------- */ unsigned char abyPCT[768]; int i, nColorCount = MIN(256,poCT->GetColorEntryCount()); memset( abyPCT, 0, 768 ); for( i = 0; i < nColorCount; i++ ) { GDALColorEntry sEntry; poCT->GetColorEntryAsRGB( i, &sEntry ); abyPCT[256 * 0 + i] = (unsigned char) sEntry.c1; abyPCT[256 * 1 + i] = (unsigned char) sEntry.c2; abyPCT[256 * 2 + i] = (unsigned char) sEntry.c3; } PCIDSK_PCT *poPCT = dynamic_cast<PCIDSK_PCT*>( poFile->GetSegment( nPCTSegNumber ) ); poPCT->WritePCT( abyPCT ); delete poColorTable; poColorTable = poCT->Clone(); } /* -------------------------------------------------------------------- */ /* Trap exceptions. */ /* -------------------------------------------------------------------- */ catch( PCIDSKException ex ) { CPLError( CE_Failure, CPLE_AppDefined, "%s", ex.what() ); return CE_Failure; } return CE_None; }
false
false
false
false
false
0
searchc(cap, t_cmd) cmdarg_T *cap; int t_cmd; { int c = cap->nchar; /* char to search for */ int dir = cap->arg; /* TRUE for searching forward */ long count = cap->count1; /* repeat count */ static int lastc = NUL; /* last character searched for */ static int lastcdir; /* last direction of character search */ static int last_t_cmd; /* last search t_cmd */ int col; char_u *p; int len; #ifdef FEAT_MBYTE static char_u bytes[MB_MAXBYTES]; static int bytelen = 1; /* >1 for multi-byte char */ #endif if (c != NUL) /* normal search: remember args for repeat */ { if (!KeyStuffed) /* don't remember when redoing */ { lastc = c; lastcdir = dir; last_t_cmd = t_cmd; #ifdef FEAT_MBYTE bytelen = (*mb_char2bytes)(c, bytes); if (cap->ncharC1 != 0) { bytelen += (*mb_char2bytes)(cap->ncharC1, bytes + bytelen); if (cap->ncharC2 != 0) bytelen += (*mb_char2bytes)(cap->ncharC2, bytes + bytelen); } #endif } } else /* repeat previous search */ { if (lastc == NUL) return FAIL; if (dir) /* repeat in opposite direction */ dir = -lastcdir; else dir = lastcdir; t_cmd = last_t_cmd; c = lastc; /* For multi-byte re-use last bytes[] and bytelen. */ } if (dir == BACKWARD) cap->oap->inclusive = FALSE; else cap->oap->inclusive = TRUE; p = ml_get_curline(); col = curwin->w_cursor.col; len = (int)STRLEN(p); while (count--) { #ifdef FEAT_MBYTE if (has_mbyte) { for (;;) { if (dir > 0) { col += (*mb_ptr2len)(p + col); if (col >= len) return FAIL; } else { if (col == 0) return FAIL; col -= (*mb_head_off)(p, p + col - 1) + 1; } if (bytelen == 1) { if (p[col] == c) break; } else { if (vim_memcmp(p + col, bytes, bytelen) == 0) break; } } } else #endif { for (;;) { if ((col += dir) < 0 || col >= len) return FAIL; if (p[col] == c) break; } } } if (t_cmd) { /* backup to before the character (possibly double-byte) */ col -= dir; #ifdef FEAT_MBYTE if (has_mbyte) { if (dir < 0) /* Landed on the search char which is bytelen long */ col += bytelen - 1; else /* To previous char, which may be multi-byte. */ col -= (*mb_head_off)(p, p + col); } #endif } curwin->w_cursor.col = col; return OK; }
false
false
false
false
false
0
CopyAttribute(struct Attribute * attrib) { if(attrib) return MkAttribute(__ecereFunction___ecereNameSpace__ecere__sys__CopyString(attrib->attr), CopyExpression(attrib->exp)); return (((void *)0)); }
false
false
false
false
false
0
store_alist_res(LEX *lc, RES_ITEM *item, int index, int pass) { RES *res; int count = item->default_value; int i = 0; alist *list; if (pass == 2) { if (count == 0) { /* always store in item->value */ i = 0; if ((item->value)[i] == NULL) { list = New(alist(10, not_owned_by_alist)); } else { list = (alist *)(item->value)[i]; } } else { /* Find empty place to store this directive */ while ((item->value)[i] != NULL && i++ < count) { } if (i >= count) { scan_err4(lc, _("Too many %s directives. Max. is %d. line %d: %s\n"), lc->str, count, lc->line_no, lc->line); return; } list = New(alist(10, not_owned_by_alist)); } for (;;) { lex_get_token(lc, T_NAME); /* scan next item */ res = GetResWithName(item->code, lc->str); if (res == NULL) { scan_err3(lc, _("Could not find config Resource \"%s\" referenced on line %d : %s\n"), item->name, lc->line_no, lc->line); return; } Dmsg5(900, "Append %p to alist %p size=%d i=%d %s\n", res, list, list->size(), i, item->name); list->append(res); (item->value)[i] = (char *)list; if (lc->ch != ',') { /* if no other item follows */ break; /* get out */ } lex_get_token(lc, T_ALL); /* eat comma */ } } scan_to_eol(lc); set_bit(index, res_all.hdr.item_present); }
false
false
false
false
false
0
_rtl_get_vht_highest_n_rate(struct ieee80211_hw *hw, struct ieee80211_sta *sta) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_phy *rtlphy = &(rtlpriv->phy); u8 hw_rate; u16 tx_mcs_map = le16_to_cpu(sta->vht_cap.vht_mcs.tx_mcs_map); if ((get_rf_type(rtlphy) == RF_2T2R) && (tx_mcs_map & 0x000c) != 0x000c) { if ((tx_mcs_map & 0x000c) >> 2 == IEEE80211_VHT_MCS_SUPPORT_0_7) hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS7]; else if ((tx_mcs_map & 0x000c) >> 2 == IEEE80211_VHT_MCS_SUPPORT_0_8) hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9]; else hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9]; } else { if ((tx_mcs_map & 0x0003) == IEEE80211_VHT_MCS_SUPPORT_0_7) hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS7]; else if ((tx_mcs_map & 0x0003) == IEEE80211_VHT_MCS_SUPPORT_0_8) hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9]; else hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9]; } return hw_rate; }
false
false
false
false
false
0
flush_meta() { HASHHDR *whdrp; int i, wsize; this->MAGIC = HASHMAGIC; this->VERSION = HASHVERSION; this->H_CHARKEY = this->hash(CHARKEY, sizeof(CHARKEY)); FileHandle fp = this->fp; whdrp = &this->hdr; #ifdef OS_WIN SetFilePointer(fp, 0, NULL, FILE_BEGIN); DWORD bytesWrited; if (!WriteFile(fp, whdrp, sizeof(HASHHDR), &bytesWrited, NULL) || bytesWrited != sizeof(HASHHDR)) return -1; #else wsize = pwrite(fp, whdrp, sizeof(HASHHDR), (off_t)0); if (wsize == -1) return (-1); else if (wsize != sizeof(HASHHDR)) { return (-1); } #endif for (i = 0; i < NCACHED; i++) if (this->mapp[i]) if (put_page((char *)this->mapp[i], this->BITMAPS[i], 0, 1)) return (-1); return (0); }
false
false
false
false
false
0
glusterd_get_slave (glusterd_volinfo_t *vol, const char *slaveurl, char **slavekey) { runner_t runner = {0,}; int n = 0; int i = 0; char **linearr = NULL; glusterd_urltransform_init (&runner, "canonicalize"); dict_foreach (vol->gsync_slaves, _glusterd_urltransform_add_iter, &runner); glusterd_urltransform_add (&runner, slaveurl); n = glusterd_urltransform (&runner, &linearr); if (n == -1) return -2; for (i = 0; i < n - 1; i++) { if (strcmp (linearr[i], linearr[n - 1]) == 0) break; } glusterd_urltransform_free (linearr, i); if (i < n - 1) *slavekey = dict_get_by_index (vol->gsync_slaves, i); else i = -1; return i; }
false
false
false
false
false
0
gth_string_list_join (GthStringList *list, const char *separator) { GString *str; GList *scan; str = g_string_new (""); for (scan = list->priv->list; scan; scan = scan->next) { if (scan != list->priv->list) g_string_append (str, separator); g_string_append (str, (char *) scan->data); } return g_string_free (str, FALSE); }
false
false
false
false
false
0
stkdmp (struct stck *stack) { while (stack->pback) stack = stack->pback; while (stack) { if (stack->type==0) { printf ("Operand: %s\n",stack->obj.strng); } else if (stack->type==1) { printf ("Operator: %i \n",stack->obj.op); } else if (stack->type==2) printf ("Left paren '('\n"); else if (stack->type==3) printf ("Right paren ')'\n"); else printf ("Type = %i \n",stack->type); stack = stack->pforw; } }
false
false
false
false
false
0
setupRigidBody(const btRigidBody::btRigidBodyConstructionInfo& constructionInfo) { m_internalType=CO_RIGID_BODY; m_linearVelocity.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); m_angularVelocity.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); m_angularFactor.setValue(1,1,1); m_linearFactor.setValue(1,1,1); m_gravity.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); m_gravity_acceleration.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); m_totalForce.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); m_totalTorque.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)), m_linearDamping = btScalar(0.); m_angularDamping = btScalar(0.5); m_linearSleepingThreshold = constructionInfo.m_linearSleepingThreshold; m_angularSleepingThreshold = constructionInfo.m_angularSleepingThreshold; m_optionalMotionState = constructionInfo.m_motionState; m_contactSolverType = 0; m_frictionSolverType = 0; m_additionalDamping = constructionInfo.m_additionalDamping; m_additionalDampingFactor = constructionInfo.m_additionalDampingFactor; m_additionalLinearDampingThresholdSqr = constructionInfo.m_additionalLinearDampingThresholdSqr; m_additionalAngularDampingThresholdSqr = constructionInfo.m_additionalAngularDampingThresholdSqr; m_additionalAngularDampingFactor = constructionInfo.m_additionalAngularDampingFactor; if (m_optionalMotionState) { m_optionalMotionState->getWorldTransform(m_worldTransform); } else { m_worldTransform = constructionInfo.m_startWorldTransform; } m_interpolationWorldTransform = m_worldTransform; m_interpolationLinearVelocity.setValue(0,0,0); m_interpolationAngularVelocity.setValue(0,0,0); //moved to btCollisionObject m_friction = constructionInfo.m_friction; m_restitution = constructionInfo.m_restitution; setCollisionShape( constructionInfo.m_collisionShape ); m_debugBodyId = uniqueId++; setMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia); setDamping(constructionInfo.m_linearDamping, constructionInfo.m_angularDamping); updateInertiaTensor(); m_rigidbodyFlags = 0; m_deltaLinearVelocity.setZero(); m_deltaAngularVelocity.setZero(); m_invMass = m_inverseMass*m_linearFactor; m_pushVelocity.setZero(); m_turnVelocity.setZero(); }
false
false
false
false
false
0
activate() { if(cur_select_ == list_wb_.end()) return; audio::play_wave (-1, 0); //set_activate(false); (*cur_select_)->set_activate(true); on_activate_key(); }
false
false
false
false
false
0
getTarget() { if (_withStack.empty()) { return getObject(env.target()); } return _withStack.back().object(); }
false
false
false
false
false
0
ParseCloseTag(XMLTreeRoot *root,char *tag, char *magick_unused(xml),ExceptionInfo *exception) { if ((root->node == (XMLTreeInfo *) NULL) || (root->node->tag == (char *) NULL) || (strcmp(tag,root->node->tag) != 0)) { (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, "ParseError","unexpected closing tag </%s>",tag); return(&root->root); } root->node=root->node->parent; return((XMLTreeInfo *) NULL); }
false
false
false
false
false
0
applyPattern(const UnicodeString& pattern, UParseError& parseError, UErrorCode& ec) { if(U_FAILURE(ec)) { return; } // The pattern is broken up into segments. Each time a subformat // is encountered, 4 segments are recorded. For example, consider // the pattern: // "There {0,choice,0.0#are no files|1.0#is one file|1.0<are {0, number} files} on disk {1}." // The first set of segments is: // segments[0] = "There " // segments[1] = "0" // segments[2] = "choice" // segments[3] = "0.0#are no files|1.0#is one file|1.0<are {0, number} files" // During parsing, the plain text is accumulated into segments[0]. // Segments 1..3 are used to parse each subpattern. Each time a // subpattern is parsed, it creates a format object that is stored // in the subformats array, together with an offset and argument // number. The offset into the plain text stored in // segments[0]. // Quotes in segment 0 are handled normally. They are removed. // Quotes may not occur in segments 1 or 2. // Quotes in segment 3 are parsed and _copied_. This makes // subformat patterns work, e.g., {1,number,'#'.##} passes // the pattern "'#'.##" to DecimalFormat. UnicodeString segments[4]; int32_t part = 0; // segment we are in, 0..3 // Record the highest argument number in the pattern. (In the // subpattern {3,number} the argument number is 3.) int32_t formatNumber = 0; UBool inQuote = FALSE; int32_t braceStack = 0; // Clear error struct parseError.offset = -1; parseError.preContext[0] = parseError.postContext[0] = (UChar)0; int32_t patLen = pattern.length(); int32_t i; for (i=0; i<subformatCount; ++i) { delete subformats[i].format; } subformatCount = 0; argTypeCount = 0; for (i=0; i<patLen; ++i) { UChar ch = pattern[i]; if (part == 0) { // In segment 0, recognize and remove quotes if (ch == SINGLE_QUOTE) { if (i+1 < patLen && pattern[i+1] == SINGLE_QUOTE) { segments[0] += ch; ++i; } else { inQuote = !inQuote; } } else if (ch == LEFT_CURLY_BRACE && !inQuote) { // The only way we get from segment 0 to 1 is via an // unquoted '{'. part = 1; } else { segments[0] += ch; } } else if (inQuote) { // In segments 1..3, recognize quoted matter, and copy it // into the segment, together with the quotes. This takes // care of '' as well. segments[part] += ch; if (ch == SINGLE_QUOTE) { inQuote = FALSE; } } else { // We have an unquoted character in segment 1..3 switch (ch) { case COMMA: // Commas bump us to the next segment, except for segment 3, // which can contain commas. See example above. if (part < 3) part += 1; else segments[3] += ch; break; case LEFT_CURLY_BRACE: // Handle '{' within segment 3. The initial '{' // before segment 1 is handled above. if (part != 3) { ec = U_PATTERN_SYNTAX_ERROR; goto SYNTAX_ERROR; } ++braceStack; segments[part] += ch; break; case RIGHT_CURLY_BRACE: if (braceStack == 0) { makeFormat(formatNumber, segments, parseError,ec); if (U_FAILURE(ec)){ goto SYNTAX_ERROR; } formatNumber++; segments[1].remove(); segments[2].remove(); segments[3].remove(); part = 0; } else { --braceStack; segments[part] += ch; } break; case SINGLE_QUOTE: inQuote = TRUE; // fall through (copy quote chars in segments 1..3) default: segments[part] += ch; break; } } } if (braceStack != 0 || part != 0) { // Unmatched braces in the pattern ec = U_UNMATCHED_BRACES; goto SYNTAX_ERROR; } fPattern = segments[0]; return; SYNTAX_ERROR: syntaxError(pattern, i, parseError); for (i=0; i<subformatCount; ++i) { delete subformats[i].format; } argTypeCount = subformatCount = 0; }
false
false
false
false
false
0
retrieve(QWeakPointer<StorageJob> wcaller, const QVariantMap &params) { StorageJob *caller = wcaller.data(); if (!caller) { return; } const QString clientName = caller->clientName(); initializeDb(caller); QString valueGroup = params["group"].toString(); if (valueGroup.isEmpty()) { valueGroup = "default"; } QSqlQuery query(m_db); //a bit redundant but should be the faster way with less string concatenation as possible if (params["key"].toString().isEmpty()) { //update modification time query.prepare("update " + clientName + " set accessTime=date('now') where valueGroup=:valueGroup"); query.bindValue(":valueGroup", valueGroup); query.exec(); query.prepare("select * from " + clientName + " where valueGroup=:valueGroup"); query.bindValue(":valueGroup", valueGroup); } else { //update modification time query.prepare("update " + clientName + " set accessTime=date('now') where valueGroup=:valueGroup and id=:key"); query.bindValue(":valueGroup", valueGroup); query.bindValue(":key", params["key"].toString()); query.exec(); query.prepare("select * from " + clientName + " where valueGroup=:valueGroup and id=:key"); query.bindValue(":valueGroup", valueGroup); query.bindValue(":key", params["key"].toString()); } const bool success = query.exec(); QVariant result; if (success) { QSqlRecord rec = query.record(); const int keyColumn = rec.indexOf("id"); const int textColumn = rec.indexOf("txt"); const int intColumn = rec.indexOf("int"); const int floatColumn = rec.indexOf("float"); const int binaryColumn = rec.indexOf("binary"); QVariantHash data; while (query.next()) { const QString key = query.value(keyColumn).toString(); if (!query.value(textColumn).isNull()) { data.insert(key, query.value(textColumn)); } else if (!query.value(intColumn).isNull()) { data.insert(key, query.value(intColumn)); } else if (!query.value(floatColumn).isNull()) { data.insert(key, query.value(floatColumn)); } else if (!query.value(binaryColumn).isNull()) { QByteArray bytes = query.value(binaryColumn).toByteArray(); QDataStream in(bytes); QVariant v(in); data.insert(key, v); } } result = data; } else { result = false; } emit newResult(caller, result); }
false
false
false
false
false
0
shadow_setup(char *name, gboolean do_switch) { const char *prompt = getenv("PS1"); const char *shell = getenv("SHELL"); char *new_prompt = get_shadow_prompt(name); printf("Setting up shadow instance\n"); if (safe_str_eq(new_prompt, prompt)) { /* nothing to do */ goto done; } else if (batch_flag == FALSE && shell != NULL) { setenv("PS1", new_prompt, 1); setenv("CIB_shadow", name, 1); printf("Type Ctrl-D to exit the crm_shadow shell\n"); if (strstr(shell, "bash")) { execl(shell, shell, "--norc", "--noprofile", NULL); } else { execl(shell, shell, "--noprofile", NULL); } } else if (do_switch) { printf("To switch to the named shadow instance, paste the following into your shell:\n"); } else { printf ("A new shadow instance was created. To begin using it paste the following into your shell:\n"); } printf(" CIB_shadow=%s ; export CIB_shadow\n", name); done: free(new_prompt); }
false
false
false
false
true
1
fr_command_zip_extract (FrCommand *comm, const char *from_file, GList *file_list, const char *dest_dir, gboolean overwrite, gboolean skip_older, gboolean junk_paths) { GList *scan; fr_process_set_out_line_func (FR_COMMAND (comm)->process, process_line__common, comm); fr_process_begin_command (comm->process, "unzip"); if (dest_dir != NULL) { fr_process_add_arg (comm->process, "-d"); fr_process_add_arg (comm->process, dest_dir); } if (overwrite) fr_process_add_arg (comm->process, "-o"); else fr_process_add_arg (comm->process, "-n"); if (skip_older) fr_process_add_arg (comm->process, "-u"); if (junk_paths) fr_process_add_arg (comm->process, "-j"); add_password_arg (comm, FR_ARCHIVE (comm)->password); fr_process_add_arg (comm->process, "--"); fr_process_add_arg (comm->process, comm->filename); for (scan = file_list; scan; scan = scan->next) { char *escaped; escaped = _g_str_escape (scan->data, ZIP_SPECIAL_CHARACTERS); fr_process_add_arg (comm->process, escaped); g_free (escaped); } fr_process_end_command (comm->process); }
false
false
false
false
false
0
activate_statue_trap(struct trap *trap, xchar x, xchar y, bool shatter) { struct monst *mtmp = NULL; struct obj *otmp = sobj_at(STATUE, x, y); int fail_reason; /* * Try to animate the first valid statue. Stop the loop when we * actually create something or the failure cause is not because * the mon was unique. */ deltrap(trap); while (otmp) { mtmp = animate_statue(otmp, x, y, shatter ? ANIMATE_SHATTER : ANIMATE_NORMAL, &fail_reason); if (mtmp || fail_reason != AS_MON_IS_UNIQUE) break; while ((otmp = otmp->nexthere) != 0) if (otmp->otyp == STATUE) break; } if (Blind) feel_location(x, y); else newsym(x, y); return mtmp; }
false
false
false
false
false
0
display_autoneg(struct writer * w, int advertised, int bithd, int bitfd, char *desc) { if (!((advertised & bithd) || (advertised & bitfd))) return; tag_start(w, "advertised", "Adv"); tag_attr(w, "type", "", desc); if (bitfd != bithd) { tag_attr(w, "hd", "HD", (advertised & bithd)?"yes":"no"); tag_attr(w, "fd", "FD", (advertised & bitfd)?"yes":"no"); } tag_end (w); }
false
false
false
false
false
0
SetTextProperty(vtkTextProperty *p) { if ( this->TextProperty == p ) { return; } if ( this->TextProperty ) { this->TextProperty->UnRegister( this ); this->TextProperty = NULL; } this->TextProperty = p; if (this->TextProperty) { this->TextProperty->Register(this); this->ScaledTextProperty->ShallowCopy(this->TextProperty); } this->Modified(); }
false
false
false
false
false
0
Write (writer_t *wr, const void *data, Addr_t nbytes) { wr_buffer_t *bp = BufOf(wr); if (wr->errFlg) return; ASSERT(bp->next+nbytes <= bp->top); memcpy (bp->next, data, nbytes); bp->next += nbytes; }
false
true
false
false
false
1
vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, enum dma_data_direction dma_dir, gfp_t gfp_flags) { struct vb2_dma_sg_conf *conf = alloc_ctx; struct vb2_dma_sg_buf *buf; struct sg_table *sgt; int ret; int num_pages; DEFINE_DMA_ATTRS(attrs); dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs); if (WARN_ON(alloc_ctx == NULL)) return NULL; buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf) return NULL; buf->vaddr = NULL; buf->dma_dir = dma_dir; buf->offset = 0; buf->size = size; /* size is already page aligned */ buf->num_pages = size >> PAGE_SHIFT; buf->dma_sgt = &buf->sg_table; buf->pages = kzalloc(buf->num_pages * sizeof(struct page *), GFP_KERNEL); if (!buf->pages) goto fail_pages_array_alloc; ret = vb2_dma_sg_alloc_compacted(buf, gfp_flags); if (ret) goto fail_pages_alloc; ret = sg_alloc_table_from_pages(buf->dma_sgt, buf->pages, buf->num_pages, 0, size, GFP_KERNEL); if (ret) goto fail_table_alloc; /* Prevent the device from being released while the buffer is used */ buf->dev = get_device(conf->dev); sgt = &buf->sg_table; /* * No need to sync to the device, this will happen later when the * prepare() memop is called. */ sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir, &attrs); if (!sgt->nents) goto fail_map; buf->handler.refcount = &buf->refcount; buf->handler.put = vb2_dma_sg_put; buf->handler.arg = buf; atomic_inc(&buf->refcount); dprintk(1, "%s: Allocated buffer of %d pages\n", __func__, buf->num_pages); return buf; fail_map: put_device(buf->dev); sg_free_table(buf->dma_sgt); fail_table_alloc: num_pages = buf->num_pages; while (num_pages--) __free_page(buf->pages[num_pages]); fail_pages_alloc: kfree(buf->pages); fail_pages_array_alloc: kfree(buf); return NULL; }
false
false
false
false
false
0
firstLine(const QModelIndex &index) const { if (index.isValid()) return index.model()->data(index, Qt::DisplayRole).toString(); return QString(); }
false
false
false
false
false
0
vartable_open (ggobid *gg) { GtkWidget *vbox, *hbox; GSList *l; GGobiData *d; /*-- if used before we have data, bail out --*/ if (gg->d == NULL || g_slist_length (gg->d) == 0) return; /*-- if new datad's have been added, the user has to reopen the window --*/ if (gg->vartable_ui.window != NULL) { destroyit (gg); } gg->vartable_ui.window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(gg->vartable_ui.window), 750, 300); g_signal_connect (G_OBJECT (gg->vartable_ui.window), "delete_event", G_CALLBACK (close_wmgr_cb), gg); gtk_window_set_title (GTK_WINDOW (gg->vartable_ui.window), "Variable Manipulation"); vbox = gtk_vbox_new (false, 5); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); gtk_container_add (GTK_CONTAINER (gg->vartable_ui.window), vbox); gtk_widget_show (vbox); /* Create a notebook, set the position of the tabs */ gg->vartable_ui.notebook = gtk_notebook_new (); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (gg->vartable_ui.notebook), GTK_POS_TOP); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (gg->vartable_ui.notebook), g_slist_length (gg->d) > 1); gtk_box_pack_start (GTK_BOX (vbox), gg->vartable_ui.notebook, true, true, 2); /* Needed?: a switch-page callback so that we can keep track of * the vartyped of the current page, and show or hide buttons * as appropriate -- dfs */ /* Connecting to display_selected event */ g_signal_connect (G_OBJECT (gg), "display_selected", G_CALLBACK (vartable_show_page_cb), NULL); /* */ for (l = gg->d; l; l = l->next) { d = (GGobiData *) l->data; vartable_subwindow_init (d, gg); } /*-- listen for datad_added events --*/ g_signal_connect (G_OBJECT (gg), "datad_added", G_CALLBACK (vartable_notebook_adddata_cb), GTK_OBJECT (gg->vartable_ui.notebook)); hbox = vartable_buttonbox_build (gg); gtk_box_pack_start (GTK_BOX (vbox), hbox, false, false, 1); gtk_widget_show_all (gg->vartable_ui.window); /*-- set it to the page corresponding to the current display --*/ d = (gg->current_display ? gg->current_display->d : (GGobiData *)gg->d->data); vartable_show_page (d, gg); }
false
false
false
false
false
0
get_thread_status(int n, ThreadStat *status) { THREAD t; t = find_thread_by_number(n); if (t == NULL) return 0; else { status->number = t->number; status->owner = t->vms->r->vm_uid; status->sleeping = (t->queue == &sleep_q); status->status = t->contextkind; return 1; } }
false
false
false
false
false
0
is_cjk_letter(UT_UCSChar c) const { if (!cjk_locale()) return 0; return (c>0xff); }
false
false
false
false
false
0
fm_malloc(size_t req_size) { Fm_mem_src *src; frame_errmsg = NULL; if (top_frame == NULL) src = NULL; else src = top_frame->src; return(alloc_on_frame(top_frame, src, req_size)); }
false
false
false
false
false
0
setkey_core (void *context, const unsigned char *key, unsigned int keylen, int with_phase2) { static int initialized; static const char *selftest_failed; RFC2268_context *ctx = context; unsigned int i; unsigned char *S, x; int len; int bits = keylen * 8; if (!initialized) { initialized = 1; selftest_failed = selftest (); if (selftest_failed) log_error ("RFC2268 selftest failed (%s).\n", selftest_failed); } if (selftest_failed) return GPG_ERR_SELFTEST_FAILED; if (keylen < 40 / 8) /* We want at least 40 bits. */ return GPG_ERR_INV_KEYLEN; S = (unsigned char *) ctx->S; for (i = 0; i < keylen; i++) S[i] = key[i]; for (i = keylen; i < 128; i++) S[i] = rfc2268_sbox[(S[i - keylen] + S[i - 1]) & 255]; S[0] = rfc2268_sbox[S[0]]; /* Phase 2 - reduce effective key size to "bits". This was not * discussed in Gutmann's paper. I've copied that from the public * domain code posted in sci.crypt. */ if (with_phase2) { len = (bits + 7) >> 3; i = 128 - len; x = rfc2268_sbox[S[i] & (255 >> (7 & -bits))]; S[i] = x; while (i--) { x = rfc2268_sbox[x ^ S[i + len]]; S[i] = x; } } /* Make the expanded key, endian independent. */ for (i = 0; i < 64; i++) ctx->S[i] = ( (u16) S[i * 2] | (((u16) S[i * 2 + 1]) << 8)); return 0; }
false
false
false
false
false
0
atp_reinit(struct work_struct *work) { struct atp *dev = container_of(work, struct atp, work); int retval; dprintk("appletouch: putting appletouch to sleep (reinit)\n"); atp_geyser_init(dev); retval = usb_submit_urb(dev->urb, GFP_ATOMIC); if (retval) dev_err(&dev->intf->dev, "atp_reinit: usb_submit_urb failed with error %d\n", retval); }
false
false
false
false
false
0
sshv2_initialize_string_with_path (gftp_request * request, const char *path, size_t *len, char **endpos) { char *ret, *tempstr; size_t origlen; origlen = *len; if (*path == '/') ret = sshv2_initialize_buffer_with_i18n_string (request, path, len); else { tempstr = gftp_build_path (request, request->directory, path, NULL); ret = sshv2_initialize_buffer_with_i18n_string (request, tempstr, len); g_free (tempstr); } if (endpos != NULL) *endpos = ret + *len - origlen; return (ret); }
false
false
false
false
false
0
fm_list_remove(FmList* list, gpointer data) { GList* l = ((GQueue*)list)->head; for(;l; l=l->next) { if(l->data == data) { list->funcs->item_unref(data); break; } } if(l) g_queue_delete_link((GQueue*)data, l); }
false
false
false
false
false
0
camel_nntp_stream_gets (CamelNNTPStream *is, guchar **start, guint *len, GCancellable *cancellable, GError **error) { gint max; guchar *end; g_return_val_if_fail (is != NULL, -1); g_return_val_if_fail (start != NULL, -1); g_return_val_if_fail (len != NULL, -1); *len = 0; max = is->end - is->ptr; if (max == 0) { max = nntp_stream_fill (is, cancellable, error); if (max <= 0) return max; } *start = is->ptr; end = memchr (is->ptr, '\n', max); if (end) max = (end - is->ptr) + 1; *start = is->ptr; *len = max; is->ptr += max; return end == NULL ? 1 : 0; }
false
false
false
false
false
0
CreateLuminanceCIE1931LookupTable() { uint16_t *result = new uint16_t [ 256 ]; for (int i = 0; i < 256; ++i) result[i] = luminance_cie1931(i); return result; }
false
false
false
false
false
0
jump_cond_zero(const char *label, int cond, int distance) { if (cond == COND_EQUAL) { fprintf(out, " jeq %s\n", label); return 0; } else if (cond == COND_NOT_EQUAL) { fprintf(out, " jne %s\n", label); return 0; } return -1; }
false
false
false
false
false
0
gtkwidget_gtk_widget_style_get_property(ScmObj *SCM_FP, int SCM_ARGCNT, void *data_) { ScmObj widget_scm; GtkWidget* widget; ScmObj property_name_scm; const gchar * property_name; ScmObj SCM_SUBRARGS[2]; int SCM_i; SCM_ENTER_SUBR("gtk-widget-style-get-property"); for (SCM_i=0; SCM_i<2; SCM_i++) { SCM_SUBRARGS[SCM_i] = SCM_ARGREF(SCM_i); } widget_scm = SCM_SUBRARGS[0]; if (!SCM_GTK_WIDGET_P(widget_scm)) Scm_Error("<gtk-widget> required, but got %S", widget_scm); widget = SCM_GTK_WIDGET(widget_scm); property_name_scm = SCM_SUBRARGS[1]; if (!SCM_STRINGP(property_name_scm)) Scm_Error("<const-gchar*> required, but got %S", property_name_scm); property_name = CONST_GCHAR_PTR(property_name_scm); { GValue gv; ScmObj r; gv.g_type = 0; gtk_widget_style_get_property(widget, property_name, &gv); r = Scm_UnboxGValue(&gv); g_value_unset(&gv); SCM_RETURN(r); } }
false
false
false
false
false
0
getElementText( NodeImpl* start, bool after ) { QString ret; // nextSibling(), to go after e.g. </select> for( NodeImpl* n = after ? start->nextSibling() : start->traversePreviousNode(); n != NULL; n = after ? n->traverseNextNode() : n->traversePreviousNode()) { if( n->isTextNode()) { if( after ) ret += static_cast< TextImpl* >( n )->toString().string(); else ret.prepend( static_cast< TextImpl* >( n )->toString().string()); } else { switch( n->id()) { case ID_A: case ID_FONT: case ID_TT: case ID_U: case ID_B: case ID_I: case ID_S: case ID_STRIKE: case ID_BIG: case ID_SMALL: case ID_EM: case ID_STRONG: case ID_DFN: case ID_CODE: case ID_SAMP: case ID_KBD: case ID_VAR: case ID_CITE: case ID_ABBR: case ID_ACRONYM: case ID_SUB: case ID_SUP: case ID_SPAN: case ID_NOBR: case ID_WBR: break; case ID_TD: if( ret.trimmed().isEmpty()) break; // fall through default: return ret.simplified(); } } } return ret.simplified(); }
false
false
false
false
false
0
addDisputedTriangles(GoGame *game, Sgf *sgf) { int i; for (i = 0; i < goBoard_area(game->board); ++i) { if (game->flags[i] & GOGAMEFLAGS_DISPUTED) sgf_addTriangle(sgf, goBoard_loc2Sgf(game->board, i)); } }
false
false
false
false
false
0
reserve(int want) { if (want < 0) want = (_capacity > 0 ? _capacity * 2 : 4); if (want <= _capacity) return true; void **new_l = new void*[want]; if (!new_l) return false; memcpy(new_l, _l, sizeof(void*) * _n); delete[] _l; _l = new_l; _capacity = want; return true; }
false
false
false
false
false
0
packet_id_net_print (const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc) { struct buffer out = alloc_buf_gc (256, gc); buf_printf (&out, "[ #" packet_id_format, (packet_id_print_type)pin->id); if (print_timestamp && pin->time) buf_printf (&out, " / time = (" packet_id_format ") %s", (packet_id_print_type)pin->time, time_string (pin->time, 0, false, gc)); buf_printf (&out, " ]"); return BSTR (&out); }
false
false
false
false
false
0
skipblanks(ch,nextch) int ch; ifun0 nextch; { while(ch == ' ' || ch == '\t') { ch = nextch(); } return(ch); }
false
false
false
false
false
0
cfhsi_start_tx(struct cfhsi *cfhsi) { struct cfhsi_desc *desc = (struct cfhsi_desc *)cfhsi->tx_buf; int len, res; netdev_dbg(cfhsi->ndev, "%s.\n", __func__); if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) return; do { /* Create HSI frame. */ len = cfhsi_tx_frm(desc, cfhsi); if (!len) { spin_lock_bh(&cfhsi->lock); if (unlikely(cfhsi_tx_queue_len(cfhsi))) { spin_unlock_bh(&cfhsi->lock); res = -EAGAIN; continue; } cfhsi->tx_state = CFHSI_TX_STATE_IDLE; /* Start inactivity timer. */ mod_timer(&cfhsi->inactivity_timer, jiffies + cfhsi->cfg.inactivity_timeout); spin_unlock_bh(&cfhsi->lock); break; } /* Set up new transfer. */ res = cfhsi->ops->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->ops); if (WARN_ON(res < 0)) netdev_err(cfhsi->ndev, "%s: TX error %d.\n", __func__, res); } while (res < 0); }
false
false
false
false
false
0
sci_remote_device_stopped_state_enter(struct sci_base_state_machine *sm) { struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); struct isci_host *ihost = idev->owning_port->owning_controller; u32 prev_state; /* If we are entering from the stopping state let the SCI User know that * the stop operation has completed. */ prev_state = idev->sm.previous_state_id; if (prev_state == SCI_DEV_STOPPING) isci_remote_device_deconstruct(ihost, idev); sci_controller_remote_device_stopped(ihost, idev); }
false
false
false
false
false
0
CDB_memp_fset(dbmfp, pgaddr, flags) DB_MPOOLFILE *dbmfp; void *pgaddr; u_int32_t flags; { BH *bhp; DB_ENV *dbenv; DB_MPOOL *dbmp; MCACHE *mc; MPOOL *mp; int ret; dbmp = dbmfp->dbmp; dbenv = dbmp->dbenv; mp = dbmp->reginfo.primary; PANIC_CHECK(dbenv); /* Validate arguments. */ if (flags == 0) return (CDB___db_ferr(dbenv, "CDB_memp_fset", 1)); if ((ret = CDB___db_fchk(dbenv, "CDB_memp_fset", flags, DB_MPOOL_DIRTY | DB_MPOOL_CLEAN | DB_MPOOL_DISCARD)) != 0) return (ret); if ((ret = CDB___db_fcchk(dbenv, "CDB_memp_fset", flags, DB_MPOOL_CLEAN, DB_MPOOL_DIRTY)) != 0) return (ret); if (LF_ISSET(DB_MPOOL_DIRTY) && F_ISSET(dbmfp, MP_READONLY)) { CDB___db_err(dbenv, "%s: dirty flag set for readonly file page", CDB___memp_fn(dbmfp)); return (EACCES); } /* Convert the page address to a buffer header. */ bhp = (BH *)((u_int8_t *)pgaddr - SSZA(BH, buf)); /* Convert the buffer header to a cache. */ mc = BH_TO_CACHE(dbmp, bhp); R_LOCK(dbenv, &dbmp->reginfo); if (LF_ISSET(DB_MPOOL_CLEAN) && F_ISSET(bhp, BH_DIRTY)) { ++mc->stat.st_page_clean; --mc->stat.st_page_dirty; F_CLR(bhp, BH_DIRTY); } if (LF_ISSET(DB_MPOOL_DIRTY) && !F_ISSET(bhp, BH_DIRTY)) { --mc->stat.st_page_clean; ++mc->stat.st_page_dirty; F_SET(bhp, BH_DIRTY); } if (LF_ISSET(DB_MPOOL_DISCARD)) F_SET(bhp, BH_DISCARD); R_UNLOCK(dbenv, &dbmp->reginfo); return (0); }
false
false
false
false
false
0
afs_fd_set_cloexec(int fd) { int flags; flags = fcntl(fd, F_GETFD); if (flags >= 0) { flags |= FD_CLOEXEC; if (fcntl(fd, F_SETFD, flags) >= 0) return 0; } ECA_LOG_MSG(ECA_LOGGER::info, "unable to set FD_CLOEXEC: " + std::string(strerror(errno))); return -1; }
false
false
false
false
false
0
zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsigned int end, unsigned long *deleted) { unsigned int num = (end-start)+1; if (deleted) *deleted = num; zl = ziplistDeleteRange(zl,2*(start-1),2*num); return zl; }
false
false
false
false
false
0
jas_strdup(const char *s) { int n; char *p; n = strlen(s) + 1; if (!(p = jas_malloc(n * sizeof(char)))) { return 0; } strcpy(p, s); return p; }
false
false
false
false
false
0
gcr_certificate_renderer_get_property (GObject *obj, guint prop_id, GValue *value, GParamSpec *pspec) { GcrCertificateRenderer *self = GCR_CERTIFICATE_RENDERER (obj); switch (prop_id) { case PROP_CERTIFICATE: g_value_set_object (value, self->pv->opt_cert); break; case PROP_LABEL: g_value_take_string (value, calculate_label (self)); break; case PROP_ATTRIBUTES: g_value_set_boxed (value, self->pv->opt_attrs); break; default: gcr_certificate_mixin_get_property (obj, prop_id, value, pspec); break; } }
false
false
false
false
false
0
FcCharSetPrint (const FcCharSet *c) { int i, j; intptr_t *leaves = FcCharSetLeaves (c); FcChar16 *numbers = FcCharSetNumbers (c); #if 0 printf ("CharSet 0x%x\n", (intptr_t) c); printf ("Leaves: +%d = 0x%x\n", c->leaves_offset, (intptr_t) leaves); printf ("Numbers: +%d = 0x%x\n", c->numbers_offset, (intptr_t) numbers); for (i = 0; i < c->num; i++) { printf ("Page %d: %04x +%d = 0x%x\n", i, numbers[i], leaves[i], (intptr_t) FcOffsetToPtr (leaves, leaves[i], FcCharLeaf)); } #endif printf ("\n"); for (i = 0; i < c->num; i++) { intptr_t leaf_offset = leaves[i]; FcCharLeaf *leaf = FcOffsetToPtr (leaves, leaf_offset, FcCharLeaf); printf ("\t"); printf ("%04x:", numbers[i]); for (j = 0; j < 256/32; j++) printf (" %08x", leaf->map[j]); printf ("\n"); } }
false
false
false
false
false
0
UnlinkBinding(Binding **pblist, Binding *b, Binding *prev) { Binding *t; if (!prev && b != *pblist) { for (t = *pblist; t && t != b; prev = t, t = t->NextBinding) { /* Find the previous binding in the list. */ } if (t == NULL) { /* Binding not found */ return; } } if (prev) { /* middle of list */ prev->NextBinding = b->NextBinding; } else { /* must have been first one, set new start */ *pblist = b->NextBinding; } return; }
false
false
false
false
false
0
RegisterImageHelper(int type, wxBitmap& bmp) { if (! imgList) { // assumes all images are the same size imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight(), true); imgTypeMap = new wxArrayInt; } int idx = imgList->Add(bmp); // do we need to extend the mapping array? wxArrayInt& itm = *imgTypeMap; if ( itm.GetCount() < (size_t)type+1) itm.Add(-1, type - itm.GetCount() + 1); // Add an item that maps type to the image index itm[type] = idx; }
false
false
false
false
false
0
findLastSelectableNode(NodeImpl *base) { NodeImpl *last = base; // Look for last text/cdata node that has a renderer, // or last childless replaced element while ( last && !(last->renderer() && ((last->nodeType() == Node::TEXT_NODE || last->nodeType() == Node::CDATA_SECTION_NODE) || (last->renderer()->isReplaced() && !last->renderer()->lastChild())))) { NodeImpl *next = last->lastChild(); if ( !next ) next = last->previousSibling(); while ( last && last != base && !next ) { last = last->parentNode(); if ( last && last != base ) next = last->previousSibling(); } last = next; } return last ? last : base; }
false
false
false
false
false
0
recompile_files (void) { file *f; putenv (xstrdup ("COMPILER_PATH=")); putenv (xstrdup ("LIBRARY_PATH=")); while ((f = file_pop ()) != NULL) { char *line, *command; FILE *stream = fopen (f->key, "r"); const char *const outname = frob_extension (f->key, ".rnw"); FILE *output = fopen (outname, "w"); while ((line = tfgets (stream)) != NULL) { switch (line[0]) { case 'C': case 'O': maybe_tweak (line, f); } fprintf (output, "%s\n", line); } fclose (stream); fclose (output); rename (outname, f->key); obstack_grow (&temporary_obstack, "cd ", 3); obstack_grow (&temporary_obstack, f->dir, strlen (f->dir)); obstack_grow (&temporary_obstack, "; ", 2); obstack_grow (&temporary_obstack, c_file_name, strlen (c_file_name)); obstack_1grow (&temporary_obstack, ' '); obstack_grow (&temporary_obstack, f->args, strlen (f->args)); obstack_1grow (&temporary_obstack, ' '); command = obstack_copy0 (&temporary_obstack, f->main, strlen (f->main)); if (tlink_verbose) fprintf (stderr, _("collect: recompiling %s\n"), f->main); if (tlink_verbose >= 3) fprintf (stderr, "%s\n", command); if (system (command) != 0) return 0; read_repo_file (f); obstack_free (&temporary_obstack, temporary_firstobj); } return 1; }
false
false
false
false
false
0
GetRange( vtkInformation *info, vtkQuadratureSchemeDefinition **dest, int from, int to, int n) { vtkInformationQuadratureSchemeDefinitionVectorValue* base = static_cast<vtkInformationQuadratureSchemeDefinitionVectorValue *>(this->GetAsObjectBase(info)); // Source vector exists? if (base==NULL) { vtkErrorWithObjectMacro( info,"Copy of empty vector has been requested."); return; } int m=static_cast<int>(base->GetVector().size()); // check source start. if (from>=m) { vtkErrorWithObjectMacro( info,"Copy starting past the end of the vector has been requested."); return; } // limit copy to what's there. if (n>m-from+1) { vtkErrorWithObjectMacro( info,"Copy past the end of the vector has been requested."); n=m-from+1; } // copy for (int i=0; i<n; ++i, ++from, ++to) { dest[to]=base->GetVector()[from]; } }
false
false
false
false
false
0
processLocation(DILocation Loc) { if (!Loc.Verify()) return; DIDescriptor S(Loc.getScope()); if (S.isCompileUnit()) addCompileUnit(DICompileUnit(S)); else if (S.isSubprogram()) processSubprogram(DISubprogram(S)); else if (S.isLexicalBlock()) processLexicalBlock(DILexicalBlock(S)); else if (S.isLexicalBlockFile()) { DILexicalBlockFile DBF = DILexicalBlockFile(S); processLexicalBlock(DILexicalBlock(DBF.getScope())); } processLocation(Loc.getOrigLocation()); }
false
false
false
false
false
0
bdrv_getlength(BlockDriverState *bs) { BlockDriver *drv = bs->drv; if (!drv) return -ENOMEDIUM; if (!drv->bdrv_getlength) { /* legacy mode */ return bs->total_sectors * SECTOR_SIZE; } return drv->bdrv_getlength(bs); }
false
false
false
false
false
0
pool_replace(void *old, void *new) { pool_cell_t *p; if (NULL == new) return NULL; if (NULL == old) return pool_add(new); if (new == old) return new; p = memory_pool.head; while (p) { if (p->value == old) { p->value = new; if (p->prev) p->prev->next = p->next; if (p->next) p->next->prev = p->prev; free(p); return pool_add(new); } p = p->next; } return NULL; }
false
false
false
false
false
0
_gcry_log_printsxp (const char *text, gcry_sexp_t sexp) { int with_lf = 0; if (text && *text) { if ((with_lf = !!strchr (text, '\n'))) log_debug ("%s", text); else log_debug ("%s: ", text); } if (sexp) { int any = 0; int n_closing; char *buf, *pend; const char *p; size_t size; size = sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, NULL, 0); p = buf = xmalloc (size); sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, buf, size); do { if (any && !with_lf) log_debug ("%*s ", (int)strlen(text), ""); else any = 1; pend = strchr (p, '\n'); size = pend? (pend - p) : strlen (p); if (with_lf) log_debug ("%.*s", (int)size, p); else log_printf ("%.*s", (int)size, p); if (pend) p = pend + 1; else p += size; n_closing = count_closing_parens (p); if (n_closing) { while (n_closing--) log_printf (")"); p = ""; } log_printf ("\n"); } while (*p); xfree (buf); } else if (text) log_printf ("\n"); }
false
false
false
false
false
0