static void moviecache_keyfree(void *val) { MovieCacheKey *key = (MovieCacheKey *)val; BLI_mempool_free(key->cache_owner->userkeys_pool, key->userkey); BLI_mempool_free(key->cache_owner->keys_pool, key); }
int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) { unsigned int hash= gh->hashfp(key)%gh->nbuckets; Entry *e; Entry *p = NULL; for (e= gh->buckets[hash]; e; e= e->next) { if (gh->cmpfp(key, e->key)==0) { Entry *n= e->next; if (keyfreefp) keyfreefp(e->key); if (valfreefp) valfreefp(e->val); BLI_mempool_free(gh->entrypool, e); /* correct but 'e' isnt used before return */ /* e= n; */ /*UNUSED*/ if (p) p->next = n; else gh->buckets[hash] = n; --gh->nentries; return 1; } p = e; } return 0; }
/** * \brief Remove Current Walker State * * Remove and free an item from the end of the walker state * worklist. */ void BMW_state_remove(BMWalker *walker) { void *oldstate; oldstate = BMW_current_state(walker); BLI_remlink(&walker->states, oldstate); BLI_mempool_free(walker->worklist, oldstate); }
/* same as above but return the value, * no free value argument since it will be returned */ void *BLI_ghash_pop(GHash *gh, void *key, GHashKeyFreeFP keyfreefp) { unsigned int hash = gh->hashfp(key) % gh->nbuckets; Entry *e; Entry *p = NULL; for (e = gh->buckets[hash]; e; e = e->next) { if (gh->cmpfp(key, e->key) == 0) { Entry *n = e->next; void *value = e->val; if (keyfreefp) keyfreefp(e->key); BLI_mempool_free(gh->entrypool, e); /* correct but 'e' isn't used before return */ /* e = n; *//*UNUSED*/ if (p) p->next = n; else gh->buckets[hash] = n; gh->nentries--; return value; } p = e; } return NULL; }
/** * Remove \a key (v0, v1) from \a eh, or return false if the key wasn't found. * * \param v0, v1: The key to remove. * \param valfreefp: Optional callback to free the value. * \return true if \a key was removed from \a eh. */ bool BLI_edgehash_remove(EdgeHash *eh, uint v0, uint v1, EdgeHashFreeFP valfreefp) { EDGE_ORD(v0, v1); const uint bucket_index = edgehash_bucket_index(eh, v0, v1); EdgeEntry *e = edgehash_remove_ex(eh, v0, v1, valfreefp, bucket_index); if (e) { BLI_mempool_free(eh->epool, e); return true; } else { return false; } }
/** * Remove \a key (v0, v1) from \a eh, returning the value or NULL if the key wasn't found. * * \param v0, v1: The key to remove. * \return the value of \a key int \a eh or NULL. */ void *BLI_edgehash_popkey(EdgeHash *eh, uint v0, uint v1) { EDGE_ORD(v0, v1); const uint bucket_index = edgehash_bucket_index(eh, v0, v1); EdgeEntry *e = edgehash_remove_ex(eh, v0, v1, NULL, bucket_index); IS_EDGEHASH_ASSERT(eh); if (e) { void *val = e->val; BLI_mempool_free(eh->epool, e); return val; } else { return NULL; } }
/*Block level ops*/ void BME_CD_free_block(BME_CustomData *data, void **block) { const BME_LayerTypeInfo *typeInfo; int i; if(!*block) return; for(i = 0; i < data->totlayer; ++i) { typeInfo = BME_layerType_getInfo(data->layers[i].type); if(typeInfo->free) { int offset = data->layers[i].offset; typeInfo->free((char*)*block + offset, 1, typeInfo->size); } } BLI_mempool_free(data->pool, *block); *block = NULL; }
static void HashValFree(void *val) { seqCacheEntry* e = (seqCacheEntry*) val; if (e->ibuf) { /* fprintf(stderr, "Removing: %p, cnt: %d\n", e->ibuf, e->ibuf->refcounter); */ IMB_freeImBuf(e->ibuf); MEM_CacheLimiter_unmanage(e->c_handle); ibufs_rem++; } e->ibuf = NULL; e->c_handle = NULL; BLI_mempool_free(entrypool, e); }
static void moviecache_valfree(void *val) { MovieCacheItem *item = (MovieCacheItem *)val; MovieCache *cache = item->cache_owner; PRINT("%s: cache '%s' free item %p buffer %p\n", __func__, cache->name, item, item->ibuf); if (item->ibuf) { MEM_CacheLimiter_unmanage(item->c_handle); IMB_freeImBuf(item->ibuf); } if (item->priority_data && cache->prioritydeleterfp) { cache->prioritydeleterfp(item->priority_data); } BLI_mempool_free(item->cache_owner->items_pool, item); }
void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp) { unsigned int i; for (i = 0; i < eh->nbuckets; i++) { EdgeEntry *e; for (e = eh->buckets[i]; e; ) { EdgeEntry *n = e->next; if (valfreefp) valfreefp(e->val); BLI_mempool_free(eh->epool, e); e = n; } eh->buckets[i] = NULL; } eh->nentries = 0; }
static void HashKeyFree(void *key) { BLI_mempool_free(keypool, key); }