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
InitVectorField(Object vfo) { char *str; VectorField vf = NULL; Class class; vf = (struct vectorField *)DXAllocateZero(sizeof(struct vectorField)); if (! vf) goto error; class = DXGetObjectClass(vfo); if (class == CLASS_GROUP) class = DXGetGroupClass((Group)vfo); switch(class) { case CLASS_MULTIGRID: { int i, n; char *str; if (! DXGetMemberCount((Group)vfo, &n)) goto error; vf->nmembers = n; vf->members = (VectorGrp *)DXAllocate(n*sizeof(VectorGrp)); if (! vf->members) goto error; for (i = 0; i < n; i++) { Object mo = DXGetEnumeratedMember((Group)vfo, i, NULL); if (!mo) goto error; class = DXGetObjectClass(mo); if (class == CLASS_GROUP) class = DXGetGroupClass((Group)mo); if (class != CLASS_FIELD && class != CLASS_COMPOSITEFIELD) { DXSetError(ERROR_DATA_INVALID, "invalid multigrid member"); goto error; } if (! GetElementType(mo, &str)) { DXSetError(ERROR_DATA_INVALID, "vectors"); goto error; } switch (IsRegular(mo)) { case 1: vf->members[i] = _dxfReg_InitVectorGrp(mo, str); break; case 0: vf->members[i] = _dxfIrreg_InitVectorGrp(mo, str); break; default: { DXSetError(ERROR_DATA_INVALID, "vectors"); goto error; } } if (! vf->members[i]) goto error; } } break; case CLASS_FIELD: case CLASS_COMPOSITEFIELD: { vf->nmembers = 1; vf->members = (VectorGrp *)DXAllocate(sizeof(VectorGrp)); if (! vf->members) goto error; if (! GetElementType(vfo, &str)) { DXSetError(ERROR_DATA_INVALID, "vectors"); goto error; } switch (IsRegular(vfo)) { case 1: vf->members[0] = _dxfReg_InitVectorGrp(vfo, str); break; case 0: vf->members[0] = _dxfIrreg_InitVectorGrp(vfo, str); break; default: { DXSetError(ERROR_DATA_INVALID, "vectors"); goto error; } } if (! vf->members[0]) goto error; } break; default: { DXSetError(ERROR_DATA_INVALID, "invalid object encountered in vector field"); goto error; } } vf->nDim = vf->members[0]->nDim; return vf; error: DestroyVectorField(vf); return NULL; }
false
false
false
false
false
0
elementtree_clear(PyObject *m) { elementtreestate *st = ET_STATE(m); Py_CLEAR(st->parseerror_obj); Py_CLEAR(st->deepcopy_obj); Py_CLEAR(st->elementpath_obj); return 0; }
false
false
false
false
false
0
fireWappon(projectile* obj) { if(firedWappon < 1 && !this->isDead()){ firedWappon = WAPPONREALOADTIME + 50/wappon; obj->setSpeed(obj->getSpeed() + this->speed); //obj->teleport((this->getPosition()) + obj->getSpeed().normalisedCopy()*this->wapponStartPosition); obj->teleport(this->getPosition() + obj->getSpeed()); obj->Damage = wappon/1.7; this->game->addLightObject(obj); return true; } return false; }
false
false
false
false
false
0
HandleRoutingChange(const cec_command &command) { if (command.parameters.size == 4) { CCECBusDevice *device = GetDevice(command.initiator); if (device) { uint16_t iNewAddress = ((uint16_t)command.parameters[2] << 8) | ((uint16_t)command.parameters[3]); device->SetActiveRoute(iNewAddress); return COMMAND_HANDLED; } } return CEC_ABORT_REASON_INVALID_OPERAND; }
false
false
false
false
false
0
tilemap_nb_find( int number ) { int count = 0; struct tilemap *tilemap; tilemap = first_tilemap; while( tilemap ) { count++; tilemap = tilemap->next; } number = (count-1)-number; tilemap = first_tilemap; while( number-- ) { tilemap = tilemap->next; } return tilemap; }
false
false
false
true
false
1
scm_i_rehash (SCM table, unsigned long (*hash_fn)(), void *closure, const char* func_name) { SCM buckets, new_buckets; int i; unsigned long old_size; unsigned long new_size; if (SCM_HASHTABLE_N_ITEMS (table) < SCM_HASHTABLE_LOWER (table)) { /* rehashing is not triggered when i <= min_size */ i = SCM_HASHTABLE (table)->size_index; do --i; while (i > SCM_HASHTABLE (table)->min_size_index && SCM_HASHTABLE_N_ITEMS (table) < hashtable_size[i] / 4); } else { i = SCM_HASHTABLE (table)->size_index + 1; if (i >= HASHTABLE_SIZE_N) /* don't rehash */ return; /* Remember HASH_FN for rehash_after_gc, but only when CLOSURE is not needed since CLOSURE can not be guaranteed to be valid after this function returns. */ if (closure == NULL) SCM_HASHTABLE (table)->hash_fn = hash_fn; } SCM_HASHTABLE (table)->size_index = i; new_size = hashtable_size[i]; if (i <= SCM_HASHTABLE (table)->min_size_index) SCM_HASHTABLE (table)->lower = 0; else SCM_HASHTABLE (table)->lower = new_size / 4; SCM_HASHTABLE (table)->upper = 9 * new_size / 10; buckets = SCM_HASHTABLE_VECTOR (table); if (SCM_HASHTABLE_WEAK_P (table)) new_buckets = scm_i_allocate_weak_vector (SCM_HASHTABLE_FLAGS (table), scm_from_ulong (new_size), SCM_EOL); else new_buckets = scm_c_make_vector (new_size, SCM_EOL); /* When this is a weak hashtable, running the GC might change it. We need to cope with this while rehashing its elements. We do this by first installing the new, empty bucket vector. Then we remove the elements from the old bucket vector and insert them into the new one. */ SCM_SET_HASHTABLE_VECTOR (table, new_buckets); SCM_SET_HASHTABLE_N_ITEMS (table, 0); old_size = SCM_SIMPLE_VECTOR_LENGTH (buckets); for (i = 0; i < old_size; ++i) { SCM ls, cell, handle; ls = SCM_SIMPLE_VECTOR_REF (buckets, i); SCM_SIMPLE_VECTOR_SET (buckets, i, SCM_EOL); while (scm_is_pair (ls)) { unsigned long h; cell = ls; handle = SCM_CAR (cell); ls = SCM_CDR (ls); h = hash_fn (SCM_CAR (handle), new_size, closure); if (h >= new_size) scm_out_of_range (func_name, scm_from_ulong (h)); SCM_SETCDR (cell, SCM_SIMPLE_VECTOR_REF (new_buckets, h)); SCM_SIMPLE_VECTOR_SET (new_buckets, h, cell); SCM_HASHTABLE_INCREMENT (table); } } }
false
false
false
false
false
0
entangle_debug_setup(gboolean debug_app, gboolean debug_gphoto) { entangle_debug_app = debug_app; entangle_debug_gphoto = debug_gphoto; #if GLIB_CHECK_VERSION(2, 31, 0) if (debug_app || debug_gphoto) { g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, gvir_log_handler, NULL); } #endif }
false
false
false
false
false
0
read_cas_url (gnutls_certificate_credentials_t res, const char *url) { int ret; gnutls_x509_crt_t *xcrt_list = NULL; gnutls_pkcs11_obj_t *pcrt_list = NULL; unsigned int pcrt_list_size = 0; /* FIXME: should we use login? */ ret = gnutls_pkcs11_obj_list_import_url (NULL, &pcrt_list_size, url, GNUTLS_PKCS11_OBJ_ATTR_CRT_TRUSTED, 0); if (ret < 0 && ret != GNUTLS_E_SHORT_MEMORY_BUFFER) { gnutls_assert (); return ret; } if (pcrt_list_size == 0) { gnutls_assert (); return 0; } pcrt_list = gnutls_malloc (sizeof (*pcrt_list) * pcrt_list_size); if (pcrt_list == NULL) { gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; } ret = gnutls_pkcs11_obj_list_import_url (pcrt_list, &pcrt_list_size, url, GNUTLS_PKCS11_OBJ_ATTR_CRT_TRUSTED, 0); if (ret < 0) { gnutls_assert (); goto cleanup; } xcrt_list = gnutls_malloc (sizeof (*xcrt_list) * pcrt_list_size); if (xcrt_list == NULL) { gnutls_assert (); ret = GNUTLS_E_MEMORY_ERROR; goto cleanup; } ret = gnutls_x509_crt_list_import_pkcs11 (xcrt_list, pcrt_list_size, pcrt_list, 0); if (xcrt_list == NULL) { gnutls_assert (); ret = GNUTLS_E_MEMORY_ERROR; goto cleanup; } res->x509_ca_list = xcrt_list; res->x509_ncas = pcrt_list_size; gnutls_free (pcrt_list); return pcrt_list_size; cleanup: gnutls_free (xcrt_list); gnutls_free (pcrt_list); return ret; }
false
false
false
false
false
0
BuildCursorGeometryWithoutHole() { this->ComputeAxes(); double bounds[6]; this->Image->GetBounds(bounds); // Length of the principal diagonal. const double pdLength = 20 * 0.5 * sqrt( (bounds[1] - bounds[0])*(bounds[1] - bounds[0]) + (bounds[3] - bounds[2])*(bounds[3] - bounds[2]) + (bounds[5] - bounds[4])*(bounds[5] - bounds[4])); // Precompute prior to use within the loop. double pts[6][3]; for (int i = 0; i < 3; i++) { pts[0][i] = this->Center[i] - pdLength * this->XAxis[i]; pts[1][i] = this->Center[i] + pdLength * this->XAxis[i]; pts[2][i] = this->Center[i] - pdLength * this->YAxis[i]; pts[3][i] = this->Center[i] + pdLength * this->YAxis[i]; pts[4][i] = this->Center[i] - pdLength * this->ZAxis[i]; pts[5][i] = this->Center[i] + pdLength * this->ZAxis[i]; } for (int j = 0; j < 3; j++) { vtkPoints *centerlinePoints = this->CenterlineAxis[j]->GetPoints(); centerlinePoints->SetPoint(0, pts[2*j]); centerlinePoints->SetPoint(1, pts[2*j+1]); this->CenterlineAxis[j]->Modified(); } this->PolyDataBuildTime.Modified(); }
false
false
false
false
false
0
tpci200_free_irq(struct ipack_device *dev) { struct slot_irq *slot_irq; struct tpci200_board *tpci200; tpci200 = check_slot(dev); if (tpci200 == NULL) return -EINVAL; if (mutex_lock_interruptible(&tpci200->mutex)) return -ERESTARTSYS; if (tpci200->slots[dev->slot].irq == NULL) { mutex_unlock(&tpci200->mutex); return -EINVAL; } tpci200_disable_irq(tpci200, dev->slot); slot_irq = tpci200->slots[dev->slot].irq; /* uninstall handler */ RCU_INIT_POINTER(tpci200->slots[dev->slot].irq, NULL); synchronize_rcu(); kfree(slot_irq); mutex_unlock(&tpci200->mutex); return 0; }
false
false
false
false
false
0
tp_presence_mixin_simple_presence_get_presences ( TpSvcConnectionInterfaceSimplePresence *iface, const GArray *contacts, DBusGMethodInvocation *context) { GObject *obj = (GObject *) iface; TpBaseConnection *conn = TP_BASE_CONNECTION (obj); TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn, TP_HANDLE_TYPE_CONTACT); TpPresenceMixinClass *mixin_cls = TP_PRESENCE_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj)); GHashTable *contact_statuses; GHashTable *presence_hash; GError *error = NULL; DEBUG ("called."); TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (conn, context); if (contacts->len == 0) { presence_hash = g_hash_table_new (g_direct_hash, g_direct_equal); tp_svc_connection_interface_simple_presence_return_from_get_presences ( context, presence_hash); g_hash_table_unref (presence_hash); return; } if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error)) { dbus_g_method_return_error (context, error); g_error_free (error); return; } contact_statuses = mixin_cls->get_contact_statuses (obj, contacts, &error); if (!contact_statuses) { dbus_g_method_return_error (context, error); g_error_free (error); return; } presence_hash = construct_simple_presence_hash (mixin_cls->statuses, contact_statuses); tp_svc_connection_interface_simple_presence_return_from_get_presences ( context, presence_hash); g_hash_table_unref (presence_hash); g_hash_table_unref (contact_statuses); }
false
false
false
false
false
0
jswrap_i2c_writeTo(JsVar *parent, JsVar *addressVar, JsVar *args) { IOEventFlags device = jsiGetDeviceFromClass(parent); if (!DEVICE_IS_I2C(device)) return; bool sendStop = true; int address = i2c_get_address(addressVar, &sendStop); size_t l = (size_t)jsvIterateCallbackCount(args); if (l+256 > jsuGetFreeStack()) { jsExceptionHere(JSET_ERROR, "Not enough free stack to send this amount of data"); return; } JsI2CWriteCbData cbData; cbData.buf = (unsigned char *)alloca(l); cbData.idx = 0; jsvIterateCallback(args, jswrap_i2c_writeToCb, (void*)&cbData); jshI2CWrite(device, (unsigned char)address, cbData.idx, cbData.buf, sendStop); }
false
false
false
false
false
0
gfire_got_preferences(gfire_data *p_gfire) { if(!p_gfire) return; gboolean fofs = gfire_preferences_get(p_gfire->prefs, 0x08); if(purple_account_get_bool(purple_connection_get_account(p_gfire->gc), "show_fofs", TRUE) != fofs) { gfire_preferences_set(p_gfire->prefs, 0x08, purple_account_get_bool(purple_connection_get_account(p_gfire->gc), "show_fofs", TRUE)); gfire_preferences_send(p_gfire->prefs, p_gfire->gc); } }
false
false
false
false
false
0
migrate_parse_webdav_source (ParseData *parse_data) { if (parse_data->soup_uri->host != NULL) g_key_file_set_string ( parse_data->key_file, E_SOURCE_EXTENSION_AUTHENTICATION, "Host", parse_data->soup_uri->host); if (parse_data->soup_uri->port != 0) g_key_file_set_integer ( parse_data->key_file, E_SOURCE_EXTENSION_AUTHENTICATION, "Port", parse_data->soup_uri->port); if (parse_data->soup_uri->user != NULL) g_key_file_set_string ( parse_data->key_file, E_SOURCE_EXTENSION_AUTHENTICATION, "User", parse_data->soup_uri->user); if (parse_data->soup_uri->path != NULL) g_key_file_set_string ( parse_data->key_file, E_SOURCE_EXTENSION_WEBDAV_BACKEND, "ResourcePath", parse_data->soup_uri->path); if (parse_data->soup_uri->query != NULL) g_key_file_set_string ( parse_data->key_file, E_SOURCE_EXTENSION_WEBDAV_BACKEND, "ResourceQuery", parse_data->soup_uri->query); parse_data->property_func = migrate_parse_webdav_property; }
false
false
false
false
false
0
doPrint() { QPrinter *printer = loadPageSetup(); if (! d->printDialog) d->printDialog = new QPrintDialog(printer, this); QPrintDialog::PrintDialogOptions options = d->printDialog->enabledOptions(); options &= ~QPrintDialog::PrintSelection; if (d->c->textCursor().hasSelection()) options |= QPrintDialog::PrintSelection; d->printDialog->setEnabledOptions(options); if (d->printDialog->exec() == QDialog::Accepted) { d->c->print(printer); savePageSetup(); } }
false
false
false
false
false
0
put_buf(struct r1bio *r1_bio) { struct r1conf *conf = r1_bio->mddev->private; int i; for (i = 0; i < conf->raid_disks * 2; i++) { struct bio *bio = r1_bio->bios[i]; if (bio->bi_end_io) rdev_dec_pending(conf->mirrors[i].rdev, r1_bio->mddev); } mempool_free(r1_bio, conf->r1buf_pool); lower_barrier(conf); }
false
false
false
false
false
0
search_alignment_direct( const ae_dna* chrom_1, const int32_t seed_1, const ae_dna* chrom_2, const int32_t seed_2, const int16_t needed_score ) { ae_vis_a_vis * best_alignment = NULL; int16_t nb_diags = 2 * align_max_shift + 1; ae_vis_a_vis * cur_vav = NULL; // TODO : As ae_vis_a_vis now contains its score, we should adapt the code to make it more integrated int16_t cur_score; // Zone 1 (Indice on the chromosome) int32_t w_zone_1_first = seed_1 - align_w_zone_h_len; // First base in working zone 1 int32_t w_zone_1_last = seed_1 + align_w_zone_h_len; // Last base in working zone 1 int32_t x_zone_1_first = w_zone_1_first - align_max_shift; // First base in extended zone 1 //~ int32_t x_zone_1_last = w_zone_1_last + align_max_shift; // Last base in extended zone 1 // Zone 2 (Indice on the chromosome) int32_t w_zone_2_first = seed_2 - align_w_zone_h_len; // First base in working zone 2 int32_t w_zone_2_last = seed_2 + align_w_zone_h_len; // Last base in working zone 2 //~ int32_t x_zone_2_first = w_zone_2_first - align_max_shift; // First base in extended zone 2 //~ int32_t x_zone_2_last = w_zone_2_last + align_max_shift; // Last base in extended zone 2 int32_t w_zone_2_shifted_first = w_zone_2_first + align_max_shift; // This doesn't represent any point of interest // in the sequence but will spare some calculation // Parse diagonals for ( int16_t cur_diag = 0 ; cur_diag < nb_diags ; cur_diag++ ) { // Initialize cur_vav according to the diagonal we are on if ( cur_diag < align_max_shift ) { cur_vav = new ae_vis_a_vis( chrom_1, chrom_2, x_zone_1_first + cur_diag, w_zone_2_first, DIRECT ); } else if ( cur_diag > align_max_shift ) { cur_vav = new ae_vis_a_vis( chrom_1, chrom_2, w_zone_1_first, w_zone_2_shifted_first - cur_diag, DIRECT ); } else // Central diagonal { cur_vav = new ae_vis_a_vis( chrom_1, chrom_2, w_zone_1_first, w_zone_2_first, DIRECT ); } // A sequence against itself is not an alignment if ( chrom_1 == chrom_2 && ae_utils::mod(cur_vav->_i_1, chrom_1->get_length()) == ae_utils::mod(cur_vav->_i_2, chrom_2->get_length()) ) { delete cur_vav; continue; } cur_score = 0; // Parse current diagonal while ( cur_vav->_i_1 <= w_zone_1_last && cur_vav->_i_2 <= w_zone_2_last ) { // Re-initialize score and potential alignment starting point if score <= 0 if ( cur_score <= 0 ) { cur_score = 0; if ( best_alignment != NULL ) { best_alignment->copy( cur_vav ); } else { best_alignment = new ae_vis_a_vis( *cur_vav ); } } // Update Score if ( cur_vav->match() ) { cur_score += align_match_bonus; // Check whether score is high enough to rearrange if ( cur_score >= needed_score ) { delete cur_vav; best_alignment->check_indices(); best_alignment->_score = cur_score; return best_alignment; } } else { cur_score -= align_mismatch_cost; } // Step forward cur_vav->step_fwd(); } delete cur_vav; } if ( best_alignment != NULL ) { delete best_alignment; } return NULL; // Didn't find any alignment with sufficient score. }
false
false
false
false
false
0
s5k5baf_hw_set_mirror(struct s5k5baf *state) { u16 flip = state->ctrls.vflip->val | (state->ctrls.vflip->val << 1); s5k5baf_write(state, REG_P_PREV_MIRROR(0), flip); if (state->streaming) s5k5baf_hw_sync_cfg(state); }
false
false
false
false
false
0
gagt_debug (const char *function, const char *format, ...) { if (DEBUG_OUT) { fprintf (debugfile, "%s (", function); if (format && strlen (format) > 0) { va_list ap; va_start (ap, format); vfprintf (debugfile, format, ap); va_end (ap); } fprintf (debugfile, ")\n"); fflush (debugfile); } }
false
false
false
false
true
1
gen_movqi (rtx operand0, rtx operand1) { rtx _val = 0; start_sequence (); { rtx operands[2]; operands[0] = operand0; operands[1] = operand1; #line 767 "../../src/gcc/config/aarch64/aarch64.md" if (GET_CODE (operands[0]) == MEM && operands[1] != const0_rtx) operands[1] = force_reg (QImode, operands[1]); operand0 = operands[0]; (void) operand0; operand1 = operands[1]; (void) operand1; } emit_insn (gen_rtx_SET (VOIDmode, operand0, operand1)); _val = get_insns (); end_sequence (); return _val; }
false
false
false
false
false
0
esl_stopwatch_Create(void) { int status; ESL_STOPWATCH *w = NULL; ESL_ALLOC(w, sizeof(ESL_STOPWATCH)); w->elapsed = 0.; w->user = 0.; w->sys = 0.; return w; ERROR: return NULL; }
false
false
false
false
false
0
xmlrpc_parse_value_va(xmlrpc_env * const envP, xmlrpc_value * const value, const char * const format, va_list args) { const char *format_copy; va_list args_copy; XMLRPC_ASSERT_ENV_OK(envP); XMLRPC_ASSERT_VALUE_OK(value); XMLRPC_ASSERT(format != NULL); format_copy = format; VA_LIST_COPY(args_copy, args); parsevalue(envP, value, &format_copy, &args_copy); if (!envP->fault_occurred) { XMLRPC_ASSERT(*format_copy == '\0'); } }
false
false
false
true
false
1
icq_convert_from_ucs2be(char *buf, int len) { #ifdef HAVE_ICONV char *ret, *ib, *ob; size_t ibl, obl; string_t text; if (!buf || !len) return NULL; text = string_init(NULL); string_append_raw(text, (char *) buf, len); ib = text->str, ibl = len; obl = 16 * ibl; ob = ret = xmalloc(obl + 1); iconv (ucs2be_conv_in, &ib, &ibl, &ob, &obl); string_free(text, 1); if (!ibl) { *ob = '\0'; ret = (char*)xrealloc((void*)ret, xstrlen(ret)+1); return ret; } xfree(ret); #endif return NULL; }
false
false
false
false
false
0
pixDebugFlipDetect(const char *filename, PIX *pixs, PIX *pixhm, l_int32 enable) { PIX *pixt, *pixthm; if (!enable) return; /* Display with red dot at counted locations */ pixt = pixConvert1To4Cmap(pixs); pixthm = pixMorphSequence(pixhm, "d5.5", 0); pixSetMaskedCmap(pixt, pixthm, 0, 0, 255, 0, 0); pixWrite(filename, pixt, IFF_PNG); pixDestroy(&pixthm); pixDestroy(&pixt); return; }
false
false
false
false
false
0
checkFile(const QString &filename) { m_currentFilename = filename; int i = m_currentFilename.lastIndexOf('/'); if (i != -1) { m_currentFilename = m_currentFilename.mid(i + 1); } m_skip = true; QFile file(filename); if (!file.open(QIODevice::ReadOnly)) { return false; } QTextStream ts(&file); ts.setCodec(QTextCodec::codecForName("ISO-8859-1")); int lineCount = 0; resetOptions(); QString id; while (!ts.atEnd()) { QString line = ts.readLine().trimmed(); lineCount++; if (line.isEmpty() || (line[0] == '#')) { continue; } if (line.startsWith("Id=")) { id = m_currentFilename + ':' + line.mid(3); } else if (line.startsWith("File=")) { checkGotFile(line.mid(5), id); } } return true; }
false
false
false
false
false
0
split_div(__isl_take isl_set *set, __isl_take isl_qpolynomial *qp, int div, isl_int min, isl_int max, struct isl_split_periods_data *data) { for (; isl_int_le(min, max); isl_int_add_ui(min, min, 1)) { isl_set *set_i = isl_set_copy(set); isl_qpolynomial *qp_i = isl_qpolynomial_copy(qp); if (set_div(set_i, qp_i, div, min, data) < 0) goto error; } isl_set_free(set); isl_qpolynomial_free(qp); return 0; error: isl_set_free(set); isl_qpolynomial_free(qp); return -1; }
false
false
false
false
false
0
eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *relative) { Eina_List *new_l; if ((!list) || (!relative)) return eina_list_append(list, data); eina_error_set(0); new_l = _eina_list_mempool_list_new(list); if (!new_l) return list; EINA_MAGIC_CHECK_LIST(relative, NULL); new_l->next = relative->next; new_l->data = (void *)data; if (relative->next) relative->next->prev = new_l; relative->next = new_l; new_l->prev = relative; _eina_list_update_accounting(list, new_l); if (!new_l->next) new_l->accounting->last = new_l; return list; }
false
false
false
false
false
0
eGetPage( void ) { eCmdType ePage; switch( GetSelection( ) ) { case 0 : ePage = eCMD_OP; break; case 1 : ePage = eCMD_DC; break; case 2 : ePage = eCMD_AC; break; case 3 : ePage = eCMD_TR; break; case 4 : ePage = eCMD_FO; break; default : ePage = eCMD_NONE; } return( ePage ); }
false
false
false
false
false
0
qtrle_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { QtrleContext *s = avctx->priv_data; int header, start_line; int stream_ptr, height, row_ptr; int has_palette = 0; s->buf = buf; s->size = buf_size; s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE | FF_BUFFER_HINTS_READABLE; if (avctx->reget_buffer(avctx, &s->frame)) { av_log (s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } /* check if this frame is even supposed to change */ if (s->size < 8) goto done; /* start after the chunk size */ stream_ptr = 4; /* fetch the header */ header = AV_RB16(&s->buf[stream_ptr]); stream_ptr += 2; /* if a header is present, fetch additional decoding parameters */ if (header & 0x0008) { if(s->size < 14) goto done; start_line = AV_RB16(&s->buf[stream_ptr]); stream_ptr += 4; height = AV_RB16(&s->buf[stream_ptr]); stream_ptr += 4; } else { start_line = 0; height = s->avctx->height; } row_ptr = s->frame.linesize[0] * start_line; switch (avctx->bits_per_coded_sample) { case 1: case 33: qtrle_decode_1bpp(s, stream_ptr, row_ptr, height); break; case 2: case 34: qtrle_decode_2n4bpp(s, stream_ptr, row_ptr, height, 2); has_palette = 1; break; case 4: case 36: qtrle_decode_2n4bpp(s, stream_ptr, row_ptr, height, 4); has_palette = 1; break; case 8: case 40: qtrle_decode_8bpp(s, stream_ptr, row_ptr, height); has_palette = 1; break; case 16: qtrle_decode_16bpp(s, stream_ptr, row_ptr, height); break; case 24: qtrle_decode_24bpp(s, stream_ptr, row_ptr, height); break; case 32: qtrle_decode_32bpp(s, stream_ptr, row_ptr, height); break; default: av_log (s->avctx, AV_LOG_ERROR, "Unsupported colorspace: %d bits/sample?\n", avctx->bits_per_coded_sample); break; } if(has_palette) { /* make the palette available on the way out */ memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE); if (s->avctx->palctrl->palette_changed) { s->frame.palette_has_changed = 1; s->avctx->palctrl->palette_changed = 0; } } done: *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; /* always report that the buffer was completely consumed */ return buf_size; }
false
true
false
false
false
1
bfusb_rx_submit(struct bfusb_data *data, struct urb *urb) { struct bfusb_data_scb *scb; struct sk_buff *skb; int err, pipe, size = HCI_MAX_FRAME_SIZE + 32; BT_DBG("bfusb %p urb %p", data, urb); if (!urb) { urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urb) return -ENOMEM; } skb = bt_skb_alloc(size, GFP_ATOMIC); if (!skb) { usb_free_urb(urb); return -ENOMEM; } skb->dev = (void *) data; scb = (struct bfusb_data_scb *) skb->cb; scb->urb = urb; pipe = usb_rcvbulkpipe(data->udev, data->bulk_in_ep); usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, size, bfusb_rx_complete, skb); skb_queue_tail(&data->pending_q, skb); err = usb_submit_urb(urb, GFP_ATOMIC); if (err) { BT_ERR("%s bulk rx submit failed urb %p err %d", data->hdev->name, urb, err); skb_unlink(skb, &data->pending_q); kfree_skb(skb); usb_free_urb(urb); } return err; }
false
true
false
false
false
1
load_options(void) { const char *home = getenv("HOME"); const char *tigrc_user = getenv("TIGRC_USER"); const char *tigrc_system = getenv("TIGRC_SYSTEM"); char buf[SIZEOF_STR]; if (!tigrc_system) tigrc_system = SYSCONFDIR "/tigrc"; load_option_file(tigrc_system); if (!tigrc_user) { if (!home || !string_format(buf, "%s/.tigrc", home)) return ERR; tigrc_user = buf; } load_option_file(tigrc_user); /* Add _after_ loading config files to avoid adding run requests * that conflict with keybindings. */ add_builtin_run_requests(); return OK; }
false
false
false
false
false
0
w83977af_net_close(struct net_device *dev) { struct w83977af_ir *self; int iobase; __u8 set; IRDA_ASSERT(dev != NULL, return -1;); self = netdev_priv(dev); IRDA_ASSERT(self != NULL, return 0;); iobase = self->io.fir_base; /* Stop device */ netif_stop_queue(dev); /* Stop and remove instance of IrLAP */ if (self->irlap) irlap_close(self->irlap); self->irlap = NULL; disable_dma(self->io.dma); /* Save current set */ set = inb(iobase+SSR); /* Disable interrupts */ switch_bank(iobase, SET0); outb(0, iobase+ICR); free_irq(self->io.irq, dev); free_dma(self->io.dma); /* Restore bank register */ outb(set, iobase+SSR); return 0; }
false
false
false
false
false
0
vector_make_nsarray_data(Vector *v, int compact) { unsigned int i; if (!v) { return; } v->nz = v->dim; if (v->dim > 0) { if (compact) { v->data.nsarray.compact = (int *)malloc(sizeof(int)*v->dim); if (!v->data.nsarray.compact) { if (MATR_DEBUG_MODE) { fprintf(stderr, "Unable to malloc data for non-sparse vector.\n"); } return; } } else { v->data.nsarray.precise = (double *)malloc(sizeof(double)*v->dim); if (!v->data.nsarray.precise) { if (MATR_DEBUG_MODE) { fprintf(stderr, "Unable to malloc data for non-sparse vector.\n"); } return; } } for (i = 0; i < v->dim; i++) { vector_set(v, i, 0); } } else { v->data.nsarray.precise = NULL; //pointers are same size doesn't matter } }
false
false
false
false
false
0
needbrack(Token bracket) { if (!match (bracket)) { error ("%c expected", bracket == LBRACK ? '(' : bracket == RBRACK ? ')' : bracket == LBRACE ? '{' : bracket == RBRACE ? '}' : bracket == LSQUARE ? '[' : bracket == RSQUARE ? ']' : 'x' ) ; } }
false
false
false
false
false
0
hybrid_confirm_show(const gchar *title, const gchar *text, const gchar *btn_text, confirm_cb btn_callback, gpointer user_data) { GtkWidget *window; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *action_area; GdkPixbuf *pixbuf; GtkWidget *image; GtkWidget *label; GtkWidget *button; HybridConfirm *confirm; g_return_val_if_fail(title != NULL, NULL); g_return_val_if_fail(text != NULL, NULL); confirm = g_new0(HybridConfirm, 1); confirm->btn_callback = btn_callback; confirm->user_data = user_data; window = hybrid_create_window(title, NULL, GTK_WIN_POS_CENTER, TRUE); gtk_container_set_border_width(GTK_CONTAINER(window), 8); g_signal_connect(window, "destroy", G_CALLBACK(confirm_destroy), confirm); confirm->window = window; vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); pixbuf = hybrid_create_default_icon(64); image = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 5); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), text); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 5); action_area = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), action_area, FALSE, FALSE, 0); button = gtk_button_new_with_label(btn_text); gtk_widget_set_size_request(button, 100, 30); gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5); g_signal_connect(button, "clicked", G_CALLBACK(confirm_user_btn_cb), confirm); button = gtk_button_new_with_label(_("Cancel")); gtk_widget_set_size_request(button, 100, 30); gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5); g_signal_connect(button, "clicked", G_CALLBACK(confirm_cancel_btn_cb), confirm); gtk_widget_show_all(confirm->window); return confirm; }
false
false
false
false
false
0
deco16_tilemap_2_draw(struct mame_bitmap *bitmap, const struct rectangle *cliprect, int flags, UINT32 priority) { if (pf2_tilemap_8x8) tilemap_draw(bitmap,cliprect,pf2_tilemap_8x8,flags,priority); if (pf2_tilemap_16x16) tilemap_draw(bitmap,cliprect,pf2_tilemap_16x16,flags,priority); }
false
false
false
false
false
0
vs_image_scale_lanczos_Y (const VSImage * dest, const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, int submethod, double a, double sharpen) { switch (submethod) { case 0: default: vs_image_scale_lanczos_Y_int16 (dest, src, tmpbuf, sharpness, dither, a, sharpen); break; case 1: vs_image_scale_lanczos_Y_int32 (dest, src, tmpbuf, sharpness, dither, a, sharpen); break; case 2: vs_image_scale_lanczos_Y_float (dest, src, tmpbuf, sharpness, dither, a, sharpen); break; case 3: vs_image_scale_lanczos_Y_double (dest, src, tmpbuf, sharpness, dither, a, sharpen); break; } }
false
false
false
false
false
0
comparetup_index(const SortTuple *a, const SortTuple *b, Tuplesortstate *state) { /* * This is similar to _bt_tuplecompare(), but we have already done the * index_getattr calls for the first column, and we need to keep track of * whether any null fields are present. Also see the special treatment * for equal keys at the end. */ ScanKey scanKey = state->indexScanKey; IndexTuple tuple1; IndexTuple tuple2; int keysz; TupleDesc tupDes; bool equal_hasnull = false; int nkey; int32 compare; /* Allow interrupting long sorts */ CHECK_FOR_INTERRUPTS(); /* Compare the leading sort key */ compare = inlineApplySortFunction(&scanKey->sk_func, SORTFUNC_CMP, a->datum1, a->isnull1, b->datum1, b->isnull1); if (compare != 0) return compare; /* they are equal, so we only need to examine one null flag */ if (a->isnull1) equal_hasnull = true; /* Compare additional sort keys */ tuple1 = (IndexTuple) a->tuple; tuple2 = (IndexTuple) b->tuple; keysz = state->nKeys; tupDes = RelationGetDescr(state->indexRel); scanKey++; for (nkey = 2; nkey <= keysz; nkey++, scanKey++) { Datum datum1, datum2; bool isnull1, isnull2; datum1 = index_getattr(tuple1, nkey, tupDes, &isnull1); datum2 = index_getattr(tuple2, nkey, tupDes, &isnull2); /* see comments about NULLs handling in btbuild */ /* the comparison function is always of CMP type */ compare = inlineApplySortFunction(&scanKey->sk_func, SORTFUNC_CMP, datum1, isnull1, datum2, isnull2); if (compare != 0) return compare; /* done when we find unequal attributes */ /* they are equal, so we only need to examine one null flag */ if (isnull1) equal_hasnull = true; } /* * If btree has asked us to enforce uniqueness, complain if two equal * tuples are detected (unless there was at least one NULL field). * * It is sufficient to make the test here, because if two tuples are equal * they *must* get compared at some stage of the sort --- otherwise the * sort algorithm wouldn't have checked whether one must appear before the * other. * * Some rather brain-dead implementations of qsort will sometimes call the * comparison routine to compare a value to itself. (At this writing only * QNX 4 is known to do such silly things; we don't support QNX anymore, * but perhaps the behavior still exists elsewhere.) Don't raise a bogus * error in that case. */ if (state->enforceUnique && !equal_hasnull && tuple1 != tuple2) ereport(ERROR, (errcode(ERRCODE_UNIQUE_VIOLATION), errmsg("could not create unique index"), errdetail("Table contains duplicated values."))); /* * If key values are equal, we sort on ItemPointer. This does not affect * validity of the finished index, but it offers cheap insurance against * performance problems with bad qsort implementations that have trouble * with large numbers of equal keys. */ { BlockNumber blk1 = ItemPointerGetBlockNumber(&tuple1->t_tid); BlockNumber blk2 = ItemPointerGetBlockNumber(&tuple2->t_tid); if (blk1 != blk2) return (blk1 < blk2) ? -1 : 1; } { OffsetNumber pos1 = ItemPointerGetOffsetNumber(&tuple1->t_tid); OffsetNumber pos2 = ItemPointerGetOffsetNumber(&tuple2->t_tid); if (pos1 != pos2) return (pos1 < pos2) ? -1 : 1; } return 0; }
false
false
false
false
false
0
wall_11_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_11_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "wall_11_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; }
false
false
false
false
false
0
cl_commlib_get_connection_param(cl_com_handle_t* handle, int parameter, int* value) { if (handle != NULL) { switch(parameter) { case HEARD_FROM_TIMEOUT: *value = handle->last_heard_from_timeout; break; } } return CL_RETVAL_OK; }
false
false
false
false
false
0
lookup_id_mapping(gid, nidp) unsigned gid, *nidp; { int i; struct bucket *curr; if (n_ids_mapped) for (curr = id_map; curr; curr = curr->next) { /* first bucket might not be totally full */ if (curr == id_map) { i = n_ids_mapped % N_PER_BUCKET; if (i == 0) i = N_PER_BUCKET; } else i = N_PER_BUCKET; while (--i >= 0) if (gid == curr->map[i].gid) { *nidp = curr->map[i].nid; return TRUE; } } return FALSE; }
false
false
false
false
false
0
create_poitype_tree (guint max_level) { guint i = 0; guint j = 0; if (mydebug > 20) fprintf (stderr, "create_poitype_tree:\n"); /* insert base categories into tree */ for (i = 0; i < poi_type_list_max; i++) { if (strlen (poi_type_list[i].name) > 0) { if (poi_type_list[i].level == 0) { poitypetree_addrow (i, (GtkTreeIter *) NULL); if (mydebug > 30) { fprintf (stderr, "create_poitype_tree:" " adding base type %s\n", poi_type_list[i].name); } } } else { poi_type_list[i].level = 99; } } /* insert subcategories into tree */ for (j = 1; j <= max_level; j++) { for (i = 0; i < poi_type_list_max; i++) { if (poi_type_list[i].level == j) { gtk_tree_model_foreach (GTK_TREE_MODEL (poi_types_tree), *(GtkTreeModelForeachFunc) poitypetree_find_parent, (gpointer) i); } } } return gtk_tree_model_get_iter_first (GTK_TREE_MODEL (poi_types_tree), &current.poitype_iter); }
false
false
false
false
false
0
ves_icall_System_IO_MonoIO_FindClose (gpointer handle) { IncrementalFind *ifh = handle; gint32 error; if (FindClose (ifh->find_handle) == FALSE){ error = GetLastError (); } else error = ERROR_SUCCESS; g_free (ifh->utf8_path); g_free (ifh); return error; }
false
false
false
false
false
0
rd_new_remdata(RemType type, char *remote_name, char *type_spec) { REMDATA_S *rd = NULL; rd = (REMDATA_S *)fs_get(sizeof(*rd)); memset((void *)rd, 0, sizeof(*rd)); rd->type = type; rd->access = NoExists; if(remote_name) rd->rn = cpystr(remote_name); switch(rd->type){ case RemImap: if(type_spec) rd->t.i.special_hdr = cpystr(type_spec); break; default: q_status_message(SM_ORDER, 3,5, "rd_new_remdata: type not supported"); break; } return(rd); }
false
false
false
false
false
0
dbio_write_var(Var v) { int i; dbio_write_num((int) v.type & TYPE_DB_MASK); switch ((int) v.type) { case TYPE_CLEAR: case TYPE_NONE: break; case TYPE_STR: dbio_write_string(v.v.str); break; case TYPE_OBJ: case TYPE_ERR: case TYPE_INT: case TYPE_CATCH: case TYPE_FINALLY: dbio_write_num(v.v.num); break; case TYPE_FLOAT: dbio_write_float(*v.v.fnum); break; case TYPE_LIST: dbio_write_num(v.v.list[0].v.num); for (i = 0; i < v.v.list[0].v.num; i++) dbio_write_var(v.v.list[i + 1]); break; case TYPE_WAIF: write_waif(v); break; } }
false
false
false
false
false
0
toXml() const { QString xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<!DOCTYPE FreeMedForms>\n" "<DataPackServer>\n"; xml += Utils::GenericDescription::toXml(); xml += "</DataPackServer>\n"; return xml; }
false
false
false
false
false
0
ParseDirectives() { bool readDirective = false; while(1) { if(m_pScanner->empty()) break; Token& token = m_pScanner->peek(); if(token.type != Token::DIRECTIVE) break; // we keep the directives from the last document if none are specified; // but if any directives are specific, then we reset them if(!readDirective) m_state.Reset(); readDirective = true; HandleDirective(&token); m_pScanner->pop(); } }
false
false
false
false
false
0
print_troff_ms_text(const printTableContent *cont, FILE *fout) { bool opt_tuples_only = cont->opt->tuples_only; unsigned short opt_border = cont->opt->border; unsigned int i; const char *const * ptr; if (cancel_pressed) return; if (opt_border > 2) opt_border = 2; if (cont->opt->start_table) { /* print title */ if (!opt_tuples_only && cont->title) { fputs(".LP\n.DS C\n", fout); troff_ms_escaped_print(cont->title, fout); fputs("\n.DE\n", fout); } /* begin environment and set alignments and borders */ fputs(".LP\n.TS\n", fout); if (opt_border == 2) fputs("center box;\n", fout); else fputs("center;\n", fout); for (i = 0; i < cont->ncolumns; i++) { fputc(*(cont->aligns + i), fout); if (opt_border > 0 && i < cont->ncolumns - 1) fputs(" | ", fout); } fputs(".\n", fout); /* print headers */ if (!opt_tuples_only) { for (i = 0, ptr = cont->headers; i < cont->ncolumns; i++, ptr++) { if (i != 0) fputc('\t', fout); fputs("\\fI", fout); troff_ms_escaped_print(*ptr, fout); fputs("\\fP", fout); } fputs("\n_\n", fout); } } /* print cells */ for (i = 0, ptr = cont->cells; *ptr; i++, ptr++) { troff_ms_escaped_print(*ptr, fout); if ((i + 1) % cont->ncolumns == 0) { fputc('\n', fout); if (cancel_pressed) break; } else fputc('\t', fout); } if (cont->opt->stop_table) { printTableFooter *footers = footers_with_default(cont); fputs(".TE\n.DS L\n", fout); /* print footers */ if (footers && !opt_tuples_only && !cancel_pressed) { printTableFooter *f; for (f = footers; f; f = f->next) { troff_ms_escaped_print(f->data, fout); fputc('\n', fout); } } fputs(".DE\n", fout); } }
false
false
false
false
false
0
dbd_st_rows(SV *h, imp_sth_t *imp_sth) { dTHX; PERL_UNUSED_VAR(h); DBIh_SET_ERR_CHAR(h, imp_sth, 0, 1, "err msg", "12345", Nullch); return -1; }
false
false
false
false
false
0
isValidProxy(const KUrl &u) { return u.isValid() && u.hasHost(); }
false
false
false
false
false
0
snd_es1938_get_byte(struct es1938 *chip) { int i; unsigned char v; for (i = GET_LOOP_TIMEOUT; i; i--) if ((v = inb(SLSB_REG(chip, STATUS))) & 0x80) return inb(SLSB_REG(chip, READDATA)); dev_err(chip->card->dev, "get_byte timeout: status 0x02%x\n", v); return -ENODEV; }
false
false
false
false
false
0
get_app_info_size(FILE *in, int *size) { unsigned char raw_header[LEN_RAW_DB_HEADER]; DBHeader dbh; unsigned int offset; record_header rh; fseek(in, 0, SEEK_SET); fread(raw_header, LEN_RAW_DB_HEADER, 1, in); if (feof(in)) { jp_logf(JP_LOG_WARN, "get_app_info_size(): %s\n", _("Error reading file")); return EXIT_FAILURE; } unpack_db_header(&dbh, raw_header); if (dbh.app_info_offset==0) { *size=0; return EXIT_SUCCESS; } if (dbh.sort_info_offset!=0) { *size = dbh.sort_info_offset - dbh.app_info_offset; return EXIT_SUCCESS; } if (dbh.number_of_records==0) { fseek(in, 0, SEEK_END); *size=ftell(in) - dbh.app_info_offset; return EXIT_SUCCESS; } fread(&rh, sizeof(record_header), 1, in); offset = ((rh.Offset[0]*256+rh.Offset[1])*256+rh.Offset[2])*256+rh.Offset[3]; *size=offset - dbh.app_info_offset; return EXIT_SUCCESS; }
true
true
false
false
false
1
_dwarf_length_of_cu_header(Dwarf_Debug dbg, Dwarf_Unsigned offset, Dwarf_Bool is_info) { int local_length_size = 0; int local_extension_size = 0; Dwarf_Unsigned length = 0; Dwarf_Unsigned final_size = 0; Dwarf_Small *cuptr = is_info? dbg->de_debug_info.dss_data + offset: dbg->de_debug_types.dss_data+ offset; READ_AREA_LENGTH(dbg, length, Dwarf_Unsigned, cuptr, local_length_size, local_extension_size); final_size = local_extension_size + /* initial extension, if present */ local_length_size + /* Size of cu length field. */ sizeof(Dwarf_Half) + /* Size of version stamp field. */ local_length_size + /* Size of abbrev offset field. */ sizeof(Dwarf_Small); /* Size of address size field. */ if(!is_info) { final_size += /* type signature size */ sizeof (Dwarf_Sig8) + /* type offset size */ local_length_size; } return final_size; }
false
false
false
false
false
0
arm_general_register_operand_1 (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED) #line 76 "../../src/gcc/config/arm/predicates.md" { if (GET_CODE (op) == SUBREG) op = SUBREG_REG (op); return (REG_P (op) && (REGNO (op) <= LAST_ARM_REGNUM || REGNO (op) >= FIRST_PSEUDO_REGISTER)); }
false
false
false
false
false
0
getAssumptions(vector<Expr>& assumptions) { if(d_dump) { d_translator->dump(d_em->newLeafExpr(ASSUMPTIONS), true); } d_se->getAssumptions(assumptions); }
false
false
false
false
false
0
mos7840_get_serial_info(struct moschip_port *mos7840_port, struct serial_struct __user *retinfo) { struct serial_struct tmp; if (mos7840_port == NULL) return -1; if (!retinfo) return -EFAULT; memset(&tmp, 0, sizeof(tmp)); tmp.type = PORT_16550A; tmp.line = mos7840_port->port->minor; tmp.port = mos7840_port->port->port_number; tmp.irq = 0; tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; tmp.baud_base = 9600; tmp.close_delay = 5 * HZ; tmp.closing_wait = 30 * HZ; if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) return -EFAULT; return 0; }
false
false
false
false
false
0
val_int() { DBUG_ASSERT(fixed == 1); /* Perform division using DECIMAL math if either of the operands has a non-integer type */ if (args[0]->result_type() != INT_RESULT || args[1]->result_type() != INT_RESULT) { my_decimal tmp; my_decimal *val0p= args[0]->val_decimal(&tmp); if ((null_value= args[0]->null_value)) return 0; my_decimal val0= *val0p; my_decimal *val1p= args[1]->val_decimal(&tmp); if ((null_value= args[1]->null_value)) return 0; my_decimal val1= *val1p; int err; if ((err= my_decimal_div(E_DEC_FATAL_ERROR & ~E_DEC_DIV_ZERO, &tmp, &val0, &val1, 0)) > 3) { if (err == E_DEC_DIV_ZERO) signal_divide_by_null(); return 0; } my_decimal truncated; const bool do_truncate= true; if (my_decimal_round(E_DEC_FATAL_ERROR, &tmp, 0, do_truncate, &truncated)) DBUG_ASSERT(false); longlong res; if (my_decimal2int(E_DEC_FATAL_ERROR, &truncated, unsigned_flag, &res) & E_DEC_OVERFLOW) raise_integer_overflow(); return res; } longlong val0=args[0]->val_int(); longlong val1=args[1]->val_int(); bool val0_negative, val1_negative, res_negative; ulonglong uval0, uval1, res; if ((null_value= (args[0]->null_value || args[1]->null_value))) return 0; if (val1 == 0) { signal_divide_by_null(); return 0; } val0_negative= !args[0]->unsigned_flag && val0 < 0; val1_negative= !args[1]->unsigned_flag && val1 < 0; res_negative= val0_negative != val1_negative; uval0= (ulonglong) (val0_negative ? -val0 : val0); uval1= (ulonglong) (val1_negative ? -val1 : val1); res= uval0 / uval1; if (res_negative) { if (res > (ulonglong) LONGLONG_MAX) return raise_integer_overflow(); res= (ulonglong) (-(longlong) res); } return check_integer_overflow(res, !res_negative); }
false
false
false
false
false
0
bbox_continue(i_ctx_t *i_ctx_p) { os_ptr op = osp; int npop = (r_has_type(op, t_string) ? 4 : 6); int code = type1_callout_dispatch(i_ctx_p, bbox_continue, npop); if (code == 0) { op = osp; /* OtherSubrs might have altered it */ npop -= 4; /* nobbox_fill/stroke handles the rest */ pop(npop); op -= npop; op_type1_free(i_ctx_p); } return code; }
false
false
false
false
false
0
HasIndexedLookupInterceptor() { i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); ON_BAILOUT(isolate, "v8::Object::HasIndexedLookupInterceptor()", return false); return Utils::OpenHandle(this)->HasIndexedInterceptor(); }
false
false
false
false
false
0
IncorporateType(const Type *Ty) { // Check to see if we're already visited this type. if (!VisitedTypes.insert(Ty).second) return; // If this is a structure or opaque type, add a name for the type. if (((Ty->isStructTy() && cast<StructType>(Ty)->getNumElements()) || Ty->isOpaqueTy()) && !TP.hasTypeName(Ty)) { TP.addTypeName(Ty, "%"+utostr(unsigned(NumberedTypes.size()))); NumberedTypes.push_back(Ty); } // Recursively walk all contained types. for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) IncorporateType(*I); }
false
false
false
false
false
0
cl_cvdverify(const char *file) { struct cl_engine *engine; FILE *fs; int ret; if((fs = fopen(file, "rb")) == NULL) { cli_errmsg("cl_cvdverify: Can't open file %s\n", file); return CL_EOPEN; } if(!(engine = cl_engine_new())) { cli_errmsg("cld_cvdverify: Can't create new engine\n"); fclose(fs); return CL_EMEM; } engine->cb_stats_submit = NULL; /* Don't submit stats if we're just verifying a CVD */ ret = cli_cvdload(fs, engine, NULL, CL_DB_STDOPT | CL_DB_PUA, !!cli_strbcasestr(file, ".cld"), file, 1); cl_engine_free(engine); fclose(fs); return ret; }
false
false
false
false
false
0
transfer_city_units(struct player *pplayer, struct player *pvictim, struct unit_list *units, struct city *pcity, struct city *exclude_city, int kill_outside, bool verbose) { struct tile *ptile = pcity->tile; int saved_id = pcity->id; const char *name = city_name(pcity); /* Transfer enemy units in the city to the new owner. * Only relevant if we are transferring to another player. */ if (pplayer != pvictim) { unit_list_iterate_safe((ptile)->units, vunit) { /* Don't transfer units already owned by new city-owner --wegge */ if (unit_owner(vunit) == pvictim) { /* vunit may die during transfer_unit(). * unit_list_remove() is still safe using vunit pointer, as * pointer is not used for dereferencing, only as value. * Not sure if it would be safe to unlink first and transfer only * after that. Not sure if it is correct to unlink at all in * some cases, depending which list 'units' points to. */ transfer_unit(vunit, pcity, verbose); unit_list_remove(units, vunit); } else if (!pplayers_allied(pplayer, unit_owner(vunit))) { /* the owner of vunit is allied to pvictim but not to pplayer */ bounce_unit(vunit, verbose); } } unit_list_iterate_safe_end; } if (!city_exist(saved_id)) { saved_id = 0; } /* Any remaining units supported by the city are either given new home cities or maybe destroyed */ unit_list_iterate_safe(units, vunit) { struct city *new_home_city = tile_city(unit_tile(vunit)); if (new_home_city && new_home_city != exclude_city && city_owner(new_home_city) == unit_owner(vunit)) { /* unit is in another city: make that the new homecity, unless that city is actually the same city (happens if disbanding) */ transfer_unit(vunit, new_home_city, verbose); } else if ((kill_outside == -1 || real_map_distance(unit_tile(vunit), ptile) <= kill_outside) && saved_id) { /* else transfer to specified city. */ transfer_unit(vunit, pcity, verbose); if (unit_tile(vunit) == ptile && !pplayers_allied(pplayer, pvictim)) { /* Unit is inside city being transferred, bounce it */ bounce_unit(vunit, TRUE); } } else { /* The unit is lost. Call notify_player (in all other cases it is * called automatically). */ log_verbose("Lost %s %s at (%d,%d) when %s was lost.", nation_rule_name(nation_of_unit(vunit)), unit_rule_name(vunit), TILE_XY(unit_tile(vunit)), name); if (verbose) { notify_player(unit_owner(vunit), unit_tile(vunit), E_UNIT_LOST_MISC, ftc_server, _("%s lost along with control of %s."), unit_tile_link(vunit), name); } wipe_unit(vunit, ULR_CITY_LOST, NULL); } } unit_list_iterate_safe_end; #ifdef DEBUG unit_list_iterate(pcity->units_supported, punit) { fc_assert(punit->homecity == pcity->id); fc_assert(unit_owner(punit) == pplayer); } unit_list_iterate_end; #endif /* DEBUG */ }
false
false
false
false
true
1
cli_regcomp(regex_t *preg, const char *pattern, int cflags) { if (!strncmp(pattern, "(?i)", 4)) { pattern += 4; cflags |= REG_ICASE; } return cli_regcomp_real(preg, pattern, cflags); }
false
false
false
false
false
0
xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1, mmfile_t *mf2, const char *name2, xpparam_t const *xpp, int level, mmbuffer_t *result) { xdchange_t *xscr1, *xscr2; xdfenv_t xe1, xe2; int status; result->ptr = NULL; result->size = 0; if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0 || xdl_do_diff(orig, mf2, xpp, &xe2) < 0) { return -1; } if (xdl_change_compact(&xe1.xdf1, &xe1.xdf2, xpp->flags) < 0 || xdl_change_compact(&xe1.xdf2, &xe1.xdf1, xpp->flags) < 0 || xdl_build_script(&xe1, &xscr1) < 0) { xdl_free_env(&xe1); return -1; } if (xdl_change_compact(&xe2.xdf1, &xe2.xdf2, xpp->flags) < 0 || xdl_change_compact(&xe2.xdf2, &xe2.xdf1, xpp->flags) < 0 || xdl_build_script(&xe2, &xscr2) < 0) { xdl_free_env(&xe2); return -1; } status = 0; if (xscr1 || xscr2) { if (!xscr1) { result->ptr = xdl_malloc(mf2->size); memcpy(result->ptr, mf2->ptr, mf2->size); result->size = mf2->size; } else if (!xscr2) { result->ptr = xdl_malloc(mf1->size); memcpy(result->ptr, mf1->ptr, mf1->size); result->size = mf1->size; } else { status = xdl_do_merge(&xe1, xscr1, name1, &xe2, xscr2, name2, level, xpp, result); } xdl_free_script(xscr1); xdl_free_script(xscr2); } xdl_free_env(&xe1); xdl_free_env(&xe2); return status; }
false
false
false
false
false
0
hash_word_list(struct search_hash_buffer *shb, struct list_head *word_list) { struct skeyword *lcursor; unsigned num_common = 0, num_valid = 0; list_for_each_entry(lcursor, word_list, list) { size_t valid_chars = 0; uint32_t w_len = lcursor->len; tchar_t f_ch = lcursor->data[0]; if(!w_len) continue; if(!tischaracter(f_ch)) /* char valid? */ continue; else if(w_len > 3) /* anything longer than 3 char is OK */ valid_chars = w_len; else if(0x007f >= f_ch) /* basic ascii? */ valid_chars = w_len; else if(0x0080 <= f_ch && 0x07ff >= f_ch) /* simple utf-8 stuff? */ valid_chars = w_len * 2; else if(0x3041 <= f_ch && 0x30fe >= f_ch) /* asian stuff, count with 2 to get 2 chars min */ valid_chars = w_len * 2; else if(0x0800 <= f_ch) /* other stuff */ valid_chars = w_len * 3; else if(w_len > 2) /* huh? inspect it... */ { bool word, digit, mix; tistypemix(lcursor->data, w_len, &word, &digit, &mix); if(word || mix) valid_chars = w_len; } if(valid_chars > 2) /* if more than 3 utf-8 chars, everything is fine */ { bool found = false; if(w_len >= COM_WLEN_MIN && w_len <= COM_WLEN_MAX) { /* * there are some nice str search algos, but all are for the case * where you search a needle anywhere in a haystack. We only want * to compare the beginning, against several needles. * So a bsearch is at least better than bruteforce. */ found = bsearch(lcursor->data, common_word_list, anum(common_word_list), sizeof(common_word_list[0]), comw_compar) != NULL; } if(found) num_common++; else num_valid++; logg_develd_old("found %c nc %u nv %u\n", found ? 't' : 'f', num_common, num_valid); shb->hashes[shb->num++] = g2_qht_search_number_word(lcursor->data, 0, w_len); if(shb->num >= shb->size) break; } } /* if we had a search scheme in the metadata... */ if(false) num_valid += num_common > 1; else num_valid += num_common > 2; return !!num_valid; }
false
false
false
false
false
0
s_minicarp(const char *format, ...) { bool in_signal_handler = signal_in_handler(); va_list args; /* * This test duplicates the one in s_minilogv() but if we don't emit * the message we don't want to emit the stacktrace afterwards either. * Hence we need to know now. */ if G_UNLIKELY(logfile[LOG_STDERR].disabled) return; /* * This routine is only called in exceptional conditions, so even if * the LOG_STDERR file is not deemed printable for now, attempt to do * that as well and copy the message to LOG_STDOUT anyway. */ va_start(args, format); s_minilogv(G_LOG_LEVEL_WARNING, TRUE, format, args); va_end(args); s_stacktrace(in_signal_handler, 1); }
false
false
false
false
false
0
addPin(IOPIN *new_pin, unsigned int iPinNumber) { if (iPinNumber < mNumIopins) { // If there is not a PinModule for this pin, then add one. if (iopins[iPinNumber] == &AnInvalidPinModule) iopins[iPinNumber] = new PinModule(this,iPinNumber); iopins[iPinNumber]->setPin(new_pin); } else { printf("PortModule::addPin ERROR pin %d > %d\n", iPinNumber, mNumIopins); } return new_pin; }
false
false
false
false
false
0
usnic_vnic_res_spec_satisfied(const struct usnic_vnic_res_spec *min_spec, struct usnic_vnic_res_spec *res_spec) { int found, i, j; for (i = 0; i < USNIC_VNIC_RES_TYPE_MAX; i++) { found = 0; for (j = 0; j < USNIC_VNIC_RES_TYPE_MAX; j++) { if (res_spec->resources[i].type != min_spec->resources[i].type) continue; found = 1; if (min_spec->resources[i].cnt > res_spec->resources[i].cnt) return -EINVAL; break; } if (!found) return -EINVAL; } return 0; }
false
false
false
false
false
0
_doSetFixedOutputState(ArchiveHandle *AH) { /* Disable statement_timeout since restore is probably slow */ ahprintf(AH, "SET statement_timeout = 0;\n"); /* Likewise for lock_timeout */ ahprintf(AH, "SET lock_timeout = 0;\n"); /* Select the correct character set encoding */ ahprintf(AH, "SET client_encoding = '%s';\n", pg_encoding_to_char(AH->public.encoding)); /* Select the correct string literal syntax */ ahprintf(AH, "SET standard_conforming_strings = %s;\n", AH->public.std_strings ? "on" : "off"); /* Select the role to be used during restore */ if (AH->ropt && AH->ropt->use_role) ahprintf(AH, "SET ROLE %s;\n", fmtId(AH->ropt->use_role)); /* Make sure function checking is disabled */ ahprintf(AH, "SET check_function_bodies = false;\n"); /* Avoid annoying notices etc */ ahprintf(AH, "SET client_min_messages = warning;\n"); if (!AH->public.std_strings) ahprintf(AH, "SET escape_string_warning = off;\n"); /* Adjust row-security state */ if (AH->ropt && AH->ropt->enable_row_security) ahprintf(AH, "SET row_security = on;\n"); else ahprintf(AH, "SET row_security = off;\n"); ahprintf(AH, "\n"); }
false
false
false
false
false
0
operator!=(const CPose3D &p1,const CPose3D &p2) { return (p1.m_coords!=p2.m_coords)||(p1.getRotationMatrix()!=p2.getRotationMatrix()); }
false
false
false
false
false
0
removeManualAvatar(const Jid& j) { FileAvatar(this, j).removeFromDisk(); // TODO: Remove from caches. Maybe create a clearManualAvatar() which // removes the file but doesn't remove the avatar from caches (since it'll // be created again whenever the FileAvatar is requested) emit avatarChanged(j); }
false
false
false
false
false
0
gt_rcr_decoder_new(const char *name, const GtEncseq *ref, GtTimer *timer, GtError *err) { bool is_not_at_pageborder; long pagesize = sysconf((int) _SC_PAGESIZE), filepos; GtRcrDecoder *rcr_dec; gt_assert(name); if (timer != NULL) gt_timer_show_progress(timer, "initializing RcrDecoder", stdout); gt_error_check(err); if (!(gt_alphabet_is_dna(gt_encseq_alphabet(ref)))) { gt_error_set(err, "alphabet has to be DNA"); return NULL; } rcr_dec = gt_rcr_decoder_init(name, ref, err); rcr_read_header(rcr_dec); filepos = ftell(rcr_dec->fp); is_not_at_pageborder = (filepos % pagesize) != 0; if (is_not_at_pageborder) filepos = (filepos / pagesize + 1) * pagesize; gt_safe_assign(rcr_dec->startofencoding, filepos); gt_fa_fclose(rcr_dec->fp); return rcr_dec; }
false
false
false
false
false
0
prepare_group_list(void) { FILE *fd; int *idx; int n; int len, len1, len2; /* open file to store group file names */ fd = fopen(group_list, "w"); if (fd == NULL) G_fatal_error("Can't open any tempfiles"); /* * build sorted index into group files * so that all raster maps for a mapset to appear together */ idx = (int *)G_calloc(group.ref.nfiles, sizeof(int)); for (n = 0; n < group.ref.nfiles; n++) idx[n] = n; qsort(idx, group.ref.nfiles, sizeof(int), cmp); /* determine length of longest mapset name, and longest raster map name */ len1 = len2 = 0; for (n = 0; n < group.ref.nfiles; n++) { len = strlen(group.ref.file[n].name); if (len > len1) len1 = len; len = strlen(group.ref.file[n].mapset); if (len > len2) len2 = len; } /* write lengths, names to file */ fwrite(&len1, sizeof(len1), 1, fd); fwrite(&len2, sizeof(len2), 1, fd); for (n = 0; n < group.ref.nfiles; n++) fprintf(fd, "%s %s\n", group.ref.file[idx[n]].name, group.ref.file[idx[n]].mapset); fclose(fd); G_free(idx); return 0; }
false
false
false
false
true
1
discrete_component_transfer_func (gint C, RsvgNodeComponentTransferFunc * user_data) { gint k; if (!user_data->nbTableValues) return C; k = (C * user_data->nbTableValues) / 255; return user_data->tableValues[k]; }
false
false
false
false
false
0
SetEdgeLengthWeight( double w) { w = w < 0.0 ? 0.0 : ( w > 1.0 ? 1.0 : w); if(w != this->EdgeLengthWeight) { this->EdgeLengthWeight = w; this->RebuildStaticCosts = true; this->Modified(); } }
false
false
false
false
false
0
create_pdf(char const* filename) { QPDF pdf; // Start with an empty PDF that has no pages or non-required objects. pdf.emptyPDF(); // Add an indirect object to contain a font descriptor for the // built-in Helvetica font. QPDFObjectHandle font = pdf.makeIndirectObject( QPDFObjectHandle::parse( "<<" " /Type /Font" " /Subtype /Type1" " /Name /F1" " /BaseFont /Helvetica" " /Encoding /WinAnsiEncoding" ">>")); // Create a stream to encode our image. We don't have to set the // length or filters. QPDFWriter will fill in the length and // compress the stream data using FlateDecode by default. QPDFObjectHandle image = QPDFObjectHandle::newStream(&pdf); image.replaceDict(QPDFObjectHandle::parse( "<<" " /Type /XObject" " /Subtype /Image" " /ColorSpace /DeviceRGB" " /BitsPerComponent 8" " /Width 100" " /Height 100" ">>")); // Provide the stream data. ImageProvider* p = new ImageProvider(100, 100); PointerHolder<QPDFObjectHandle::StreamDataProvider> provider(p); image.replaceStreamData(provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); // Create direct objects as needed by the page dictionary. QPDFObjectHandle procset = QPDFObjectHandle::parse( "[/PDF /Text /ImageC]"); QPDFObjectHandle rfont = QPDFObjectHandle::newDictionary(); rfont.replaceKey("/F1", font); QPDFObjectHandle xobject = QPDFObjectHandle::newDictionary(); xobject.replaceKey("/Im1", image); QPDFObjectHandle resources = QPDFObjectHandle::newDictionary(); resources.replaceKey("/ProcSet", procset); resources.replaceKey("/Font", rfont); resources.replaceKey("/XObject", xobject); QPDFObjectHandle mediabox = QPDFObjectHandle::newArray(); mediabox.appendItem(newInteger(0)); mediabox.appendItem(newInteger(0)); mediabox.appendItem(newInteger(612)); mediabox.appendItem(newInteger(792)); // Create the page content stream QPDFObjectHandle contents = createPageContents( pdf, "Look at the pretty, orange square!"); // Create the page dictionary QPDFObjectHandle page = pdf.makeIndirectObject( QPDFObjectHandle::newDictionary()); page.replaceKey("/Type", newName("/Page")); page.replaceKey("/MediaBox", mediabox); page.replaceKey("/Contents", contents); page.replaceKey("/Resources", resources); // Add the page to the PDF file pdf.addPage(page, true); // Write the results. A real application would not call // setStaticID here, but this example does it for the sake of its // test suite. QPDFWriter w(pdf, filename); w.setStaticID(true); // for testing only w.write(); }
false
false
false
false
false
0
sge_ctime(time_t i, dstring *buffer) { #ifdef HAS_LOCALTIME_R struct tm tm_buffer; #endif struct tm *tm; if (!i) i = (time_t)sge_get_gmt(); #ifndef HAS_LOCALTIME_R tm = localtime(&i); #else tm = (struct tm *)localtime_r(&i, &tm_buffer); #endif sge_dstring_sprintf(buffer, "%02d/%02d/%04d %02d:%02d:%02d", tm->tm_mon + 1, tm->tm_mday, 1900 + tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); return sge_dstring_get_string(buffer); }
false
false
false
false
false
0
SortMoves (int ply) /***************************************************************************** * * Sort criteria is as follows. * 1. The move from the hash table * 2. Captures as above. * 3. Killers. * 4. History. * 5. Moves to the centre. * *****************************************************************************/ { leaf *p; int f, t, m, tovalue; int side, xside; BitBoard enemyP; side = board.side; xside = 1^side; enemyP = board.b[xside][pawn]; for (p = TreePtr[ply]; p < TreePtr[ply+1]; p++) { p->score = -INFINITY; f = FROMSQ (p->move); t = TOSQ (p->move); m = p->move & MOVEMASK; /* Hash table move (highest score) */ if (m == Hashmv[ply]) p->score += HASHSORTSCORE; else if (cboard[t] != 0 || p->move & PROMOTION) { /* ***** SRW My Interpretation of this code ************* * Captures normally in other places but..... * * * * On capture we generally prefer to capture with the * * with the lowest value piece so to chose between * * pieces we should subtract the piece value .... but * * * * The original code was looking at some captures * * last, especially where the piece was worth more * * than the piece captured - KP v K in endgame.epd * * * * So code modified to prefer any capture by adding * * ValueK * ****************************************************** */ tovalue = (Value[cboard[t]] + Value[PROMOTEPIECE (p->move)]); p->score += tovalue + ValueK - Value[cboard[f]]; } /* Killers */ else if (m == killer1[ply] || m == killer2[ply]) p->score += KILLERSORTSCORE; else if (ply > 2 && (m == killer1[ply-2] || m == killer2[ply-2])) p->score += KILLERSORTSCORE; p->score += history[side][(p->move & 0x0FFF)] + taxicab[f][D5] - taxicab[t][E4]; if ( cboard[f] == pawn ) { /* Look at pushing Passed pawns first */ if ( (enemyP & PassedPawnMask[side][t]) == NULLBITBOARD ) p->score +=50; } } }
false
false
false
false
false
0
set_alternating_send(int rate) { if( rate <= 0 || rate > 100 || (sync_test_level != 0 && rate != 1) ) { err_here(); // must not have any sync testing to enable alternating send // tell_random_seed and crc checking must send data every frame } else alternating_send_rate = rate; }
false
false
false
false
false
0
check_locale_name(const char *locale) { bool ret; int category = LC_CTYPE; char *save; save = setlocale(category, NULL); if (!save) return false; /* should not happen; */ save = xstrdup(save); ret = (setlocale(category, locale) != NULL); setlocale(category, save); free(save); /* should we exit here? */ if (!ret) fprintf(stderr, _("%s: invalid locale name \"%s\"\n"), progname, locale); return ret; }
false
false
false
false
false
0
summary_compile_simplify_regexp(gchar *simplify_subject_regexp) { int err; gchar buf[BUFFSIZE]; regex_t *preg = NULL; preg = g_new0(regex_t, 1); err = string_match_precompile(simplify_subject_regexp, preg, REG_EXTENDED); if (err) { regerror(err, preg, buf, BUFFSIZE); alertpanel_error(_("Regular expression (regexp) error:\n%s"), buf); g_free(preg); preg = NULL; } return preg; }
false
false
false
false
false
0
cairo_MeasureString (GpGraphics *graphics, GDIPCONST WCHAR *stringUnicode, int length, GDIPCONST GpFont *font, GDIPCONST RectF *rc, GDIPCONST GpStringFormat *format, RectF *boundingBox, int *codepointsFitted, int *linesFilled) { cairo_matrix_t SavedMatrix; GpStringFormat *fmt; GpStringDetailStruct *StringDetails; WCHAR *CleanString; int StringLen = length; GpStatus status; status = AllocStringData (&CleanString, &StringDetails, length); if (status != Ok) return status; /* a NULL format is valid, it means get the generic default values (and free them later) */ if (!format) { GdipStringFormatGetGenericDefault ((GpStringFormat **)&fmt); } else { fmt = (GpStringFormat *)format; } /* is the following ok ? */ cairo_get_font_matrix (graphics->ct, &SavedMatrix); status = MeasureString (graphics, stringUnicode, &StringLen, font, rc, fmt, NULL, boundingBox, codepointsFitted, linesFilled, CleanString, StringDetails, NULL); /* Restore matrix to original values */ cairo_set_font_matrix (graphics->ct, &SavedMatrix); /* Cleanup */ GdipFree (CleanString); GdipFree (StringDetails); /* we must delete the default stringformat (when one wasn't provided by the caller) */ if (format != fmt) GdipDeleteStringFormat (fmt); return status; }
false
false
false
false
false
0
copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, DebugLoc DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const { bool GPRDest = ARM::GPRRegClass.contains(DestReg); bool GPRSrc = ARM::GPRRegClass.contains(SrcReg); if (GPRDest && GPRSrc) { AddDefaultCC(AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::MOVr), DestReg) .addReg(SrcReg, getKillRegState(KillSrc)))); return; } bool SPRDest = ARM::SPRRegClass.contains(DestReg); bool SPRSrc = ARM::SPRRegClass.contains(SrcReg); unsigned Opc = 0; if (SPRDest && SPRSrc) Opc = ARM::VMOVS; else if (GPRDest && SPRSrc) Opc = ARM::VMOVRS; else if (SPRDest && GPRSrc) Opc = ARM::VMOVSR; else if (ARM::DPRRegClass.contains(DestReg, SrcReg)) Opc = ARM::VMOVD; else if (ARM::QPRRegClass.contains(DestReg, SrcReg)) Opc = ARM::VORRq; if (Opc) { MachineInstrBuilder MIB = BuildMI(MBB, I, DL, get(Opc), DestReg); MIB.addReg(SrcReg, getKillRegState(KillSrc)); if (Opc == ARM::VORRq) MIB.addReg(SrcReg, getKillRegState(KillSrc)); AddDefaultPred(MIB); return; } // Generate instructions for VMOVQQ and VMOVQQQQ pseudos in place. if (ARM::QQPRRegClass.contains(DestReg, SrcReg) || ARM::QQQQPRRegClass.contains(DestReg, SrcReg)) { const TargetRegisterInfo *TRI = &getRegisterInfo(); assert(ARM::qsub_0 + 3 == ARM::qsub_3 && "Expected contiguous enum."); unsigned EndSubReg = ARM::QQPRRegClass.contains(DestReg, SrcReg) ? ARM::qsub_1 : ARM::qsub_3; for (unsigned i = ARM::qsub_0, e = EndSubReg + 1; i != e; ++i) { unsigned Dst = TRI->getSubReg(DestReg, i); unsigned Src = TRI->getSubReg(SrcReg, i); MachineInstrBuilder Mov = AddDefaultPred(BuildMI(MBB, I, I->getDebugLoc(), get(ARM::VORRq)) .addReg(Dst, RegState::Define) .addReg(Src, getKillRegState(KillSrc)) .addReg(Src, getKillRegState(KillSrc))); if (i == EndSubReg) { Mov->addRegisterDefined(DestReg, TRI); if (KillSrc) Mov->addRegisterKilled(SrcReg, TRI); } } return; } llvm_unreachable("Impossible reg-to-reg copy"); }
false
false
false
false
false
0
yy_HtmlAttribute() { int yypos0= yypos, yythunkpos0= yythunkpos; yyprintf((stderr, "%s\n", "HtmlAttribute")); { int yypos1072= yypos, yythunkpos1072= yythunkpos; if (!yy_Alphanumeric()) goto l1073; goto l1072; l1073:; yypos= yypos1072; yythunkpos= yythunkpos1072; if (!yymatchChar('-')) goto l1069; } l1072:; l1070:; { int yypos1071= yypos, yythunkpos1071= yythunkpos; { int yypos1074= yypos, yythunkpos1074= yythunkpos; if (!yy_Alphanumeric()) goto l1075; goto l1074; l1075:; yypos= yypos1074; yythunkpos= yythunkpos1074; if (!yymatchChar('-')) goto l1071; } l1074:; goto l1070; l1071:; yypos= yypos1071; yythunkpos= yythunkpos1071; } if (!yy_Spnl()) goto l1069; { int yypos1076= yypos, yythunkpos1076= yythunkpos; if (!yymatchChar('=')) goto l1076; if (!yy_Spnl()) goto l1076; { int yypos1078= yypos, yythunkpos1078= yythunkpos; if (!yy_Quoted()) goto l1079; goto l1078; l1079:; yypos= yypos1078; yythunkpos= yythunkpos1078; if (!yy_Nonspacechar()) goto l1076; l1080:; { int yypos1081= yypos, yythunkpos1081= yythunkpos; if (!yy_Nonspacechar()) goto l1081; goto l1080; l1081:; yypos= yypos1081; yythunkpos= yythunkpos1081; } } l1078:; goto l1077; l1076:; yypos= yypos1076; yythunkpos= yythunkpos1076; } l1077:; if (!yy_Spnl()) goto l1069; yyprintf((stderr, " ok %s @ %s\n", "HtmlAttribute", yybuf+yypos)); return 1; l1069:; yypos= yypos0; yythunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "HtmlAttribute", yybuf+yypos)); return 0; }
false
false
false
false
false
0
bd_select_playlist(BLURAY *bd, uint32_t playlist) { char *f_name = str_printf("%05d.mpls", playlist); int result; bd_mutex_lock(&bd->mutex); if (bd->title_list) { /* update current title */ unsigned i; for (i = 0; i < bd->title_list->count; i++) { if (playlist == bd->title_list->title_info[i].mpls_id) { bd->title_idx = i; break; } } } result = _open_playlist(bd, f_name, 0); bd_mutex_unlock(&bd->mutex); X_FREE(f_name); return result; }
false
false
false
false
false
0
amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm) { struct amdgpu_device *adev = amdgpu_get_adev(ttm->bdev); struct amdgpu_ttm_tt *gtt = (void *)ttm; unsigned pinned = 0, nents; int r; int write = !(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY); enum dma_data_direction direction = write ? DMA_BIDIRECTIONAL : DMA_TO_DEVICE; if (current->mm != gtt->usermm) return -EPERM; if (gtt->userflags & AMDGPU_GEM_USERPTR_ANONONLY) { /* check that we only pin down anonymous memory to prevent problems with writeback */ unsigned long end = gtt->userptr + ttm->num_pages * PAGE_SIZE; struct vm_area_struct *vma; vma = find_vma(gtt->usermm, gtt->userptr); if (!vma || vma->vm_file || vma->vm_end < end) return -EPERM; } do { unsigned num_pages = ttm->num_pages - pinned; uint64_t userptr = gtt->userptr + pinned * PAGE_SIZE; struct page **pages = ttm->pages + pinned; r = get_user_pages(current, current->mm, userptr, num_pages, write, 0, pages, NULL); if (r < 0) goto release_pages; pinned += r; } while (pinned < ttm->num_pages); r = sg_alloc_table_from_pages(ttm->sg, ttm->pages, ttm->num_pages, 0, ttm->num_pages << PAGE_SHIFT, GFP_KERNEL); if (r) goto release_sg; r = -ENOMEM; nents = dma_map_sg(adev->dev, ttm->sg->sgl, ttm->sg->nents, direction); if (nents != ttm->sg->nents) goto release_sg; drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages, gtt->ttm.dma_address, ttm->num_pages); return 0; release_sg: kfree(ttm->sg); release_pages: release_pages(ttm->pages, pinned, 0); return r; }
false
false
false
false
false
0
operator| (const Bits& A) const { GIVARO_ASSERT( rep.size() == A.rep.size(), "[Bits]: invalide size in or"); size_t len = rep.size(); Rep res( len ); for (int i=0; i<int(len); ++i) res[i] = rep[i] | A.rep[i]; return Bits(res); }
false
false
false
false
false
0
load(const QString &name, const QVariantList &args, Plasma::Containment *containment) { const QString constraint = name.isEmpty() ? QString() : QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name); KService::List offers = KServiceTypeTrader::self()->query("Plasma/ToolBox", constraint); if (!offers.isEmpty()) { KService::Ptr offer = offers.first(); KPluginLoader plugin(*offer); if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) { return offer->createInstance<AbstractToolBox>(containment, args); } } return 0; }
false
false
false
false
false
0
widget_realize_cb (GtkWidget *widget, gpointer user_data) { GdkScreen *screen; NautilusDesktopBackground *self = user_data; screen = gtk_widget_get_screen (widget); if (self->details->screen_size_handler > 0) { g_signal_handler_disconnect (screen, self->details->screen_size_handler); } self->details->screen_size_handler = g_signal_connect (screen, "size-changed", G_CALLBACK (screen_size_changed), self); if (self->details->screen_monitors_handler > 0) { g_signal_handler_disconnect (screen, self->details->screen_monitors_handler); } self->details->screen_monitors_handler = g_signal_connect (screen, "monitors-changed", G_CALLBACK (screen_size_changed), self); init_fade (self); nautilus_desktop_background_set_up_widget (self); }
false
false
false
false
false
0
print_pid_suid(struct text_object *obj, char *p, int p_max_size) { #define SUIDNOTFOUND "Can't find the process saved set uid in '%s'" char *begin, *end, *buf = NULL; int bytes_read; asprintf(&buf, PROCDIR "/%d/status", strtopid(obj->data.s)); strcpy(obj->data.s, buf); free(buf); buf = readfile(obj->data.s, &bytes_read, 1); if(buf != NULL) { begin = strstr(buf, UID_ENTRY); if(begin != NULL) { begin = strchr(begin, '\t'); begin++; begin = strchr(begin, '\t'); begin++; begin = strchr(begin, '\t'); begin++; end = strchr(begin, '\t'); if(end != NULL) { *(end) = 0; } snprintf(p, p_max_size, "%s", begin); } else { NORM_ERR(SUIDNOTFOUND, obj->data.s); } free(buf); } }
false
true
false
false
false
1
_dl_name_match_p (const char *name, const struct link_map *map) { if (strcmp (name, map->l_name) == 0) return 1; struct libname_list *runp = map->l_libname; while (runp != NULL) if (strcmp (name, runp->name) == 0) return 1; else runp = runp->next; return 0; }
false
false
false
false
false
0
s5k4ecgx_config_gpio(int nr, int val, const char *name) { unsigned long flags = val ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; int ret; if (!gpio_is_valid(nr)) return 0; ret = gpio_request_one(nr, flags, name); if (!ret) gpio_export(nr, 0); return ret; }
false
false
false
false
false
0
IsInsideSurface(double x[3]) { // do a quick bounds check if ( x[0] < this->Bounds[0] || x[0] > this->Bounds[1] || x[1] < this->Bounds[2] || x[1] > this->Bounds[3] || x[2] < this->Bounds[4] || x[2] > this->Bounds[5]) { return 0; } // Perform in/out by shooting random rays. Multiple rays are fired // to improve accuracy of the result. // // The variable iterNumber counts the number of rays fired and is // limited by the defined variable VTK_MAX_ITER. // // The variable deltaVotes keeps track of the number of votes for // "in" versus "out" of the surface. When deltaVotes > 0, more votes // have counted for "in" than "out". When deltaVotes < 0, more votes // have counted for "out" than "in". When the delta_vote exceeds or // equals the defined variable VTK_VOTE_THRESHOLD, then the // appropriate "in" or "out" status is returned. // double rayMag, ray[3], xray[3], t, pcoords[3], xint[3]; int i, numInts, iterNumber, deltaVotes, subId; vtkIdType idx, numCells; double tol = this->Tolerance*this->Length; for (deltaVotes = 0, iterNumber = 1; (iterNumber < VTK_MAX_ITER) && (abs(deltaVotes) < VTK_VOTE_THRESHOLD); iterNumber++) { // Define a random ray to fire. rayMag = 0.0; while (rayMag == 0.0 ) { for (i=0; i<3; i++) { ray[i] = vtkMath::Random(-1.0,1.0); } rayMag = vtkMath::Norm(ray); } // The ray must be appropriately sized wrt the bounding box. (It has to go // all the way through the bounding box.) for (i=0; i<3; i++) { xray[i] = x[i] + (this->Length/rayMag)*ray[i]; } // Retrieve the candidate cells from the locator this->CellLocator->FindCellsAlongLine(x,xray,tol,this->CellIds); // Intersect the line with each of the candidate cells numInts = 0; numCells = this->CellIds->GetNumberOfIds(); for ( idx=0; idx < numCells; idx++ ) { this->Surface->GetCell(this->CellIds->GetId(idx), this->Cell); if ( this->Cell->IntersectWithLine(x, xray, tol, t, xint, pcoords, subId) ) { numInts++; } } //for all candidate cells // Count the result if ( (numInts % 2) == 0) { --deltaVotes; } else { ++deltaVotes; } } //try another ray // If the number of votes is positive, the point is inside // return ( deltaVotes < 0 ? 0 : 1 ); }
false
false
false
false
false
0
isNull() const { return d->_modeUid.isEmpty() && d->_formUid.isEmpty() && d->_emptyRootForms.isEmpty(); }
false
false
false
false
false
0
crypto_cert_release(krb5_context context, pkinit_cert_handle ch) { struct _pkinit_cert_data *cd = (struct _pkinit_cert_data *)ch; if (cd == NULL || cd->magic != CERT_MAGIC) return EINVAL; free(cd); return 0; }
false
false
false
false
false
0
reset(void) { QMutexLocker locker(&mutex); Space* rootSpace = root->getStatus() == FAILED ? NULL : root->getSpace(*na,curBest,c_d,a_d); if (curBest != NULL) { delete curBest; curBest = new BestNode(NULL); } if (root) { DisposeCursor dc(root,*na); PreorderNodeVisitor<DisposeCursor>(dc).run(); } delete na; na = new Node::NodeAllocator(curBest != NULL); int rootIdx = na->allocate(rootSpace); assert(rootIdx == 0); (void) rootIdx; root = (*na)[0]; root->setMarked(true); currentNode = root; pathHead = root; scale = 1.0; stats = Statistics(); for (int i=bookmarks.size(); i--;) emit removedBookmark(i); bookmarks.clear(); root->layout(*na); emit statusChanged(currentNode, stats, true); update(); }
false
false
false
false
false
0
dayofweek(int32_t year, int32_t mon, int32_t day) { _assert_(true); if (mon < 3) { year--; mon += 12; } return (day + ((8 + (13 * mon)) / 5) + (year + (year / 4) - (year / 100) + (year / 400))) % 7; }
false
false
false
false
false
0
ompfbe_upgrade_temp_var_pe_stms(Pe_statement *head) { Pe_statement *pe_stm; Statement *stm; for (pe_stm = head; pe_stm != NULL; pe_stm = pe_stm->next) { /* traverse here */ for (stm = pe_stm->stm_head; stm != NULL; stm = stm->next) { /* if (stm->ope == JUMP_KEI_OPE) */ ompfbe_upgrade_temp_var_statement(stm); } } }
false
false
false
false
false
0
gf_xml_get_element_namespace(GF_Node *n) { u32 i, count; if (n->sgprivate->tag==TAG_DOMFullNode) { GF_DOMFullNode *elt = (GF_DOMFullNode *)n; return elt->ns; } count = sizeof(xml_elements) / sizeof(struct xml_elt_def); for (i=0; i<count; i++) { if (n->sgprivate->tag==xml_elements[i].tag) return xml_elements[i].xmlns; } return GF_XMLNS_UNDEFINED; }
false
false
false
false
false
0
nodecompare(const void* a, const void* b) /* Helper function for qsort. */ { const Node* node1 = (const Node*)a; const Node* node2 = (const Node*)b; const double term1 = node1->distance; const double term2 = node2->distance; if (term1 < term2) return -1; if (term1 > term2) return +1; return 0; }
false
false
false
false
false
0