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
pkinit_client_req_fini(krb5_context context, krb5_clpreauth_moddata moddata, krb5_clpreauth_modreq modreq) { pkinit_req_context reqctx = (pkinit_req_context)modreq; pkiDebug("%s: received reqctx at %p\n", __FUNCTION__, reqctx); if (reqctx == NULL) return; if (reqctx->magic != PKINIT_REQ_CTX_MAGIC) { pkiDebug("%s: Bad magic value (%x) in req ctx\n", __FUNCTION__, reqctx->magic); return; } if (reqctx->opts != NULL) pkinit_fini_req_opts(reqctx->opts); if (reqctx->cryptoctx != NULL) pkinit_fini_req_crypto(reqctx->cryptoctx); if (reqctx->idctx != NULL) pkinit_fini_identity_crypto(reqctx->idctx); if (reqctx->idopts != NULL) pkinit_fini_identity_opts(reqctx->idopts); free(reqctx); return; }
false
false
false
false
false
0
capture(const QString &file) { Q_D(QCameraImageCapture); d->unsetError(); if (d->control) { return d->control->capture(file); } else { d->error = NotSupportedFeatureError; d->errorString = tr("Device does not support images capture."); emit error(-1, d->error, d->errorString); } return -1; }
false
false
false
false
false
0
_sync_idle_dosync_collectedexcludes(gpointer fpath_gp, gpointer flags_gp, gpointer arg_gp) { char *fpath = (char *)fpath_gp; indexes_t *indexes_p = ((struct dosync_arg *)arg_gp)->indexes_p; printf_ddd("Debug3: _sync_idle_dosync_collectedexcludes(): \"%s\", %u (%p).\n", fpath, GPOINTER_TO_INT(flags_gp), flags_gp); indexes_addexclude_aggr(indexes_p, strdup(fpath), (eventinfo_flags_t)GPOINTER_TO_INT(flags_gp)); return; }
false
false
false
false
false
0
gst_ximagesink_xcontext_clear (GstXImageSink * ximagesink) { GstXContext *xcontext; g_return_if_fail (GST_IS_XIMAGESINK (ximagesink)); GST_OBJECT_LOCK (ximagesink); if (ximagesink->xcontext == NULL) { GST_OBJECT_UNLOCK (ximagesink); return; } /* Take the xcontext reference and NULL it while we * clean it up, so that any buffer-alloced buffers * arriving after this will be freed correctly */ xcontext = ximagesink->xcontext; ximagesink->xcontext = NULL; GST_OBJECT_UNLOCK (ximagesink); gst_caps_unref (xcontext->caps); g_free (xcontext->par); g_free (ximagesink->par); ximagesink->par = NULL; if (xcontext->last_caps) gst_caps_replace (&xcontext->last_caps, NULL); g_mutex_lock (&ximagesink->x_lock); XCloseDisplay (xcontext->disp); g_mutex_unlock (&ximagesink->x_lock); g_free (xcontext); }
false
false
false
false
false
0
vmci_resource_add(struct vmci_resource *resource, enum vmci_resource_type resource_type, struct vmci_handle handle) { unsigned int idx; int result; spin_lock(&vmci_resource_table.lock); if (handle.resource == VMCI_INVALID_ID) { handle.resource = vmci_resource_find_id(handle.context, resource_type); if (handle.resource == VMCI_INVALID_ID) { result = VMCI_ERROR_NO_HANDLE; goto out; } } else if (vmci_resource_lookup(handle, resource_type)) { result = VMCI_ERROR_ALREADY_EXISTS; goto out; } resource->handle = handle; resource->type = resource_type; INIT_HLIST_NODE(&resource->node); kref_init(&resource->kref); init_completion(&resource->done); idx = vmci_resource_hash(resource->handle); hlist_add_head_rcu(&resource->node, &vmci_resource_table.entries[idx]); result = VMCI_SUCCESS; out: spin_unlock(&vmci_resource_table.lock); return result; }
false
false
false
false
false
0
kwbimage_generate(struct image_tool_params *params, struct image_type_params *tparams) { int alloc_len; void *hdr; int version = 0; version = image_version_file(params->imagename); if (version == 0) { alloc_len = sizeof(struct main_hdr_v0) + sizeof(struct ext_hdr_v0); } else { alloc_len = image_headersz_v1(params, NULL); #if defined(CONFIG_SYS_SPI_U_BOOT_OFFS) if (alloc_len > CONFIG_SYS_SPI_U_BOOT_OFFS) { fprintf(stderr, "Error: Image header (incl. SPL image) too big!\n"); fprintf(stderr, "header=0x%x CONFIG_SYS_SPI_U_BOOT_OFFS=0x%x!\n", alloc_len, CONFIG_SYS_SPI_U_BOOT_OFFS); fprintf(stderr, "Increase CONFIG_SYS_SPI_U_BOOT_OFFS!\n"); } else { alloc_len = CONFIG_SYS_SPI_U_BOOT_OFFS; } #endif } hdr = malloc(alloc_len); if (!hdr) { fprintf(stderr, "%s: malloc return failure: %s\n", params->cmdname, strerror(errno)); exit(EXIT_FAILURE); } memset(hdr, 0, alloc_len); tparams->header_size = alloc_len; tparams->hdr = hdr; return 0; }
false
false
false
false
true
1
operator<<(std::ostream& out, const HypothesisStackCubePruning& hypoColl) { HypothesisStackCubePruning::const_iterator iter; for (iter = hypoColl.begin() ; iter != hypoColl.end() ; ++iter) { const Hypothesis &hypo = **iter; out << hypo << endl; } return out; }
false
false
false
false
false
0
omitnumberedstring(Object o, Object numbers) { char *cp; int i; if (DXGetObjectClass(o) != CLASS_STRING) { DXSetError(ERROR_INTERNAL, "omitnumberedstring routine called on non-string input"); return NULL; } cp = DXGetString((String)o); if (!cp) { DXSetError(ERROR_DATA_INVALID, "input is an empty string, must be group or list"); return NULL; } /* default - delete first (and only) member of list. */ if (numbers == NULL) return (Object)DXNewArray(TYPE_STRING, CATEGORY_REAL, 1, 1); /* if numbers contains one item and the value is 0, return same as above. * otherwise if there is more than one item in the list * or the value isn't 0, it's an error. */ if (DXExtractInteger(numbers, &i) && (i == 0)) return (Object)DXNewArray(TYPE_STRING, CATEGORY_REAL, 1, 1); DXSetError(ERROR_BAD_PARAMETER, "'%s' must be 0, since the string has only one item", "which item"); return NULL; }
false
false
false
false
false
0
cavan_cache_write(struct cavan_cache *cache, const char *buff, size_t size) { const char *buff_bak = buff; const char *buff_end = buff + size; pthread_mutex_lock(&cache->lock); while (1) { size_t length, rcount; size_t remain; remain = buff_end - buff; if (remain == 0) { break; } while (1) { if (cache->tail < cache->head) { length = rcount = cache->head - cache->tail - 1; } else { rcount = cache->mem_end - cache->tail; length = rcount + (cache->head - cache->mem) - 1; } #if CAVAN_CACHE_DEBUG println("Write: head = %p, tail = %p, rcount = %d, length = %d, free_space = %d", cache->head, cache->tail, rcount, length, cavan_cache_free_space(cache)); #endif if (length > 0) { break; } if (cache->closed) { size = buff - buff_bak; goto out_pthread_mutex_unlock; } pthread_cond_wait(&cache->wrcond, &cache->lock); } if (length > remain) { length = remain; } if (length > rcount) { size_t lcount = length - rcount; memcpy(cache->tail, buff, rcount); memcpy(cache->mem, buff + rcount, lcount); cache->tail = cache->mem + lcount; } else { memcpy(cache->tail, buff, length); cache->tail += length; if (cache->tail >= cache->mem_end) { cache->tail = cache->mem; } } buff += length; pthread_cond_signal(&cache->rdcond); } out_pthread_mutex_unlock: pthread_mutex_unlock(&cache->lock); return size; }
false
false
false
false
false
0
parse_logic_expr(std::istream& in, scope_t * scope, const short flags) { value_expr node; if (peek_next_nonws(in) == '!') { char c; in.get(c); node.reset(new value_expr_t(value_expr_t::O_NOT)); node->set_left(parse_add_expr(in, scope, flags)); return node.release(); } node.reset(parse_add_expr(in, scope, flags)); if (node.get() && ! in.eof()) { char c = peek_next_nonws(in); if (c == '!' || c == '=' || c == '<' || c == '>') { in.get(c); switch (c) { case '!': case '=': { bool negate = c == '!'; if ((c = peek_next_nonws(in)) == '=') in.get(c); else unexpected(c, '='); value_expr prev(node.release()); node.reset(new value_expr_t(negate ? value_expr_t::O_NEQ : value_expr_t::O_EQ)); node->set_left(prev.release()); node->set_right(parse_add_expr(in, scope, flags)); break; } case '<': { value_expr prev(node.release()); node.reset(new value_expr_t(value_expr_t::O_LT)); if (peek_next_nonws(in) == '=') { in.get(c); node->kind = value_expr_t::O_LTE; } node->set_left(prev.release()); node->set_right(parse_add_expr(in, scope, flags)); break; } case '>': { value_expr prev(node.release()); node.reset(new value_expr_t(value_expr_t::O_GT)); if (peek_next_nonws(in) == '=') { in.get(c); node->kind = value_expr_t::O_GTE; } node->set_left(prev.release()); node->set_right(parse_add_expr(in, scope, flags)); break; } default: if (! in.eof()) unexpected(c); break; } } } return node.release(); }
false
false
false
false
false
0
save() { QString filename = DATA_PATH + "experience.dat"; QFile file( filename ); uint lastLevel = 0; if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writng\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE experience>" << endl; ts << "<experience>" << endl; uint nbLevels = _levels.count(); for( uint i = 0; i < nbLevels; i++ ) { ts << "\t<level>"; ts << ( _levels.at( i ) ) - lastLevel; ts << "</level>" << endl; lastLevel = _levels.at( i ) ; } ts << "</experience>" << endl; file.close(); return true; }
false
false
false
false
false
0
xdig2num(char const &dig) { if (isdigit(dig)) return dig - '0'; if ('a' <= dig && dig <= 'f') return dig - 'a' + 10; if ('A' <= dig && dig <= 'F') return dig - 'A' + 10; return 0; }
false
false
false
false
false
0
hcache_gui_init(void) { GtkTreeModel *model; gint n; STATIC_ASSERT(G_N_ELEMENTS(hcache_col_labels) == HCACHE_STATS_VISIBLE_COLUMNS); treeview_hcache = GTK_TREE_VIEW(gui_main_window_lookup("treeview_hcache")); model = GTK_TREE_MODEL(gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT)); for (n = 0; n < HCACHE_MAX; n++) { GtkTreeIter iter; if (n == HCACHE_NONE) continue; gtk_list_store_append(GTK_LIST_STORE(model), &iter); gtk_list_store_set(GTK_LIST_STORE(model), &iter, c_hcs_name, get_hcache_name(n), c_hcs_host_count, 0, c_hcs_hits, 0, c_hcs_misses, 0, (-1)); } for (n = 0; (guint) n < G_N_ELEMENTS(hcache_col_labels); n++) { add_column(treeview_hcache, n, (gfloat) (n != 0), _(hcache_col_labels[n].text)); } gtk_tree_view_set_model(treeview_hcache, model); tree_view_restore_widths(treeview_hcache, PROP_HCACHE_COL_WIDTHS); g_object_unref(model); tree_view_set_fixed_height_mode(treeview_hcache, TRUE); main_gui_add_timer(hcache_gui_timer); }
false
false
false
false
false
0
ad5380_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long info) { const unsigned int max_val = (1 << chan->scan_type.realbits); struct ad5380_state *st = iio_priv(indio_dev); switch (info) { case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_CALIBSCALE: if (val >= max_val || val < 0) return -EINVAL; return regmap_write(st->regmap, ad5380_info_to_reg(chan, info), val << chan->scan_type.shift); case IIO_CHAN_INFO_CALIBBIAS: val += (1 << chan->scan_type.realbits) / 2; if (val >= max_val || val < 0) return -EINVAL; return regmap_write(st->regmap, AD5380_REG_OFFSET(chan->address), val << chan->scan_type.shift); default: break; } return -EINVAL; }
false
false
false
false
false
0
split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error) { gchar *ptr; gchar c; gboolean escaped = FALSE, fresh = TRUE; gchar quote_char = '\0'; GString *str; str = g_string_new (""); ptr = (gchar *) cmdline; while ((c = *ptr++) != '\0') { if (escaped) { /* * \CHAR is only special inside a double quote if CHAR is * one of: $`"\ and newline */ if (quote_char == '\"'){ if (!(c == '$' || c == '`' || c == '"' || c == '\\')) g_string_append_c (str, '\\'); g_string_append_c (str, c); } else { if (!g_ascii_isspace (c)) g_string_append_c (str, c); } escaped = FALSE; } else if (quote_char) { if (c == quote_char) { quote_char = '\0'; if (fresh && (g_ascii_isspace (*ptr) || *ptr == '\0')){ g_ptr_array_add (array, g_string_free (str, FALSE)); str = g_string_new (""); } } else if (c == '\\'){ escaped = TRUE; } else g_string_append_c (str, c); } else if (g_ascii_isspace (c)) { if (str->len > 0) { g_ptr_array_add (array, g_string_free (str, FALSE)); str = g_string_new (""); } } else if (c == '\\') { escaped = TRUE; } else if (c == '\'' || c == '"') { fresh = str->len == 0; quote_char = c; } else { g_string_append_c (str, c); } } if (escaped) { if (error) *error = g_error_new (G_LOG_DOMAIN, 0, "Unfinished escape."); g_string_free (str, TRUE); return -1; } if (quote_char) { if (error) *error = g_error_new (G_LOG_DOMAIN, 0, "Unfinished quote."); g_string_free (str, TRUE); return -1; } if (str->len > 0) { g_ptr_array_add (array, g_string_free (str, FALSE)); } else { g_string_free (str, TRUE); } g_ptr_array_add (array, NULL); return 0; }
false
false
false
false
false
0
build_curseg(struct f2fs_sb_info *sbi) { struct curseg_info *array; int i; array = kcalloc(NR_CURSEG_TYPE, sizeof(*array), GFP_KERNEL); if (!array) return -ENOMEM; SM_I(sbi)->curseg_array = array; for (i = 0; i < NR_CURSEG_TYPE; i++) { mutex_init(&array[i].curseg_mutex); array[i].sum_blk = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL); if (!array[i].sum_blk) return -ENOMEM; array[i].segno = NULL_SEGNO; array[i].next_blkoff = 0; } return restore_curseg_summaries(sbi); }
false
false
false
false
false
0
close_listeners(void) { aClient *acptr, *bcptr; aConfItem *aconf; /* * close all 'extra' listening ports we have and unlink the file * name if it was a unix socket. */ for (acptr = ListenerLL; acptr; acptr = bcptr) { aconf = acptr->confs->value.aconf; bcptr = acptr->next; /* might get deleted by close_connection */ if (IsIllegal(aconf)) { #ifdef UNIXPORT if (IsUnixSocket(acptr)) { sprintf(unixpath, "%s/%d", aconf->host, aconf->port); (void)unlink(unixpath); } #endif if (aconf->clients > 0) { close_client_fd(acptr); } else { close_connection(acptr); } } } }
false
false
false
false
false
0
GFMethod_consGF2m(const mp_int *irr, const unsigned int irr_arr[5]) { mp_err res = MP_OKAY; int ret; GFMethod *meth = NULL; meth = GFMethod_new(); if (meth == NULL) return NULL; MP_CHECKOK(mp_copy(irr, &meth->irr)); if (irr_arr != NULL) { /* Irreducible polynomials are either trinomials or pentanomials. */ meth->irr_arr[0] = irr_arr[0]; meth->irr_arr[1] = irr_arr[1]; meth->irr_arr[2] = irr_arr[2]; if (irr_arr[2] > 0) { meth->irr_arr[3] = irr_arr[3]; meth->irr_arr[4] = irr_arr[4]; } else { meth->irr_arr[3] = meth->irr_arr[4] = 0; } } else { ret = mp_bpoly2arr(irr, meth->irr_arr, 5); /* Irreducible polynomials are either trinomials or pentanomials. */ if ((ret != 5) && (ret != 3)) { res = MP_UNDEF; goto CLEANUP; } } meth->field_add = &ec_GF2m_add; meth->field_neg = &ec_GF2m_neg; meth->field_sub = &ec_GF2m_add; meth->field_mod = &ec_GF2m_mod; meth->field_mul = &ec_GF2m_mul; meth->field_sqr = &ec_GF2m_sqr; meth->field_div = &ec_GF2m_div; meth->field_enc = NULL; meth->field_dec = NULL; meth->extra1 = NULL; meth->extra2 = NULL; meth->extra_free = NULL; CLEANUP: if (res != MP_OKAY) { GFMethod_free(meth); return NULL; } return meth; }
false
false
false
false
false
0
take_off(void) { char desc[ROGUE_COLUMNS]; object *obj; if (rogue.armor) { if (rogue.armor->is_cursed) { message(curse_message, 0); } else { mv_aquatars(); obj = rogue.armor; unwear(rogue.armor); #if defined( JAPAN ) get_desc(obj, desc, 0); (void) strcat(desc, mesg[94]); #else /* not JAPAN */ (void) strcpy(desc, mesg[94]); get_desc(obj, desc + strlen(mesg[94]), 0); #endif /* not JAPAN */ message(desc, 0); print_stats(STAT_ARMOR); (void) reg_move(); } } else { message(mesg[95], 0); } }
true
true
false
false
false
1
test_clone_empty__can_clone_an_empty_local_repo_barely(void) { char *local_name = "refs/heads/master"; const char *expected_tracked_branch_name = "refs/remotes/origin/master"; const char *expected_remote_name = "origin"; git_buf buf = GIT_BUF_INIT; git_reference *ref; cl_set_cleanup(&cleanup_repository, "./empty"); g_options.bare = true; cl_git_pass(git_clone(&g_repo_cloned, "./empty_bare.git", "./empty", &g_options)); /* Although the HEAD is unborn... */ cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo_cloned, local_name)); /* ...one can still retrieve the name of the remote tracking reference */ cl_git_pass(git_branch_upstream_name(&buf, g_repo_cloned, local_name)); cl_assert_equal_s(expected_tracked_branch_name, buf.ptr); git_buf_free(&buf); /* ...and the name of the remote... */ cl_git_pass(git_branch_remote_name(&buf, g_repo_cloned, expected_tracked_branch_name)); cl_assert_equal_s(expected_remote_name, buf.ptr); git_buf_free(&buf); /* ...even when the remote HEAD is unborn as well */ cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo_cloned, expected_tracked_branch_name)); }
false
false
false
false
false
0
Initialize( hid_t hDatasetID, const char *pszName ) { SetDescription( pszName ); this->hDatasetID = hDatasetID; hid_t datatype = H5Dget_type( hDatasetID ); dataspace = H5Dget_space( hDatasetID ); int n_dims = H5Sget_simple_extent_ndims( dataspace ); native = H5Tget_native_type( datatype, H5T_DIR_ASCEND ); hsize_t dims[3], maxdims[3]; eDataType = GH5_GetDataType( native ); if( n_dims == 2 ) { H5Sget_simple_extent_dims( dataspace, dims, maxdims ); nRasterXSize = (int) dims[1]; nRasterYSize = (int) dims[0]; } else { CPLError( CE_Failure, CPLE_AppDefined, "Dataset not of rank 2." ); return false; } nBlockXSize = nRasterXSize; nBlockYSize = 1; /* -------------------------------------------------------------------- */ /* Check for chunksize, and use it as blocksize for optimized */ /* reading. */ /* -------------------------------------------------------------------- */ hid_t listid = H5Dget_create_plist( hDatasetID ); if (listid>0) { if(H5Pget_layout(listid) == H5D_CHUNKED) { hsize_t panChunkDims[3]; int nDimSize = H5Pget_chunk(listid, 3, panChunkDims); nBlockXSize = (int) panChunkDims[nDimSize-1]; nBlockYSize = (int) panChunkDims[nDimSize-2]; } int nfilters = H5Pget_nfilters( listid ); H5Z_filter_t filter; char name[120]; size_t cd_nelmts = 20; unsigned int cd_values[20]; unsigned int flags; for (int i = 0; i < nfilters; i++) { filter = H5Pget_filter(listid, i, &flags, (size_t *)&cd_nelmts, cd_values, 120, name); if (filter == H5Z_FILTER_DEFLATE) poDS->SetMetadataItem( "COMPRESSION", "DEFLATE", "IMAGE_STRUCTURE" ); else if (filter == H5Z_FILTER_NBIT) poDS->SetMetadataItem( "COMPRESSION", "NBIT", "IMAGE_STRUCTURE" ); else if (filter == H5Z_FILTER_SCALEOFFSET) poDS->SetMetadataItem( "COMPRESSION", "SCALEOFFSET", "IMAGE_STRUCTURE" ); else if (filter == H5Z_FILTER_SZIP) poDS->SetMetadataItem( "COMPRESSION", "SZIP", "IMAGE_STRUCTURE" ); } H5Pclose(listid); } /* -------------------------------------------------------------------- */ /* Load min/max information. */ /* -------------------------------------------------------------------- */ if( EQUAL(pszName,"elevation") && GH5_FetchAttribute( hDatasetID, "Maximum Elevation Value", dfMaximum ) && GH5_FetchAttribute( hDatasetID, "Minimum Elevation Value", dfMinimum ) ) bMinMaxSet = true; else if( EQUAL(pszName,"uncertainty") && GH5_FetchAttribute( hDatasetID, "Maximum Uncertainty Value", dfMaximum ) && GH5_FetchAttribute( hDatasetID, "Minimum Uncertainty Value", dfMinimum ) ) bMinMaxSet = true; else if( EQUAL(pszName,"nominal_elevation") && GH5_FetchAttribute( hDatasetID, "max_value", dfMaximum ) && GH5_FetchAttribute( hDatasetID, "min_value", dfMinimum ) ) bMinMaxSet = true; return true; }
false
false
false
false
false
0
glade_widget_set_object (GladeWidget * gwidget, GObject * new_object) { GObject *old_object; g_return_if_fail (GLADE_IS_WIDGET (gwidget)); g_return_if_fail (new_object == NULL || g_type_is_a (G_OBJECT_TYPE (new_object), glade_widget_adaptor_get_object_type (gwidget->priv->adaptor))); if (gwidget->priv->object == new_object) return; old_object = gwidget->priv->object; gwidget->priv->object = new_object; if (new_object) { /* Add internal reference to new widget if its not internal */ if (gwidget->priv->internal == NULL) { /* Assume initial ref count of all objects */ if (G_IS_INITIALLY_UNOWNED (new_object)) g_object_ref_sink (new_object); } g_object_set_qdata (G_OBJECT (new_object), glade_widget_name_quark, gwidget); if (g_type_is_a (glade_widget_adaptor_get_object_type (gwidget->priv->adaptor), GTK_TYPE_WIDGET)) { /* Disable any built-in DnD */ gtk_drag_dest_unset (GTK_WIDGET (new_object)); gtk_drag_source_unset (GTK_WIDGET (new_object)); /* We nee to make sure all widgets set the event glade core needs */ glade_widget_add_events (GTK_WIDGET (new_object)); ubuntu_show_menu_bars (GTK_WIDGET (new_object)); } } /* Remove internal reference to old widget */ if (old_object) { if (gwidget->priv->internal == NULL) { GLADE_NOTE (REF_COUNTS, g_print ("Killing '%s::%s' widget's object with reference count %d\n", glade_widget_adaptor_get_name (gwidget->priv->adaptor), gwidget->priv->name ? gwidget->priv->name : "(unknown)", old_object->ref_count)); /* Have the adaptor for this widget break any additional references */ glade_widget_adaptor_destroy_object (gwidget->priv->adaptor, old_object); } /* From this point on, the GladeWidget is no longer retrievable with * glade_widget_get_from_gobject()... we let it be for the duration * of ->destroy_object() */ g_object_set_qdata (G_OBJECT (old_object), glade_widget_name_quark, NULL); if (gwidget->priv->internal == NULL) g_object_unref (old_object); } g_object_notify_by_pspec (G_OBJECT (gwidget), properties[PROP_OBJECT]); }
false
false
false
false
false
0
o_arc_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current) { if (o_current->arc == NULL) { return; } gschem_cairo_arc (w_current, o_current->line_width, o_current->arc->x, o_current->arc->y, o_current->arc->width / 2, o_current->arc->start_angle, o_current->arc->end_angle); gschem_cairo_set_source_color (w_current, o_drawing_color (w_current, o_current)); gschem_cairo_stroke (w_current, o_current->line_type, o_current->line_end, o_current->line_width, o_current->line_length, o_current->line_space); if (o_current->selected && w_current->draw_grips == TRUE) { o_arc_draw_grips (w_current, o_current); } }
false
false
false
false
false
0
esl_scorematrix_ExpectedScore(ESL_SCOREMATRIX *S, double *fi, double *fj, double *ret_E) { double E = 0.; int a,b; for (a = 0; a < S->K; a++) for (b = 0; b < S->K; b++) E += fi[a] * fj[b] * (double) S->s[a][b]; *ret_E = E; return eslOK; }
false
false
false
false
false
0
mca_base_component_compare(const mca_base_component_t* aa, const mca_base_component_t* bb) { int val; val = strncmp(aa->mca_type_name, bb->mca_type_name, MCA_BASE_MAX_TYPE_NAME_LEN); if (val != 0) { return -val; } val = strncmp(aa->mca_component_name, bb->mca_component_name, MCA_BASE_MAX_COMPONENT_NAME_LEN); if (val != 0) { return -val; } /* The names were equal, so compare the versions */ if (aa->mca_component_major_version > bb->mca_component_major_version) { return -1; } else if (aa->mca_component_major_version < bb->mca_component_major_version) { return 1; } else if (aa->mca_component_minor_version > bb->mca_component_minor_version) { return -1; } else if (aa->mca_component_minor_version < bb->mca_component_minor_version) { return 1; } else if (aa->mca_component_release_version > bb->mca_component_release_version) { return -1; } else if (aa->mca_component_release_version < bb->mca_component_release_version) { return 1; } return 0; }
false
false
false
false
false
0
clearArea(int x, int y, unsigned int width, unsigned int height, bool exposures) { // TODO: probably could call renderForeground here (with x,y,w,h) if (m_lastbg_pm == ParentRelative && m_renderer) FbWindow::clear(); else XClearArea(display(), window(), x, y, width, height, exposures); }
false
false
false
false
false
0
getEdgeProbability(const BasicBlock *Src, const BasicBlock *Dst) const { uint32_t N = getEdgeWeight(Src, Dst); uint32_t D = getSumForBlock(Src); // It is possible that the edge weight on the only successor edge of Src is // zero, in which case we return 100%. if (N == 0 && D == 0) return BranchProbability::getOne(); return BranchProbability(N, D); }
false
false
false
false
false
0
copytree() { /* Make a complete copy of the current tree for undo purposes */ if (whichtree == 1) othertree = 0; else othertree = 1; treesets[othertree].root = copytrav(root); treesets[othertree].nonodes = nonodes; treesets[othertree].waswritten = waswritten; treesets[othertree].hasmult = hasmult; treesets[othertree].haslengths = haslengths; treesets[othertree].nolengths = nolengths; treesets[othertree].initialized = true; }
false
false
false
false
false
0
leah_c0(void) { UINT32 src1 = SRC1VAL; UINT32 src2 = SRC2VAL; UINT32 dst = src1 + (src2 << 1); SET_ZNCV_ADD(dst, src1, src2); if (src1 & 0x80000000) SET_CFLAG(1); if ((src1 ^ (src1 >> 1)) & 0x40000000) SET_VFLAG(1); }
false
false
false
false
false
0
FT_Stroker_New( FT_Library library, FT_Stroker *astroker ) { FT_Error error; FT_Memory memory; FT_Stroker stroker = NULL; if ( !library ) return FT_Err_Invalid_Argument; memory = library->memory; if ( !FT_NEW( stroker ) ) { stroker->library = library; ft_stroke_border_init( &stroker->borders[0], memory ); ft_stroke_border_init( &stroker->borders[1], memory ); } *astroker = stroker; return error; }
false
false
false
false
false
0
mktoken(const char *hash, const char *t, time_t now) { char now_s[NUMBUFSIZE]; char *p; unsigned char *q; int i; char *r; libmail_strh_time_t(now, now_s); p=malloc(strlen(hash)+strlen(now_s)+3+hmac_sha1.hh_L*2); if (!p) return (NULL); strcat(strcpy(p, hash), now_s); q=malloc(hmac_sha1.hh_L*3); if (!q) { free(p); return (NULL); } hmac_hashkey(&hmac_sha1, t, sizeof(cur_token), q, q + hmac_sha1.hh_L); hmac_hashtext(&hmac_sha1, p, strlen(p), q, q + hmac_sha1.hh_L, q + hmac_sha1.hh_L*2); strcpy(p, now_s); r=p + strlen(p); *r++='-'; for (i=0; i<hmac_sha1.hh_L; i++) { int c=(unsigned char)q[hmac_sha1.hh_L*2+i]; *r++ = xdigit[c / 16]; *r++ = xdigit[c % 16]; } *r=0; free(q); return (p); }
false
false
false
false
false
0
print_voicecodes() { int i; if (voicecodes == 0) return; printf("voice mapping:\n"); for (i=0;i<voicecodes;i++) { if(i%4 == 3) printf("\n"); printf("%s %d ",voicecode[i],i+1); } printf("\n"); }
false
false
false
false
false
0
setComboStyle(FXuint mode){ FXuint opts=(options&~COMBOBOX_MASK)|(mode&COMBOBOX_MASK); if(opts!=options){ options=opts; if(options&COMBOBOX_STATIC){ field->setEditable(FALSE); // Non-editable list->setScrollStyle(SCROLLERS_TRACK|HSCROLLING_OFF); // No scrolling } else{ field->setEditable(TRUE); // Editable list->setScrollStyle(SCROLLERS_TRACK|HSCROLLER_NEVER); // Scrollable, but no scrollbar } recalc(); } }
false
false
false
false
false
0
ReachWithSpellCure(Unit* pVictim) { if (!pVictim) { return NULL; } for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) { if (!m_spells[i]) { continue; } SpellEntry const* spellInfo = sSpellStore.LookupEntry(m_spells[i]); if (!spellInfo) { sLog.outError("WORLD: unknown spell id %i", m_spells[i]); continue; } bool bcontinue = true; for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { if ((spellInfo->Effect[j] == SPELL_EFFECT_HEAL)) { bcontinue = false; break; } } if (bcontinue) { continue; } if (spellInfo->manaCost > GetPower(POWER_MANA)) { continue; } SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); float range = GetSpellMaxRange(srange); float minrange = GetSpellMinRange(srange); float dist = GetCombatDistance(pVictim, spellInfo->rangeIndex == SPELL_RANGE_IDX_COMBAT); // if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) // continue; if (dist > range || dist < minrange) { continue; } if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) { continue; } if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) { continue; } return spellInfo; } return NULL; }
false
false
false
false
false
0
fso_framework_kernel_removeModule (const gchar* filename, gboolean wait, gboolean force, GError** error) { guint flags = 0U; gboolean _tmp0_ = FALSE; gboolean _tmp2_ = FALSE; glong ok = 0L; const gchar* _tmp4_ = NULL; guint _tmp5_ = 0U; glong _tmp6_ = 0L; glong _tmp7_ = 0L; GError * _inner_error_ = NULL; g_return_if_fail (filename != NULL); flags = (guint) (O_EXCL | O_NONBLOCK); _tmp0_ = wait; if (_tmp0_) { guint _tmp1_ = 0U; _tmp1_ = flags; flags = _tmp1_ & (~O_NONBLOCK); } _tmp2_ = force; if (_tmp2_) { guint _tmp3_ = 0U; _tmp3_ = flags; flags = _tmp3_ | O_TRUNC; } _tmp4_ = filename; _tmp5_ = flags; _tmp6_ = delete_module (_tmp4_, _tmp5_); ok = _tmp6_; _tmp7_ = ok; if (_tmp7_ != ((glong) 0)) { gint _tmp8_ = 0; const gchar* _tmp9_ = NULL; const gchar* _tmp10_ = NULL; gchar* _tmp11_ = NULL; gchar* _tmp12_ = NULL; GError* _tmp13_ = NULL; GError* _tmp14_ = NULL; _tmp8_ = errno; _tmp9_ = g_strerror (_tmp8_); _tmp10_ = string_to_string (_tmp9_); _tmp11_ = g_strconcat ("Can't insert module: ", _tmp10_, NULL); _tmp12_ = _tmp11_; _tmp13_ = g_error_new_literal (SYSTEM_ERROR, SYSTEM_ERROR_ERROR, _tmp12_); _tmp14_ = _tmp13_; _g_free0 (_tmp12_); _inner_error_ = _tmp14_; g_propagate_error (error, _inner_error_); return; } }
false
false
false
false
false
0
wilc_wlan_firmware_download(const u8 *buffer, u32 buffer_size) { wilc_wlan_dev_t *p = &g_wlan; u32 offset; u32 addr, size, size2, blksz; u8 *dma_buffer; int ret = 0; blksz = BIT(12); /* Allocate a DMA coherent buffer. */ dma_buffer = kmalloc(blksz, GFP_KERNEL); if (dma_buffer == NULL) { /*EIO 5*/ ret = -5; PRINT_ER("Can't allocate buffer for firmware download IO error\n "); goto _fail_1; } PRINT_D(INIT_DBG, "Downloading firmware size = %d ...\n", buffer_size); /** * load the firmware **/ offset = 0; do { memcpy(&addr, &buffer[offset], 4); memcpy(&size, &buffer[offset + 4], 4); #ifdef BIG_ENDIAN addr = BYTE_SWAP(addr); size = BYTE_SWAP(size); #endif acquire_bus(ACQUIRE_ONLY); offset += 8; while (((int)size) && (offset < buffer_size)) { if (size <= blksz) size2 = size; else size2 = blksz; /* Copy firmware into a DMA coherent buffer */ memcpy(dma_buffer, &buffer[offset], size2); ret = p->hif_func.hif_block_tx(addr, dma_buffer, size2); if (!ret) break; addr += size2; offset += size2; size -= size2; } release_bus(RELEASE_ONLY); if (!ret) { /*EIO 5*/ ret = -5; PRINT_ER("Can't download firmware IO error\n "); goto _fail_; } PRINT_D(INIT_DBG, "Offset = %d\n", offset); } while (offset < buffer_size); _fail_: kfree(dma_buffer); _fail_1: return (ret < 0) ? ret : 0; }
false
true
false
false
false
1
cleanup() { d->mode = Idle; // stop any dns if(d->dns.isBusy()) d->dns.stop(); if(d->srv.isBusy()) d->srv.stop(); // destroy the bytestream, if there is one delete d->bs; d->bs = 0; d->multi = false; d->using_srv = false; d->will_be_ssl = false; d->probe_mode = -1; setUseSSL(false); setPeerAddressNone(); }
false
false
false
false
false
0
sas_host_match(struct attribute_container *cont, struct device *dev) { struct Scsi_Host *shost; struct sas_internal *i; if (!scsi_is_host_device(dev)) return 0; shost = dev_to_shost(dev); if (!shost->transportt) return 0; if (shost->transportt->host_attrs.ac.class != &sas_host_class.class) return 0; i = to_sas_internal(shost->transportt); return &i->t.host_attrs.ac == cont; }
false
false
false
false
false
0
intel_gen6_powersave_work(struct work_struct *work) { struct drm_i915_private *dev_priv = container_of(work, struct drm_i915_private, rps.delayed_resume_work.work); struct drm_device *dev = dev_priv->dev; mutex_lock(&dev_priv->rps.hw_lock); gen6_reset_rps_interrupts(dev); if (IS_CHERRYVIEW(dev)) { cherryview_enable_rps(dev); } else if (IS_VALLEYVIEW(dev)) { valleyview_enable_rps(dev); } else if (INTEL_INFO(dev)->gen >= 9) { gen9_enable_rc6(dev); gen9_enable_rps(dev); if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) __gen6_update_ring_freq(dev); } else if (IS_BROADWELL(dev)) { gen8_enable_rps(dev); __gen6_update_ring_freq(dev); } else { gen6_enable_rps(dev); __gen6_update_ring_freq(dev); } WARN_ON(dev_priv->rps.max_freq < dev_priv->rps.min_freq); WARN_ON(dev_priv->rps.idle_freq > dev_priv->rps.max_freq); WARN_ON(dev_priv->rps.efficient_freq < dev_priv->rps.min_freq); WARN_ON(dev_priv->rps.efficient_freq > dev_priv->rps.max_freq); dev_priv->rps.enabled = true; gen6_enable_rps_interrupts(dev); mutex_unlock(&dev_priv->rps.hw_lock); intel_runtime_pm_put(dev_priv); }
false
false
false
false
false
0
player_controller_remove_from_menu (PlayerController* self) { gboolean* _tmp13_ = NULL; gboolean _tmp14_ = FALSE; g_return_if_fail (self != NULL); { GeeArrayList* _item_list = NULL; GeeArrayList* _tmp0_ = NULL; GeeArrayList* _tmp1_ = NULL; gint _item_size = 0; GeeArrayList* _tmp2_ = NULL; gint _tmp3_ = 0; gint _tmp4_ = 0; gint _item_index = 0; _tmp0_ = self->custom_items; _tmp1_ = _g_object_ref0 (_tmp0_); _item_list = _tmp1_; _tmp2_ = _item_list; _tmp3_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp2_); _tmp4_ = _tmp3_; _item_size = _tmp4_; _item_index = -1; while (TRUE) { gint _tmp5_ = 0; gint _tmp6_ = 0; gint _tmp7_ = 0; PlayerItem* item = NULL; GeeArrayList* _tmp8_ = NULL; gint _tmp9_ = 0; gpointer _tmp10_ = NULL; DbusmenuMenuitem* _tmp11_ = NULL; PlayerItem* _tmp12_ = NULL; _tmp5_ = _item_index; _item_index = _tmp5_ + 1; _tmp6_ = _item_index; _tmp7_ = _item_size; if (!(_tmp6_ < _tmp7_)) { break; } _tmp8_ = _item_list; _tmp9_ = _item_index; _tmp10_ = gee_abstract_list_get ((GeeAbstractList*) _tmp8_, _tmp9_); item = (PlayerItem*) _tmp10_; _tmp11_ = self->root_menu; _tmp12_ = item; dbusmenu_menuitem_child_delete (_tmp11_, (DbusmenuMenuitem*) _tmp12_); _g_object_unref0 (item); } _g_object_unref0 (_item_list); } _tmp13_ = self->use_playlists; _tmp14_ = TRUE; if (_bool_equal (_tmp13_, &_tmp14_) == TRUE) { PlaylistsMenuitem* playlists_menuitem = NULL; GeeArrayList* _tmp15_ = NULL; gpointer _tmp16_ = NULL; PlayerItem* _tmp17_ = NULL; PlaylistsMenuitem* _tmp18_ = NULL; DbusmenuMenuitem* _tmp19_ = NULL; PlaylistsMenuitem* _tmp20_ = NULL; DbusmenuMenuitem* _tmp21_ = NULL; _tmp15_ = self->custom_items; _tmp16_ = gee_abstract_list_get ((GeeAbstractList*) _tmp15_, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); _tmp17_ = (PlayerItem*) _tmp16_; _tmp18_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp17_, TYPE_PLAYLISTS_MENUITEM) ? ((PlaylistsMenuitem*) _tmp17_) : NULL; if (_tmp18_ == NULL) { _g_object_unref0 (_tmp17_); } playlists_menuitem = _tmp18_; _tmp19_ = self->root_menu; _tmp20_ = playlists_menuitem; _tmp21_ = _tmp20_->root_item; dbusmenu_menuitem_child_delete (_tmp19_, _tmp21_); _g_object_unref0 (playlists_menuitem); } }
false
false
false
true
false
1
dc_setReplyHostName(const char *s) { if( (s == NULL) || (getenv("DCACHE_REPLY") != NULL) ) return; if( hostName != NULL ) free(hostName); dc_debug(DC_INFO, "Binding client callback hostname to %s.", s); hostName = (char *)strdup(s); }
false
false
false
false
true
1
posix_memalign(void **memptr, size_t alignment, size_t size) { /* * Per standard, posix_memalign returns EINVAL when alignment * is not a power of two or power of sizeof(void*). efence * doesn't check the value of alignment in memalign, but then * again, memalign was never specified very well, and on some * systems odd alignments could indeed have been allowed. */ if ((alignment & (alignment - 1)) || alignment % sizeof (void *)) return EINVAL; void *ptr = memalign (alignment, size); if (ptr == NULL) return ENOMEM; *memptr = ptr; return 0; }
false
false
false
false
false
0
set_base_and_text (char const *type_name) { static char const *_text_widgets[] = { "GtkCellView", "GtkEntry", "GtkTextView" }; for (unsigned int i = 0; i < G_N_ELEMENTS (_text_widgets); i++) { if (0 == g_strcmp0 (type_name, _text_widgets[i])) { return true; } } return false; }
false
false
false
false
false
0
netup_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { unsigned long flags; int i, trans_done, res = num; struct netup_i2c *i2c = i2c_get_adapdata(adap); u16 reg; if (num <= 0) { dev_dbg(i2c->adap.dev.parent, "%s(): num == %d\n", __func__, num); return -EINVAL; } spin_lock_irqsave(&i2c->lock, flags); if (i2c->state != STATE_DONE) { dev_dbg(i2c->adap.dev.parent, "%s(): i2c->state == %d, resetting I2C\n", __func__, i2c->state); netup_i2c_reset(i2c); } dev_dbg(i2c->adap.dev.parent, "%s() num %d\n", __func__, num); for (i = 0; i < num; i++) { i2c->msg = &msgs[i]; netup_i2c_start_xfer(i2c); trans_done = 0; while (!trans_done) { spin_unlock_irqrestore(&i2c->lock, flags); if (wait_event_timeout(i2c->wq, i2c->state != STATE_WAIT, msecs_to_jiffies(NETUP_I2C_TIMEOUT))) { spin_lock_irqsave(&i2c->lock, flags); switch (i2c->state) { case STATE_WANT_READ: netup_i2c_fifo_rx(i2c); break; case STATE_WANT_WRITE: netup_i2c_fifo_tx(i2c); break; case STATE_DONE: if ((i2c->msg->flags & I2C_M_RD) != 0 && i2c->xmit_size != i2c->msg->len) netup_i2c_fifo_rx(i2c); dev_dbg(i2c->adap.dev.parent, "%s(): msg %d OK\n", __func__, i); trans_done = 1; break; case STATE_ERROR: res = -EIO; dev_dbg(i2c->adap.dev.parent, "%s(): error state\n", __func__); goto done; default: dev_dbg(i2c->adap.dev.parent, "%s(): invalid state %d\n", __func__, i2c->state); res = -EINVAL; goto done; } if (!trans_done) { i2c->state = STATE_WAIT; reg = readw( &i2c->regs->twi_ctrl0_stat); writew(TWI_IRQEN | reg, &i2c->regs->twi_ctrl0_stat); } spin_unlock_irqrestore(&i2c->lock, flags); } else { spin_lock_irqsave(&i2c->lock, flags); dev_dbg(i2c->adap.dev.parent, "%s(): wait timeout\n", __func__); res = -ETIMEDOUT; goto done; } spin_lock_irqsave(&i2c->lock, flags); } } done: spin_unlock_irqrestore(&i2c->lock, flags); dev_dbg(i2c->adap.dev.parent, "%s(): result %d\n", __func__, res); return res; }
false
false
false
false
false
0
select_pool(void) { static int rotating_pool = 0; struct pool *pool, *cp; bool avail = false; int tested, i; cp = current_pool(); if (pool_strategy == POOL_BALANCE) { pool = select_balanced(cp); goto out; } if (pool_strategy != POOL_LOADBALANCE) { pool = cp; goto out; } else pool = NULL; for (i = 0; i < total_pools; i++) { struct pool *tp = pools[i]; if (tp->quota_used < tp->quota_gcd) { avail = true; break; } } /* There are no pools with quota, so reset them. */ if (!avail) { for (i = 0; i < total_pools; i++) pools[i]->quota_used = 0; if (++rotating_pool >= total_pools) rotating_pool = 0; } /* Try to find the first pool in the rotation that is usable */ tested = 0; while (!pool && tested++ < total_pools) { pool = pools[rotating_pool]; if (pool->quota_used++ < pool->quota_gcd) { if (!pool_unusable(pool)) break; } pool = NULL; if (++rotating_pool >= total_pools) rotating_pool = 0; } /* If there are no alive pools with quota, choose according to * priority. */ if (!pool) { for (i = 0; i < total_pools; i++) { struct pool *tp = priority_pool(i); if (!pool_unusable(tp)) { pool = tp; break; } } } /* If still nothing is usable, use the current pool */ if (!pool) pool = cp; out: applog(LOG_DEBUG, "Selecting pool %d for work", pool->pool_no); return pool; }
false
false
false
false
false
0
emulib_EnableSound (uae_u32 val) { if (!sound_available || currprefs.produce_sound == 2) return 0; currprefs.produce_sound = val; return 1; }
false
false
false
false
false
0
visit(const char* value,orbOptions::Source) throw (orbOptions::BadParam) { unsigned int v; if( sscanf(value,"%o",&v) != 1 ) { throw orbOptions::BadParam(key(),value, "Invalid value, expect mode bits in octal radix"); } orbParameters::unixTransportPermission = v; }
false
false
false
false
false
0
sm501fb_suspend_fb(struct sm501fb_info *info, enum sm501_controller head) { struct fb_info *fbi = info->fb[head]; struct sm501fb_par *par = fbi->par; if (par->screen.size == 0) return 0; /* blank the relevant interface to ensure unit power minimised */ (par->ops.fb_blank)(FB_BLANK_POWERDOWN, fbi); /* tell console/fb driver we are suspending */ console_lock(); fb_set_suspend(fbi, 1); console_unlock(); /* backup copies in case chip is powered down over suspend */ par->store_fb = vmalloc(par->screen.size); if (par->store_fb == NULL) { dev_err(info->dev, "no memory to store screen\n"); return -ENOMEM; } par->store_cursor = vmalloc(par->cursor.size); if (par->store_cursor == NULL) { dev_err(info->dev, "no memory to store cursor\n"); goto err_nocursor; } dev_dbg(info->dev, "suspending screen to %p\n", par->store_fb); dev_dbg(info->dev, "suspending cursor to %p\n", par->store_cursor); memcpy_fromio(par->store_fb, par->screen.k_addr, par->screen.size); memcpy_fromio(par->store_cursor, par->cursor.k_addr, par->cursor.size); return 0; err_nocursor: vfree(par->store_fb); par->store_fb = NULL; return -ENOMEM; }
false
false
false
false
false
0
pkinit_get_deferred_id_flags(pkinit_deferred_id *identities, const char *identity) { int i; for (i = 0; identities != NULL && identities[i] != NULL; i++) { if (strcmp(identities[i]->identity, identity) == 0) return identities[i]->ck_flags; } return 0; }
false
false
false
false
false
0
silence_gen_alter(silence_gen_state_t *s, int silent_samples) { /* Block negative silences */ if (silent_samples < 0) { if (-silent_samples > s->remaining_samples) silent_samples = -s->remaining_samples; } s->remaining_samples += silent_samples; s->total_samples += silent_samples; }
false
false
false
false
false
0
draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w) { uint8_t *ptr, *last_line; int i; last_line = buf + (height - 1) * wrap; /* left and right */ ptr = buf; if(w==8) { __asm__ volatile( "1: \n\t" "movd (%0), %%mm0 \n\t" "punpcklbw %%mm0, %%mm0 \n\t" "punpcklwd %%mm0, %%mm0 \n\t" "punpckldq %%mm0, %%mm0 \n\t" "movq %%mm0, -8(%0) \n\t" "movq -8(%0, %2), %%mm1 \n\t" "punpckhbw %%mm1, %%mm1 \n\t" "punpckhwd %%mm1, %%mm1 \n\t" "punpckhdq %%mm1, %%mm1 \n\t" "movq %%mm1, (%0, %2) \n\t" "add %1, %0 \n\t" "cmp %3, %0 \n\t" " jb 1b \n\t" : "+r" (ptr) : "r" ((x86_reg)wrap), "r" ((x86_reg)width), "r" (ptr + wrap*height) ); } else { __asm__ volatile( "1: \n\t" "movd (%0), %%mm0 \n\t" "punpcklbw %%mm0, %%mm0 \n\t" "punpcklwd %%mm0, %%mm0 \n\t" "punpckldq %%mm0, %%mm0 \n\t" "movq %%mm0, -8(%0) \n\t" "movq %%mm0, -16(%0) \n\t" "movq -8(%0, %2), %%mm1 \n\t" "punpckhbw %%mm1, %%mm1 \n\t" "punpckhwd %%mm1, %%mm1 \n\t" "punpckhdq %%mm1, %%mm1 \n\t" "movq %%mm1, (%0, %2) \n\t" "movq %%mm1, 8(%0, %2) \n\t" "add %1, %0 \n\t" "cmp %3, %0 \n\t" " jb 1b \n\t" : "+r" (ptr) : "r" ((x86_reg)wrap), "r" ((x86_reg)width), "r" (ptr + wrap*height) ); } for(i=0;i<w;i+=4) { /* top and bottom (and hopefully also the corners) */ ptr= buf - (i + 1) * wrap - w; __asm__ volatile( "1: \n\t" "movq (%1, %0), %%mm0 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm0, (%0, %2) \n\t" "movq %%mm0, (%0, %2, 2) \n\t" "movq %%mm0, (%0, %3) \n\t" "add $8, %0 \n\t" "cmp %4, %0 \n\t" " jb 1b \n\t" : "+r" (ptr) : "r" ((x86_reg)buf - (x86_reg)ptr - w), "r" ((x86_reg)-wrap), "r" ((x86_reg)-wrap*3), "r" (ptr+width+2*w) ); ptr= last_line + (i + 1) * wrap - w; __asm__ volatile( "1: \n\t" "movq (%1, %0), %%mm0 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm0, (%0, %2) \n\t" "movq %%mm0, (%0, %2, 2) \n\t" "movq %%mm0, (%0, %3) \n\t" "add $8, %0 \n\t" "cmp %4, %0 \n\t" " jb 1b \n\t" : "+r" (ptr) : "r" ((x86_reg)last_line - (x86_reg)ptr - w), "r" ((x86_reg)wrap), "r" ((x86_reg)wrap*3), "r" (ptr+width+2*w) ); } }
false
false
false
false
false
0
CommentOperator(List *opername, List *arguments, char *comment) { TypeName *typenode1 = (TypeName *) linitial(arguments); TypeName *typenode2 = (TypeName *) lsecond(arguments); Oid oid; /* Look up the operator */ oid = LookupOperNameTypeNames(NULL, opername, typenode1, typenode2, false, -1); /* Check user's privilege to comment on this operator */ if (!pg_oper_ownercheck(oid, GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER, NameListToString(opername)); /* Call CreateComments() to create/drop the comments */ CreateComments(oid, OperatorRelationId, 0, comment); }
false
false
false
false
false
0
remove_empty(hwloc_topology_t topology, hwloc_obj_t *pobj) { hwloc_obj_t obj = *pobj, child, *pchild; for_each_child_safe(child, obj, pchild) remove_empty(topology, pchild); if (obj->type != HWLOC_OBJ_NODE && !obj->first_child /* only remove if all children were removed above, so that we don't remove parents of NUMAnode */ && !hwloc_obj_type_is_io(obj->type) && obj->type != HWLOC_OBJ_MISC && obj->cpuset /* don't remove if no cpuset at all, there's likely a good reason why it's different from having an empty cpuset */ && hwloc_bitmap_iszero(obj->cpuset)) { /* Remove empty children */ hwloc_debug("%s", "\nRemoving empty object "); print_object(topology, 0, obj); unlink_and_free_single_object(pobj); } }
false
false
false
false
false
0
soap_fdelete(struct soap_clist *p) { switch (p->type) { case SOAP_TYPE_vector: if (p->size < 0) SOAP_DELETE((vector*)p->ptr); else SOAP_DELETE_ARRAY((vector*)p->ptr); break; case SOAP_TYPE_matrix: if (p->size < 0) SOAP_DELETE((matrix*)p->ptr); else SOAP_DELETE_ARRAY((matrix*)p->ptr); break; case SOAP_TYPE_ns1__magicResponse: if (p->size < 0) SOAP_DELETE((struct ns1__magicResponse*)p->ptr); else SOAP_DELETE_ARRAY((struct ns1__magicResponse*)p->ptr); break; case SOAP_TYPE_ns1__magic: if (p->size < 0) SOAP_DELETE((struct ns1__magic*)p->ptr); else SOAP_DELETE_ARRAY((struct ns1__magic*)p->ptr); break; #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Header: if (p->size < 0) SOAP_DELETE((struct SOAP_ENV__Header*)p->ptr); else SOAP_DELETE_ARRAY((struct SOAP_ENV__Header*)p->ptr); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Code: if (p->size < 0) SOAP_DELETE((struct SOAP_ENV__Code*)p->ptr); else SOAP_DELETE_ARRAY((struct SOAP_ENV__Code*)p->ptr); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Detail: if (p->size < 0) SOAP_DELETE((struct SOAP_ENV__Detail*)p->ptr); else SOAP_DELETE_ARRAY((struct SOAP_ENV__Detail*)p->ptr); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Reason: if (p->size < 0) SOAP_DELETE((struct SOAP_ENV__Reason*)p->ptr); else SOAP_DELETE_ARRAY((struct SOAP_ENV__Reason*)p->ptr); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Fault: if (p->size < 0) SOAP_DELETE((struct SOAP_ENV__Fault*)p->ptr); else SOAP_DELETE_ARRAY((struct SOAP_ENV__Fault*)p->ptr); break; #endif default: return SOAP_ERR; } return SOAP_OK; }
false
false
false
false
false
0
_enter_buffered_busy(buffered *self) { if (self->owner == PyThread_get_thread_ident()) { PyErr_Format(PyExc_RuntimeError, "reentrant call inside %R", self); return 0; } Py_BEGIN_ALLOW_THREADS PyThread_acquire_lock(self->lock, 1); Py_END_ALLOW_THREADS return 1; }
false
false
false
false
false
0
timer_callback (GkmTimer *timer, gpointer user_data) { GkmObject *self = user_data; glong after, idle, offset; GkmObjectTransient *transient; GTimeVal tv; g_return_if_fail (GKM_IS_OBJECT (self)); g_object_ref (self); g_return_if_fail (self->pv->transient); transient = self->pv->transient; g_return_if_fail (timer == transient->timer); transient->timer = NULL; g_get_current_time (&tv); idle = after = G_MAXLONG; /* Are we supposed to be destroyed after a certain time? */ if (transient->timed_after) { g_return_if_fail (transient->stamp_created); after = (transient->stamp_created + transient->timed_after) - tv.tv_sec; } /* Are we supposed to be destroyed after an idle time? */ if (transient->timed_idle) { g_return_if_fail (transient->stamp_used); idle = (transient->stamp_used + transient->timed_idle) - tv.tv_sec; } /* Okay, time to destroy? */ offset = MIN (after, idle); if (offset <= 0) self_destruct (self); /* Setup the next timer */ else transient->timer = gkm_timer_start (self->pv->module, offset, timer_callback, self); g_object_unref (self); }
false
false
false
false
false
0
drbd_rs_cancel_all(struct drbd_device *device) { spin_lock_irq(&device->al_lock); if (get_ldev_if_state(device, D_FAILED)) { /* Makes sure ->resync is there. */ lc_reset(device->resync); put_ldev(device); } device->resync_locked = 0; device->resync_wenr = LC_FREE; spin_unlock_irq(&device->al_lock); wake_up(&device->al_wait); }
false
false
false
false
false
0
ompi_osc_rdma_process_flush (ompi_osc_rdma_module_t *module, int source, ompi_osc_rdma_header_flush_t *flush_header) { ompi_osc_rdma_header_flush_ack_t flush_ack; OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output, "ompi_osc_rdma_process_flush entering (finished %d/%d)...", module->passive_incoming_frag_count[source], module->passive_incoming_frag_signal_count[source])); /* we cannot block when processing an incoming request */ if (module->passive_incoming_frag_signal_count[source] != module->passive_incoming_frag_count[source]) { return OMPI_ERR_WOULD_BLOCK; } module->passive_incoming_frag_signal_count[source] = 0; module->passive_incoming_frag_count[source] = 0; flush_ack.base.type = OMPI_OSC_RDMA_HDR_TYPE_FLUSH_ACK; flush_ack.base.flags = OMPI_OSC_RDMA_HDR_FLAG_VALID; flush_ack.serial_number = flush_header->serial_number; return ompi_osc_rdma_control_send_unbuffered (module, source, &flush_ack, sizeof (flush_ack)); }
false
false
false
false
false
0
snd_rme96_apply_dac_volume(struct rme96 *rme96) { if (RME96_DAC_IS_1852(rme96)) { snd_rme96_write_SPI(rme96, (rme96->vol[0] << 2) | 0x0); snd_rme96_write_SPI(rme96, (rme96->vol[1] << 2) | 0x2); } else if (RME96_DAC_IS_1855(rme96)) { snd_rme96_write_SPI(rme96, (rme96->vol[0] & 0x3FF) | 0x000); snd_rme96_write_SPI(rme96, (rme96->vol[1] & 0x3FF) | 0x400); } }
false
false
false
false
false
0
thread_signals(apr_thread_t *thread, void *data) { apr_status_t rc; error_log(LOG_DEBUG, thread, "Signal thread: Starting."); rc = apr_signal_thread(handle_signals); if (rc != APR_SUCCESS) { error_log(LOG_DEBUG, thread, "Signal thread: Error %d", rc); logc_shutdown(1); } return NULL; }
false
false
false
false
false
0
OpFgets() { fah_fgets_it in ; fah_fgets_ot out ; char *buff ; u_short fid ; /* obtain fid, length of string */ if (!readn(newsock, (char *)&in, sizeof(in))) return ; fid = ntohs(in.fid) ; /* check if valid fid */ if (!(fid < TABLE_SIZE && table[fid].fp != NULL)) { out.status = htons(FAILURE) ; out.error = htons(FAH_ER_NOTOPEN) ; out.len = htonl(0) ; writen(newsock, (char *)&out, sizeof(out)) ; return ; } /* read string from file & send it */ buff = (char *) malloc(ntohl(in.len)) ; if (fgets(buff, ntohl(in.len), table[fid].fp) == NULL) { out.status = htons(FAILURE) ; out.error = htons(FAH_ER_FGETS) ; out.len = htonl(0) ; } else { out.status = htons(SUCCESS) ; out.error = htons(FAH_ER_NOERROR) ; out.len = ntohl(strlen(buff)+1) ; } /* send string length & then string */ if (writen(newsock, (char *)&out, sizeof(out))) writen(newsock, (char *)buff, ntohl(out.len)) ; free(buff) ; }
false
false
false
false
false
0
hdb_remove_aliases(krb5_context context, HDB *db, krb5_data *key) { const HDB_Ext_Aliases *aliases; krb5_error_code code; hdb_entry oldentry; krb5_data value; size_t i; code = db->hdb__get(context, db, *key, &value); if (code == HDB_ERR_NOENTRY) return 0; else if (code) return code; code = hdb_value2entry(context, &value, &oldentry); krb5_data_free(&value); if (code) return code; code = hdb_entry_get_aliases(&oldentry, &aliases); if (code || aliases == NULL) { free_hdb_entry(&oldentry); return code; } for (i = 0; i < aliases->aliases.len; i++) { krb5_data akey; hdb_principal2key(context, &aliases->aliases.val[i], &akey); code = db->hdb__del(context, db, akey); krb5_data_free(&akey); if (code) { free_hdb_entry(&oldentry); return code; } } free_hdb_entry(&oldentry); return 0; }
false
false
false
false
true
1
isOSSDevice(const QByteArray& lastElement, const char* lastElementAscii) { m_driver = Solid::AudioInterface::UnknownAudioDriver; m_type = Solid::AudioInterface::UnknownAudioInterfaceType; m_cardnum = 0; m_deviceFile = m_device->property("DEVNAME").toString(); if (lastElement.startsWith("dsp")) { m_driver = Solid::AudioInterface::OpenSoundSystem; sscanf (lastElementAscii, "dsp%d", &m_cardnum); } if (lastElement.startsWith("adsp")) { m_driver = Solid::AudioInterface::OpenSoundSystem; sscanf (lastElementAscii, "adsp%d", &m_cardnum); } if (lastElement.startsWith("midi")) { m_driver = Solid::AudioInterface::OpenSoundSystem; sscanf (lastElementAscii, "midi%d", &m_cardnum); } if (lastElement.startsWith("amidi")) { m_driver = Solid::AudioInterface::OpenSoundSystem; sscanf (lastElementAscii, "amidi%d", &m_cardnum); } if (lastElement.startsWith("audio")) { m_driver = Solid::AudioInterface::OpenSoundSystem; sscanf (lastElementAscii, "audio%d", &m_cardnum); } if (lastElement.startsWith("mixer")) { m_driver = Solid::AudioInterface::OpenSoundSystem; m_type = Solid::AudioInterface::AudioControl; sscanf (lastElementAscii, "mixer%d", &m_cardnum); } if (m_driver != Solid::AudioInterface::UnknownAudioDriver) { m_name = cardNumberToName(); QString path; path.sprintf("/proc/asound/card%d/pcm0p/info", m_cardnum); QByteArray cardName = grepHelper(path, "name: "); if (!cardName.isEmpty()) { m_name.append(QLatin1String(" (") + cardName + ')'); } else { m_name.append(QLatin1String(" (OSS Device)")); } return true; } return false; }
false
false
false
false
false
0
icd() { if(icd_detected()) { printf("ICD version \"%s\" was found.\n",icd_version()); printf("Target controller is %s.\n", icd_target()); printf("Vdd: %.1f\t",icd_vdd()); printf("Vpp: %.1f\n",icd_vpp()); if(icd_has_debug_module()) puts("Debug module is present"); else puts("Debug moudle is NOT present."); } else { printf("ICD has not been opened (use the \"icd open\" command)\n"); } }
false
false
false
false
false
0
opal_dss_unpack(opal_buffer_t *buffer, void *dst, int32_t *num_vals, opal_data_type_t type) { int rc, ret; int32_t local_num, n=1; opal_data_type_t local_type; /* check for error */ if (NULL == buffer || NULL == dst || NULL == num_vals) { return OPAL_ERR_BAD_PARAM; } /* if user provides a zero for num_vals, then there is no storage allocated * so return an appropriate error */ if (0 == *num_vals) { OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack: inadequate space ( %p, %p, %lu, %d )\n", (void*)buffer, dst, (long unsigned int)*num_vals, (int)type ) ); return OPAL_ERR_UNPACK_INADEQUATE_SPACE; } /** Unpack the declared number of values * REMINDER: it is possible that the buffer is corrupted and that * the DSS will *think* there is a proper int32_t variable at the * beginning of the unpack region - but that the value is bogus (e.g., just * a byte field in a string array that so happens to have a value that * matches the int32_t data type flag). Therefore, this error check is * NOT completely safe. This is true for ALL unpack functions, not just * int32_t as used here. */ if (OPAL_DSS_BUFFER_FULLY_DESC == buffer->type) { if (OPAL_SUCCESS != ( rc = opal_dss_get_data_type(buffer, &local_type))) { *num_vals = 0; return rc; } if (OPAL_INT32 != local_type) { /* if the length wasn't first, then error */ *num_vals = 0; return OPAL_ERR_UNPACK_FAILURE; } } n=1; if (OPAL_SUCCESS != (rc = opal_dss_unpack_int32(buffer, &local_num, &n, OPAL_INT32))) { *num_vals = 0; return rc; } /** if the storage provided is inadequate, set things up * to unpack as much as we can and to return an error code * indicating that everything was not unpacked - the buffer * is left in a state where it can not be further unpacked. */ if (local_num > *num_vals) { local_num = *num_vals; OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack: inadequate space ( %p, %p, %lu, %d )\n", (void*)buffer, dst, (long unsigned int)*num_vals, (int)type ) ); ret = OPAL_ERR_UNPACK_INADEQUATE_SPACE; } else { /** enough or more than enough storage */ *num_vals = local_num; /** let the user know how many we actually unpacked */ ret = OPAL_SUCCESS; } /** Unpack the value(s) */ if (OPAL_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, dst, &local_num, type))) { *num_vals = 0; ret = rc; } return ret; }
false
false
false
false
false
0
p_check_image_numpart (GapStoryElem *stb_elem, char *filename) { char *l_basnam; long l_number; l_basnam = gap_lib_alloc_basename(filename, &l_number); if(l_basnam) { if(l_number > 0) { /* the image has a numberpart and probably one of series of frames */ stb_elem->from_frame = l_number; stb_elem->to_frame = l_number; } g_free(l_basnam); } }
false
false
false
false
false
0
_TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount) { if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0) return TIFF_SETGET_ASCII; else if (count == 1 && passcount == 0) { switch (type) { case TIFF_BYTE: case TIFF_UNDEFINED: return TIFF_SETGET_UINT8; case TIFF_ASCII: return TIFF_SETGET_ASCII; case TIFF_SHORT: return TIFF_SETGET_UINT16; case TIFF_LONG: return TIFF_SETGET_UINT32; case TIFF_RATIONAL: case TIFF_SRATIONAL: case TIFF_FLOAT: return TIFF_SETGET_FLOAT; case TIFF_SBYTE: return TIFF_SETGET_SINT8; case TIFF_SSHORT: return TIFF_SETGET_SINT16; case TIFF_SLONG: return TIFF_SETGET_SINT32; case TIFF_DOUBLE: return TIFF_SETGET_DOUBLE; case TIFF_IFD: case TIFF_IFD8: return TIFF_SETGET_IFD8; case TIFF_LONG8: return TIFF_SETGET_UINT64; case TIFF_SLONG8: return TIFF_SETGET_SINT64; default: return TIFF_SETGET_UNDEFINED; } } else if (count >= 1 && passcount == 0) { switch (type) { case TIFF_BYTE: case TIFF_UNDEFINED: return TIFF_SETGET_C0_UINT8; case TIFF_ASCII: return TIFF_SETGET_C0_ASCII; case TIFF_SHORT: return TIFF_SETGET_C0_UINT16; case TIFF_LONG: return TIFF_SETGET_C0_UINT32; case TIFF_RATIONAL: case TIFF_SRATIONAL: case TIFF_FLOAT: return TIFF_SETGET_C0_FLOAT; case TIFF_SBYTE: return TIFF_SETGET_C0_SINT8; case TIFF_SSHORT: return TIFF_SETGET_C0_SINT16; case TIFF_SLONG: return TIFF_SETGET_C0_SINT32; case TIFF_DOUBLE: return TIFF_SETGET_C0_DOUBLE; case TIFF_IFD: case TIFF_IFD8: return TIFF_SETGET_C0_IFD8; case TIFF_LONG8: return TIFF_SETGET_C0_UINT64; case TIFF_SLONG8: return TIFF_SETGET_C0_SINT64; default: return TIFF_SETGET_UNDEFINED; } } else if (count == TIFF_VARIABLE && passcount == 1) { switch (type) { case TIFF_BYTE: case TIFF_UNDEFINED: return TIFF_SETGET_C16_UINT8; case TIFF_ASCII: return TIFF_SETGET_C16_ASCII; case TIFF_SHORT: return TIFF_SETGET_C16_UINT16; case TIFF_LONG: return TIFF_SETGET_C16_UINT32; case TIFF_RATIONAL: case TIFF_SRATIONAL: case TIFF_FLOAT: return TIFF_SETGET_C16_FLOAT; case TIFF_SBYTE: return TIFF_SETGET_C16_SINT8; case TIFF_SSHORT: return TIFF_SETGET_C16_SINT16; case TIFF_SLONG: return TIFF_SETGET_C16_SINT32; case TIFF_DOUBLE: return TIFF_SETGET_C16_DOUBLE; case TIFF_IFD: case TIFF_IFD8: return TIFF_SETGET_C16_IFD8; case TIFF_LONG8: return TIFF_SETGET_C16_UINT64; case TIFF_SLONG8: return TIFF_SETGET_C16_SINT64; default: return TIFF_SETGET_UNDEFINED; } } else if (count == TIFF_VARIABLE2 && passcount == 1) { switch (type) { case TIFF_BYTE: case TIFF_UNDEFINED: return TIFF_SETGET_C32_UINT8; case TIFF_ASCII: return TIFF_SETGET_C32_ASCII; case TIFF_SHORT: return TIFF_SETGET_C32_UINT16; case TIFF_LONG: return TIFF_SETGET_C32_UINT32; case TIFF_RATIONAL: case TIFF_SRATIONAL: case TIFF_FLOAT: return TIFF_SETGET_C32_FLOAT; case TIFF_SBYTE: return TIFF_SETGET_C32_SINT8; case TIFF_SSHORT: return TIFF_SETGET_C32_SINT16; case TIFF_SLONG: return TIFF_SETGET_C32_SINT32; case TIFF_DOUBLE: return TIFF_SETGET_C32_DOUBLE; case TIFF_IFD: case TIFF_IFD8: return TIFF_SETGET_C32_IFD8; case TIFF_LONG8: return TIFF_SETGET_C32_UINT64; case TIFF_SLONG8: return TIFF_SETGET_C32_SINT64; default: return TIFF_SETGET_UNDEFINED; } } return TIFF_SETGET_UNDEFINED; }
false
false
false
false
false
0
rsa_get_internal(hx509_context context, hx509_private_key key, const char *type) { if (strcasecmp(type, "rsa-modulus") == 0) { return BN_dup(key->private_key.rsa->n); } else if (strcasecmp(type, "rsa-exponent") == 0) { return BN_dup(key->private_key.rsa->e); } else return NULL; }
false
false
false
false
false
0
threadpool_clear_queue (ThreadPool *tp, MonoDomain *domain) { MonoObject *obj; MonoMList *other = NULL; MonoCQ *queue = tp->queue; if (!queue) return; while (mono_cq_dequeue (queue, &obj)) { if (obj == NULL) continue; if (obj->vtable->domain != domain) other = mono_mlist_prepend (other, obj); threadpool_jobs_dec (obj); } if (mono_runtime_is_shutting_down ()) return; while (other) { threadpool_append_job (tp, (MonoObject *) mono_mlist_get_data (other)); other = mono_mlist_next (other); } }
false
false
false
false
false
0
foo_scroll_area_invalidate_region (FooScrollArea *area, cairo_region_t *region) { GtkWidget *widget; g_return_if_fail (FOO_IS_SCROLL_AREA (area)); widget = GTK_WIDGET (area); cairo_region_union (area->priv->update_region, region); if (gtk_widget_get_realized (widget)) { canvas_to_window (area, region); gdk_window_invalidate_region (gtk_widget_get_window (widget), region, TRUE); window_to_canvas (area, region); } }
false
false
false
false
false
0
scan_unsigned(const char **bufp, unsigned *out, int width, int base) { unsigned result = 0; int scanned_so_far = 0; const int hex = base==16; tor_assert(base == 10 || base == 16); if (!bufp || !*bufp || !out) return -1; if (width<0) width=MAX_SCANF_WIDTH; while (**bufp && (hex?TOR_ISXDIGIT(**bufp):TOR_ISDIGIT(**bufp)) && scanned_so_far < width) { int digit = hex?hex_decode_digit(*(*bufp)++):digit_to_num(*(*bufp)++); unsigned new_result = result * base + digit; if (new_result > UINT32_MAX || new_result < result) return -1; /* over/underflow. */ result = new_result; ++scanned_so_far; } if (!scanned_so_far) /* No actual digits scanned */ return -1; *out = result; return 0; }
false
false
false
false
false
0
calculate_sub_circles(float radius_multiplier) { /* * The new way of doing it, is as follows: * [Outer loop: for all contours] * - Estimate a subcircle-radius: Average of line-segment-lengths * 3.5 (maybe this should be a parameter ?) * [Loop: for all points] * - Create a subcircle for the next two points (this gives a center and a radius) * [Inner loop: as long as we have more points] * - Add the next point: maybe expand the radius, and change the center * - [if: (radius > avg-radius && more than two more points exist)] * - Break inner loop ! * - Add the subcircle to the list **/ std::vector<CL_Contour>::iterator it; for( it = contours.begin(); it != contours.end(); ++it ) { (*it).sub_circles.clear(); const std::vector<CL_Pointf> &points = (*it).points; // Test that we have at least 2 points if(points.size() < 2) { CL_Log::log("ClanCollision", "Error: contour has less than 2 points"); continue; } // sub_radius = average of line lenghts in the contour * 3.5 float sub_radius = 0.0f; for( unsigned int j=0; j < points.size(); ++j ) { int j2 = (j+1) % points.size(); sub_radius += (points[j].distance(points[j2])); } sub_radius /= points.size(); sub_radius *= radius_multiplier; unsigned int i=0; while(i < points.size()) { // Create a circle from the first two points CL_OutlineCircle circle; circle.start = i; // i denotes the index of the beginning circle.end = i+1; // (i+1) denotes the index of the end: and it loops CL_OutlineMath::minimum_enclosing_sub_circle(circle,points,sub_radius); circle.radius += 0.01f; // Just to make sure. // Add the circle (*it).sub_circles.push_back(circle); // update i for next circle i = circle.end; } } }
false
false
false
false
false
0
view_terminal_dispose (GObject *object) { GiggleViewTerminalPriv *priv = GET_PRIV (object); if (priv->notebook) { g_signal_handlers_disconnect_by_func (priv->notebook, view_terminal_tab_remove_cb, object); priv->notebook = NULL; } G_OBJECT_CLASS (giggle_view_terminal_parent_class)->dispose (object); }
false
false
false
false
false
0
imc_get_coeffs (IMCContext* q) { int i, j, cw_len, cw; for(i = 0; i < BANDS; i++) { if(!q->sumLenArr[i]) continue; if (q->bandFlagsBuf[i] || q->bandWidthT[i]) { for(j = band_tab[i]; j < band_tab[i+1]; j++) { cw_len = q->CWlengthT[j]; cw = 0; if (get_bits_count(&q->gb) + cw_len > 512){ //av_log(NULL,0,"Band %i coeff %i cw_len %i\n",i,j,cw_len); return -1; } if(cw_len && (!q->bandFlagsBuf[i] || !q->skipFlags[j])) cw = get_bits(&q->gb, cw_len); q->codewords[j] = cw; } } } return 0; }
false
false
false
false
false
0
st_theme_node_get_background_paint_box (StThemeNode *node, const ClutterActorBox *actor_box, ClutterActorBox *paint_box) { StShadow *background_image_shadow; ClutterActorBox shadow_box; g_return_if_fail (ST_IS_THEME_NODE (node)); g_return_if_fail (actor_box != NULL); g_return_if_fail (paint_box != NULL); background_image_shadow = st_theme_node_get_background_image_shadow (node); *paint_box = *actor_box; if (!background_image_shadow) return; st_shadow_get_box (background_image_shadow, actor_box, &shadow_box); paint_box->x1 = MIN (paint_box->x1, shadow_box.x1); paint_box->x2 = MAX (paint_box->x2, shadow_box.x2); paint_box->y1 = MIN (paint_box->y1, shadow_box.y1); paint_box->y2 = MAX (paint_box->y2, shadow_box.y2); }
false
false
false
false
false
0
Multimap() { cxxtools::xmlrpc::Service service; service.registerMethod("multiplymultimap", *this, &XmlRpcCallbackTest::multiplyMultimap); _server->addService("/test", service); cxxtools::xmlrpc::HttpClient client(_loop, "", _port, "/test"); cxxtools::RemoteProcedure<IntMultimap, IntMultimap, int> multiply(client, "multiplymultimap"); connect( multiply.finished, *this, &XmlRpcCallbackTest::onMultiplyMultimapFinished ); IntMultimap mymap; mymap.insert(IntMultimap::value_type(2, 4)); mymap.insert(IntMultimap::value_type(7, 7)); mymap.insert(IntMultimap::value_type(7, 8)); mymap.insert(IntMultimap::value_type(1, -1)); multiply.begin(mymap, 2); _loop.run(); }
false
false
false
false
false
0
maRestartServer(cchar *ip, int port) { MaAppweb *appweb; MaServer *server; HttpEndpoint *endpoint; appweb = MPR->appwebService; server = mprGetFirstItem(appweb->servers); lock(appweb->servers); endpoint = mprGetFirstItem(server->endpoints); httpStopEndpoint(endpoint); /* Alternatively, iterate over all endpoints by Http *http = MPR->httpService; int next; for (ITERATE_ITEMS(http->endpoints, endpoint, next)) { ... } */ if (port) { endpoint->port = port; } if (ip) { endpoint->ip = sclone(ip); } httpStartEndpoint(endpoint); unlock(appweb->servers); }
false
false
false
false
false
0
render() { const WidgetLookFeel& wlf = getLookNFeel(); InventoryItem* item = dynamic_cast<InventoryItem*>(d_window); if (!item) // render basic imagery wlf.getStateImagery(d_window->isDisabled() ? "Disabled" : "Enabled").render(*d_window); if (item->isBeingDragged()) wlf.getStateImagery(item->currentDropTargetIsValid() ? "DraggingValidTarget" : "DraggingInvalidTarget").render(*item); else wlf.getStateImagery("Normal").render(*item); }
false
false
false
true
false
1
ipath_user_sdma_queue_destroy(struct ipath_user_sdma_queue *pq) { if (!pq) return; kmem_cache_destroy(pq->pkt_slab); dma_pool_destroy(pq->header_cache); kfree(pq); }
false
false
false
false
false
0
addAppletActions(KMenu &desktopMenu, Applet *applet, QEvent *event) { foreach (QAction *action, applet->contextualActions()) { if (action) { desktopMenu.addAction(action); } } if (!applet->d->failed) { QAction *configureApplet = applet->d->actions->action("configure"); if (configureApplet && configureApplet->isEnabled()) { desktopMenu.addAction(configureApplet); } QAction *runAssociatedApplication = applet->d->actions->action("run associated application"); if (runAssociatedApplication && runAssociatedApplication->isEnabled()) { desktopMenu.addAction(runAssociatedApplication); } } KMenu *containmentMenu = new KMenu(i18nc("%1 is the name of the containment", "%1 Options", q->name()), &desktopMenu); addContainmentActions(*containmentMenu, event); if (!containmentMenu->isEmpty()) { int enabled = 0; //count number of real actions QListIterator<QAction *> actionsIt(containmentMenu->actions()); while (enabled < 3 && actionsIt.hasNext()) { QAction *action = actionsIt.next(); if (action->isVisible() && !action->isSeparator()) { ++enabled; } } if (enabled) { //if there is only one, don't create a submenu if (enabled < 2) { foreach (QAction *action, containmentMenu->actions()) { if (action->isVisible() && !action->isSeparator()) { desktopMenu.addAction(action); } } } else { desktopMenu.addMenu(containmentMenu); } } } if (q->immutability() == Mutable && !q->property("hideCloseAppletInContextMenu").toBool()) { QAction *closeApplet = applet->d->actions->action("remove"); //kDebug() << "checking for removal" << closeApplet; if (closeApplet) { if (!desktopMenu.isEmpty()) { desktopMenu.addSeparator(); } //kDebug() << "adding close action" << closeApplet->isEnabled() << closeApplet->isVisible(); desktopMenu.addAction(closeApplet); } } }
false
false
false
false
false
0
remove_conflicts() { register int i; register int symbol; register action *p, *pref; SRtotal = 0; RRtotal = 0; SRconflicts = NEW2(nstates, short); RRconflicts = NEW2(nstates, short); for (i = 0; i < nstates; i++) { SRcount = 0; RRcount = 0; symbol = -1; for (p = parser[i]; p; p = p->next) { if (p->symbol != symbol) { pref = p; symbol = p->symbol; } else if (i == final_state && symbol == 0) { SRcount++; p->suppressed = 1; } else if (pref->action_code == SHIFT) { if (pref->prec > 0 && p->prec > 0) { if (pref->prec < p->prec) { pref->suppressed = 2; pref = p; } else if (pref->prec > p->prec) { p->suppressed = 2; } else if (pref->assoc == LEFT) { pref->suppressed = 2; pref = p; } else if (pref->assoc == RIGHT) { p->suppressed = 2; } else { pref->suppressed = 2; p->suppressed = 2; } } else { SRcount++; p->suppressed = 1; } } else { RRcount++; p->suppressed = 1; } } SRtotal += SRcount; RRtotal += RRcount; SRconflicts[i] = SRcount; RRconflicts[i] = RRcount; } }
false
false
false
false
true
1
gedit_tab_dispose (GObject *object) { GeditTab *tab = GEDIT_TAB (object); if (tab->priv->print_job != NULL) { g_signal_handlers_disconnect_by_func (tab->priv->print_job, done_printing_cb, tab); g_object_unref (tab->priv->print_job); tab->priv->print_job = NULL; tab->priv->print_preview = NULL; } g_clear_object (&tab->priv->tmp_save_location); g_clear_object (&tab->priv->editor); G_OBJECT_CLASS (gedit_tab_parent_class)->dispose (object); }
false
false
false
false
false
0
NSSUTIL_ArgSkipParameter(char *string) { char *end; /* look for the end of the <name>= */ for (;*string; string++) { if (*string == '=') { string++; break; } if (NSSUTIL_ArgIsBlank(*string)) return(string); } end = NSSUTIL_ArgFindEnd(string); if (*end) end++; return end; }
false
false
false
false
false
0
ArgusBackList(struct ArgusListStruct *list) { void *retn = NULL; if (list->start) retn = list->start->prv->obj; #ifdef ARGUSDEBUG ArgusDebug (6, "ArgusBackList (0x%x) returning 0x%x\n", list, retn); #endif return (retn); }
false
false
false
false
false
0
test_status_ignore__negative_ignores_in_slash_star(void) { git_status_options status_opts = GIT_STATUS_OPTIONS_INIT; git_status_list *list; int found_look_ma = 0, found_what_about = 0; size_t i; static const char *test_files[] = { "empty_standard_repo/bin/look-ma.txt", "empty_standard_repo/bin/what-about-me.txt", NULL }; make_test_data("empty_standard_repo", test_files); cl_git_mkfile( "empty_standard_repo/.gitignore", "bin/*\n" "!bin/w*\n"); assert_is_ignored("bin/look-ma.txt"); refute_is_ignored("bin/what-about-me.txt"); status_opts.flags = GIT_STATUS_OPT_DEFAULTS; cl_git_pass(git_status_list_new(&list, g_repo, &status_opts)); for (i = 0; i < git_status_list_entrycount(list); i++) { const git_status_entry *entry = git_status_byindex(list, i); if (!strcmp("bin/look-ma.txt", entry->index_to_workdir->new_file.path)) found_look_ma = 1; if (!strcmp("bin/what-about-me.txt", entry->index_to_workdir->new_file.path)) found_what_about = 1; } git_status_list_free(list); cl_assert(found_look_ma); cl_assert(found_what_about); }
false
false
false
false
false
0
GDALRegister_ADRG() { GDALDriver *poDriver; if( GDALGetDriverByName( "ADRG" ) == NULL ) { poDriver = new GDALDriver(); poDriver->SetDescription( "ADRG" ); poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, "ARC Digitized Raster Graphics" ); poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, "frmt_various.html#ADRG" ); poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "gen" ); poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, "Byte" ); poDriver->SetMetadataItem( GDAL_DMD_SUBDATASETS, "YES" ); poDriver->SetMetadataItem( GDAL_DCAP_VIRTUALIO, "YES" ); poDriver->pfnOpen = ADRGDataset::Open; poDriver->pfnCreate = ADRGDataset::Create; GetGDALDriverManager()->RegisterDriver( poDriver ); } }
false
false
false
false
false
0
operator==(const TimeZoneRule& that) const { if (this == &that) { return TRUE; } if (typeid(*this) != typeid(that)) { return FALSE; } AnnualTimeZoneRule *atzr = (AnnualTimeZoneRule*)&that; return (*fDateTimeRule == *(atzr->fDateTimeRule) && fStartYear == atzr->fStartYear && fEndYear == atzr->fEndYear); }
false
false
false
false
false
0
hdpvr_set_audio(struct hdpvr_device *dev, u8 input, enum v4l2_mpeg_audio_encoding codec) { int ret = 0; if (dev->flags & HDPVR_FLAG_AC3_CAP) { mutex_lock(&dev->usbc_mutex); memset(dev->usbc_buf, 0, 2); dev->usbc_buf[0] = input; if (codec == V4L2_MPEG_AUDIO_ENCODING_AAC) dev->usbc_buf[1] = 0; else if (codec == V4L2_MPEG_AUDIO_ENCODING_AC3) dev->usbc_buf[1] = 1; else { mutex_unlock(&dev->usbc_mutex); v4l2_err(&dev->v4l2_dev, "invalid audio codec %d\n", codec); ret = -EINVAL; goto error; } ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), 0x01, 0x38, CTRL_AUDIO_INPUT_VALUE, CTRL_DEFAULT_INDEX, dev->usbc_buf, 2, 1000); mutex_unlock(&dev->usbc_mutex); if (ret == 2) ret = 0; } else ret = hdpvr_config_call(dev, CTRL_AUDIO_INPUT_VALUE, input); error: return ret; }
false
false
false
false
false
0
delfeed (lofig) /*===========================================================================*/ lofig_list *lofig; { loins_list *loins, *temploins; for (loins = lofig->LOINS; loins != NULL; loins = temploins) { temploins = loins->NEXT; if (incatalogfeed(loins->FIGNAME)) if (delloins (lofig, loins->INSNAME) != 1) fatalerror ("Fatal error on instance deleting. (delins)"); } }
false
false
false
false
false
0
vm_object_dump(vm_instance_t *vm) { vm_obj_t *obj; printf("VM \"%s\" (%u) object list:\n",vm->name,vm->instance_id); for(obj=vm->vm_object_list;obj;obj=obj->next) { printf(" - %-15s [data=%p]\n",obj->name,obj->data); } printf("\n"); }
false
false
false
false
false
0
datetime_astimezone(PyDateTime_DateTime *self, PyObject *args, PyObject *kw) { PyObject *result; PyObject *offset; PyObject *temp; PyObject *tzinfo; _Py_IDENTIFIER(fromutc); static char *keywords[] = {"tz", NULL}; if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:astimezone", keywords, &PyDateTime_TZInfoType, &tzinfo)) return NULL; if (!HASTZINFO(self) || self->tzinfo == Py_None) goto NeedAware; /* Conversion to self's own time zone is a NOP. */ if (self->tzinfo == tzinfo) { Py_INCREF(self); return (PyObject *)self; } /* Convert self to UTC. */ offset = datetime_utcoffset((PyObject *)self, NULL); if (offset == NULL) return NULL; if (offset == Py_None) { Py_DECREF(offset); NeedAware: PyErr_SetString(PyExc_ValueError, "astimezone() cannot be applied to " "a naive datetime"); return NULL; } /* result = self - offset */ result = add_datetime_timedelta(self, (PyDateTime_Delta *)offset, -1); Py_DECREF(offset); if (result == NULL) return NULL; /* Attach new tzinfo and let fromutc() do the rest. */ temp = ((PyDateTime_DateTime *)result)->tzinfo; ((PyDateTime_DateTime *)result)->tzinfo = tzinfo; Py_INCREF(tzinfo); Py_DECREF(temp); temp = result; result = _PyObject_CallMethodId(tzinfo, &PyId_fromutc, "O", temp); Py_DECREF(temp); return result; }
false
false
false
false
false
0
mpc860_scc_update_irq(struct mpc860_data *d,u_int scc_chan) { struct mpc860_scc_chan *chan = &d->scc_chan[scc_chan]; if (chan->scce & chan->sccm) d->cipr |= scc_chan_info[scc_chan].cipr_irq; else d->cipr &= ~scc_chan_info[scc_chan].cipr_irq; mpc860_update_cpm_int_status(d); return(0); }
false
false
false
false
false
0
open_ins_file(fc_type fc, rbool report_error) { ins_buff=NULL; ins_line=0; if (ins_descr!=NULL) return 1; if (filevalid(insfile,fINS)) { textrewind(insfile); return 1; } if (agx_file) { ins_descr=read_descr(ins_ptr.start,ins_ptr.size); if (ins_descr!=NULL) return 1; /* Note that if the AGX file doesn't contain an INS block, we don't immediatly give up but try opening <fname>.INS */ } insfile=openfile(fc, fINS, report_error ? "Sorry, Instructions aren't available for this game" : NULL, 0); return(filevalid(insfile,fINS)); }
false
false
false
false
false
0
gru_check_context_placement(struct gru_thread_state *gts) { struct gru_state *gru; /* * If the current task is the context owner, verify that the * context is correctly placed. This test is skipped for non-owner * references. Pthread apps use non-owner references to the CBRs. */ gru = gts->ts_gru; if (!gru || gts->ts_tgid_owner != current->tgid) return; if (!gru_check_chiplet_assignment(gru, gts)) { STAT(check_context_unload); gru_unload_context(gts, 1); } else if (gru_retarget_intr(gts)) { STAT(check_context_retarget_intr); } }
false
false
false
false
false
0
LI49() { VMB49 VMS49 VMV49 goto TTL; TTL:; base[0]= ((object)VV[67]); base[1]= (((object)VV[8])->s.s_dbind); vs_top=(vs_base=base+0)+2; Ladjoin(); vs_top=sup; (((object)VV[8])->s.s_dbind)= vs_base[0]; {object V78 = Cnil; VMR49(V78)} base[0]=base[0]; return Cnil; }
false
false
false
false
false
0
lookupDefaultUidGid(uid_t &uid, gid_t &gid) { struct passwd *userEntry; userEntry = getpwnam(defaultUser.c_str()); if (userEntry == NULL) { throw NonExistentUserException("Default user '" + defaultUser + "' does not exist."); } uid = userEntry->pw_uid; gid = lookupGid(defaultGroup); if (gid == (gid_t) -1) { throw NonExistentGroupException("Default group '" + defaultGroup + "' does not exist."); } }
false
false
false
false
false
0
avatar_chooser_update_preview_cb (GtkFileChooser *file_chooser, TpawAvatarChooser *self) { gchar *filename; filename = gtk_file_chooser_get_preview_filename (file_chooser); if (filename != NULL) { GtkWidget *image; GdkPixbuf *pixbuf = NULL; GdkPixbuf *scaled_pixbuf; pixbuf = gdk_pixbuf_new_from_file (filename, NULL); image = gtk_file_chooser_get_preview_widget (file_chooser); if (pixbuf != NULL) { scaled_pixbuf = tpaw_pixbuf_scale_down_if_necessary (pixbuf, AVATAR_SIZE_SAVE); gtk_image_set_from_pixbuf (GTK_IMAGE (image), scaled_pixbuf); g_object_unref (scaled_pixbuf); g_object_unref (pixbuf); } else { gtk_image_set_from_stock (GTK_IMAGE (image), "dialog-question", GTK_ICON_SIZE_DIALOG); } g_free (filename); } gtk_file_chooser_set_preview_widget_active (file_chooser, TRUE); }
false
false
false
false
false
0
AddWeapon(short id, char name[], short wpndmg, short wpndmg_z1, short wpndmg_z2, short freq, short speed, short slot, short price, short range, short accuracy, short ammo1, short ammo2, int reloadtime, short special, short team) { if (name != NULL) { weapons[id].name = malloc(strlen(name) + 1); if (weapons[id].name == NULL) error_exit("Memory Error in AddWeapon()\n"); strncpy(weapons[id].name, name, strlen(name) + 1); } else { weapons[id].name = NULL; } weapons[id].weapondamage = wpndmg; weapons[id].weapondamage_z1 = wpndmg_z1; weapons[id].weapondamage_z2 = wpndmg_z2; weapons[id].freq = freq; weapons[id].speed = speed; weapons[id].slot = slot; weapons[id].price = price; weapons[id].range = range; weapons[id].accuracy = accuracy; weapons[id].ammo1 = ammo1; weapons[id].ammo2 = ammo2; weapons[id].reloadtime = reloadtime; weapons[id].special = special; weapons[id].team = team; }
false
true
false
false
false
1
alloc_inode(struct fs_info *fs, uint32_t ino, size_t data) { struct inode *inode = zalloc(sizeof(struct inode) + data); if (inode) { inode->fs = fs; inode->ino = ino; inode->refcnt = 1; } return inode; }
false
false
false
false
false
0
accumulator_output(struct fortuna_state *st, unsigned char *dst, size_t len) { /* Reseed the generator with data from pools if we have accumulated enough * data and enough time has passed since the last accumulator reseed. */ if (st->pool0_bytes >= MIN_POOL_LEN && enough_time_passed(st)) accumulator_reseed(st); generator_output(st, dst, len); }
false
false
false
false
false
0