void mono_g_hash_table_destroy (MonoGHashTable *hash) { int i; g_return_if_fail (hash != NULL); #ifdef HAVE_SGEN_GC mono_gc_deregister_root ((char*)hash); #endif for (i = 0; i < hash->table_size; i++){ Slot *s, *next; for (s = hash->table [i]; s != NULL; s = next){ next = s->next; if (hash->key_destroy_func != NULL) (*hash->key_destroy_func)(s->key); if (hash->value_destroy_func != NULL) (*hash->value_destroy_func)(s->value); free_slot (hash, s); } } mg_free (hash->table); mg_free (hash); }
gboolean mono_g_hash_table_remove (MonoGHashTable *hash, gconstpointer key) { GEqualFunc equal; Slot *s, *last; guint hashcode; g_return_val_if_fail (hash != NULL, FALSE); equal = hash->key_equal_func; hashcode = ((*hash->hash_func)(key)) % hash->table_size; last = NULL; for (s = hash->table [hashcode]; s != NULL; s = s->next){ if ((*equal)(s->key, key)){ if (hash->key_destroy_func != NULL) (*hash->key_destroy_func)(s->key); if (hash->value_destroy_func != NULL) (*hash->value_destroy_func)(s->value); if (last == NULL) hash->table [hashcode] = s->next; else last->next = s->next; free_slot (hash, s); hash->in_use--; return TRUE; } last = s; } return FALSE; }
int disk_client_poll(struct disk_client *c) { struct disk_msg msg; struct disk_client_slot *slot; int slot_num; while (channel_can_recv(c->resp_chan)) { channel_recv(c->resp_chan, &msg); slot_num = msg.handle; slot = get_slot(c, slot_num); if (msg.status != 0) { slot->err(&msg); } else { if (msg.type == DISK_SIZE) { slot->cb.size(msg.device_size); } else if (msg.type == DISK_READ) { slot->cb.read(msg.num_sectors, msg.start_sector, msg.payload); } else { slot->cb.write(msg.num_sectors, msg.start_sector); } } free_slot(c, slot_num); } return 0; }
static void rpcb_callit_done(ar_clnt_call_obj_t cco, void *arg, const arpc_err_t *stat, void *result) { struct finfo *fi; rpcb_remote_result_t *ret; r_rmtcall_args_t *r; int err; fi = (struct finfo *)arg; ret = (rpcb_remote_result_t *)result; assert(ret != NULL); assert(fi != NULL); assert(fi->cco == cco); err = ar_svc_async_get_resultptr(fi->sco, (void **)&r); if (err == 0 && stat->re_status == ARPC_SUCCESS) { r->rmt_localvers = fi->localvers; r->rmt_uaddr = fi->uaddr; fi->uaddr = NULL; r->rmt_ret = ret->buf; r->rmt_retlen = ret->off; memset(ret, 0, sizeof(*ret)); ar_svc_async_done(fi->sco, 0); } else { switch (stat->re_status) { case ARPC_AUTHERROR: ar_scoflgerr_auth(fi->sco, stat->re_why); break; case ARPC_PROGUNAVAIL: ar_scoflgerr_noprog(fi->sco); break; case ARPC_PROGVERSMISMATCH: ar_scoflgerr_progvers(fi->sco, stat->re_vers.low, stat->re_vers.high); break; case ARPC_PROCUNAVAIL: ar_scoflgerr_noproc(fi->sco); break; case ARPC_CANTDECODEARGS: ar_scoflgerr_decode(fi->sco); break; default: ar_scoflgerr_systemerr(fi->sco); break; } ar_svc_async_done(fi->sco, EINVAL); } /* reply is now going out, clean up rest of state */ fi->sco = NULL; fi->cco = NULL; free_slot(fi); }
static void free_slot(struct radix_tree *tree, struct radix_tree_node *node, unsigned long key, int level) { node->slots[get_index(tree, key, level)] = NULL; node->count--; if (node->count == 0 && node->parent != NULL) { free_slot(tree, node->parent, key, level - 1); free(node); } }
static int free_bucket_cb(void *context, void *entry, const size_t sizeof_entry) { Slot *slot = entry; (void) context; (void) sizeof_entry; free_slot(slot); return 0; }
void arch_uninstall_hw_breakpoint(struct perf_event *bp) { struct arch_hw_breakpoint *info = counter_arch_bp(bp); int i; if (info->type == XTENSA_BREAKPOINT_EXECUTE) { unsigned long ibreakenable; /* Breakpoint */ i = free_slot(this_cpu_ptr(bp_on_reg), XCHAL_NUM_IBREAK, bp); if (i >= 0) { ibreakenable = xtensa_get_sr(SREG_IBREAKENABLE); xtensa_set_sr(ibreakenable & ~(1 << i), SREG_IBREAKENABLE); } } else { /* Watchpoint */ i = free_slot(this_cpu_ptr(wp_on_reg), XCHAL_NUM_DBREAK, bp); if (i >= 0) xtensa_wsr(0, SREG_DBREAKC + i); } }
/** * radix_tree_remove - remove mapping from tree. * @tree: a radix tree to remove from. * @key: a key to remove. */ void radix_tree_remove(struct radix_tree *tree, unsigned long key) { struct radix_tree_node *node = tree->root; int i; for (i = 0; i < level_count(tree) - 1; i++) { int index = get_index(tree, key, i); if (node->slots[index] == NULL) return; /* no mapping exists */ node = node->slots[index]; } free_slot(tree, node, key, i); }
static int free_slot_by_index(int index) { struct finfo *fi; if (index < 0 || index >= NFORWARD) { return 0; } fi = &FINFO[index]; if (fi->flag & FINFO_ACTIVE) { free_slot(fi); return (1); } return (0); }
/* {{{ apc_cache_gc */ PHP_APCU_API void apc_cache_gc(apc_cache_t* cache) { /* This function scans the list of removed cache entries and deletes any * entry whose reference count is zero or that has been on the gc * list for more than cache->gc_ttl seconds * (we issue a warning in the latter case). */ if (!cache || !cache->header->gc) { return; } { apc_cache_slot_t** slot = &cache->header->gc; while (*slot != NULL) { time_t now = time(0); time_t gc_sec = cache->gc_ttl ? (now - (*slot)->dtime) : 0; if (!(*slot)->value->ref_count || gc_sec > (time_t)cache->gc_ttl) { apc_cache_slot_t* dead = *slot; /* good ol' whining */ if (dead->value->ref_count > 0) { apc_debug( "GC cache entry '%s' was on gc-list for %d seconds", dead->key.str, gc_sec ); } /* set next slot */ *slot = dead->next; /* free slot */ free_slot( dead); /* next */ continue; } else { slot = &(*slot)->next; } } } }
void _nscd_free_cslots() { int i; (void) mutex_lock(&child_lock); for (i = 0; i < max_pu_nscd; i++) free_slot(i); open_head = -1; open_tail = -1; used_slot = -1; (void) mutex_unlock(&child_lock); }
guint mono_g_hash_table_foreach_remove (MonoGHashTable *hash, GHRFunc func, gpointer user_data) { int i; int count = 0; g_return_val_if_fail (hash != NULL, 0); g_return_val_if_fail (func != NULL, 0); for (i = 0; i < hash->table_size; i++){ Slot *s, *last; last = NULL; for (s = hash->table [i]; s != NULL; ){ if ((*func)(s->key, s->value, user_data)){ Slot *n; if (hash->key_destroy_func != NULL) (*hash->key_destroy_func)(s->key); if (hash->value_destroy_func != NULL) (*hash->value_destroy_func)(s->value); if (last == NULL){ hash->table [i] = s->next; n = s->next; } else { last->next = s->next; n = last->next; } free_slot (hash, s); hash->in_use--; count++; s = n; } else { last = s; s = s->next; } } } if (count > 0) rehash (hash); return count; }
/* {{{ apc_cache_remove_slot */ PHP_APCU_API void apc_cache_remove_slot(apc_cache_t* cache, apc_cache_slot_t** slot) { apc_cache_slot_t* dead = *slot; /* think here is safer */ *slot = (*slot)->next; /* adjust header info */ if (cache->header->mem_size) cache->header->mem_size -= dead->value->mem_size; if (cache->header->nentries) cache->header->nentries--; /* remove if there are no references */ if (dead->value->ref_count <= 0) { free_slot(dead); } else { /* add to gc if there are still refs */ dead->next = cache->header->gc; dead->dtime = time(0); cache->header->gc = dead; } }
int tc_filter(frame_list_t *ptr_, char *options){ vframe_list_t * ptr = (vframe_list_t *)ptr_; int frame_slot = 0; static vob_t *vob=NULL; static int slots[TC_FRAME_THREADS_MAX]; if(ptr->tag & TC_FILTER_GET_CONFIG) { optstr_filter_desc (options, MOD_NAME, MOD_CAP, MOD_VERSION, "Julien Tierny", "VRYMO", "1"); optstr_param (options, "font", "Valid PSF font file (provided with the `aart` package)", "%s", "default8x9.psf"); optstr_param (options, "pallete", "Valid pallete file (provided with the `aart` package)", "%s", "colors.pal"); optstr_param(options, "threads", "Use multiple-threaded routine for picture rendering", "%d", "0", "1", "oo"); /* Boolean parameter */ optstr_param(options, "buffer", "Use `aart` internal buffer for output", "", "-1"); return 0; } //---------------------------------- // // filter init // //---------------------------------- if(ptr->tag & TC_FILTER_INIT) { if((vob = tc_get_vob())==NULL) return(-1); /* aart sanity check */ if (tc_test_program("aart") !=0 ) return -1; /* Now, let's handle the options ... */ if((parameters = tc_malloc (sizeof(parameter_struct))) == NULL){ tc_log_error(MOD_NAME, "Out of memory !!!"); return -1; } /* Filter default options */ if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Preparing default options."); strncpy(parameters->aart_font, "default8x9.psf", strlen("default8x9.psf")); if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Default options correctly formated."); strncpy(parameters->aart_pallete, "colors.pal", strlen("colors.pal")); parameters->aart_threads = 1; parameters->aart_buffer = -1; parameters->tcvhandle = 0; if (options){ /* Get filter options via transcode core */ if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Merging options from transcode."); optstr_get(options, "font", "%s", parameters->aart_font); clean_parameter(parameters->aart_font); optstr_get(options, "pallete", "%s", parameters->aart_pallete); clean_parameter(parameters->aart_pallete); optstr_get(options, "threads", "%d", ¶meters->aart_threads); if (optstr_lookup(options, "buffer") != NULL) parameters->aart_buffer=1; if (optstr_lookup(options, "help") != NULL) help_optstr(); if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Options correctly merged."); } if (vob->im_v_codec == CODEC_YUV){ if (!(parameters->tcvhandle = tcv_init())) { tc_log_error(MOD_NAME, "Error at image conversion initialization."); return(-1); } } /* Init thread slots (multithread support)*/ init_slots(slots); if(verbose) tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP); return(0); } //---------------------------------- // // filter close // //---------------------------------- if(ptr->tag & TC_FILTER_CLOSE) { /* * TODO : * Provide a `aart` kill routine in case of cancel. * For the moment, transcode waits for the `aart` * process to finish before exiting. */ tcv_free(parameters->tcvhandle); /* Let's free the parameter structure */ free(parameters); parameters = NULL; return(0); } //---------------------------------- // // filter frame routine // //---------------------------------- if(ptr->tag & TC_POST_M_PROCESS && ptr->tag & TC_VIDEO && !(ptr->attributes & TC_FRAME_IS_SKIPPED)) { frame_slot = find_empty_slot(ptr->id, slots); switch(vob->im_v_codec){ case CODEC_RGB: return aart_render(ptr->video_buf, ptr->v_width, ptr->v_height, frame_slot, parameters->aart_font, parameters->aart_pallete, parameters->aart_threads, parameters->aart_buffer); break; case CODEC_YUV: if (!tcv_convert(parameters->tcvhandle, ptr->video_buf, ptr->video_buf, ptr->v_width, ptr->v_height, IMG_YUV_DEFAULT, IMG_RGB24)){ tc_log_error(MOD_NAME, "cannot convert YUV stream to RGB format !"); return -1; } if (aart_render(ptr->video_buf, ptr->v_width, ptr->v_height, frame_slot, parameters->aart_font, parameters->aart_pallete, parameters->aart_threads, parameters->aart_buffer) == -1){return -1;} if (!tcv_convert(parameters->tcvhandle, ptr->video_buf, ptr->video_buf, ptr->v_width, ptr->v_height, IMG_RGB24, IMG_YUV_DEFAULT)){ tc_log_error(MOD_NAME, "cannot convert RGB stream to YUV format !"); return -1; } break; default: tc_log_error(MOD_NAME, "Internal video codec is not supported."); return -1; } free_slot(ptr->id, slots); } return(0); }