static void __destroy(struct rb_node *n) { if (n) { struct seek_bkt *sbp = rb_entry(n, struct seek_bkt, rb_node); __destroy(n->rb_left); __destroy(n->rb_right); free(sbp); } }
static void __destroy (rbtree_t *T, rbtree_node_t *n) { if (n != T->nil) { Py_DECREF(n->key); Py_DECREF(n->value); __destroy(T, n->l); __destroy(T, n->r); DEL (n); } }
void rbtree_dealloc(rbtree_t *T) { __destroy(T, T->root); Py_XDECREF(T->compare); DEL(T->nil); }
void ResourceArray::_destroy(unsigned index) { void **res = mRes; byte *types = mResTypes; if(index&DYNAMIC_PLACEHOLDER_BIT) { res = mDynRes; types = mDynResTypes; index = index&(~DYNAMIC_PLACEHOLDER_BIT); TESTINDEX(index, mDynResSize); } else { TESTINDEX(index, mResSize); } MYASSERT(types[index] != RT_FLUX, ERR_RES_DESTROY_FLUX); #ifdef RESOURCE_MEMORY_LIMIT switch(types[index]) { #define CASE_SUBMEM(R, T, D) case R: mResmem -= size_##R((T*)res[index]); break; TYPES(CASE_SUBMEM); } if(mResmem > mResmemMax) { DEBIG_PHAT_ERROR; } #endif //RESOURCE_MEMORY_LIMIT __destroy(res[index], types[index], index); res[index] = NULL; types[index] = RT_PLACEHOLDER; }
void seeki_free(void *param) { struct seeki *sip = param; if (sip->sps_fp && sip->sps.nseeks != 0) sps_emit(sip); /* * Associated files are cleaned up by seek_clean */ __destroy(sip->root.rb_node); free(sip); }
/** * Add a resource. * @param index Resource index. * @param obj Pointer to object data. * @param type Resource type. */ int ResourceArray::_add(unsigned index, void* obj, byte type) { void **res = mRes; byte *types = mResTypes; if(index&DYNAMIC_PLACEHOLDER_BIT) { res = mDynRes; types = mDynResTypes; index = index&(~DYNAMIC_PLACEHOLDER_BIT); TESTINDEX(index, mDynResSize); } else { TESTINDEX(index, mResSize); } // obj is the resource data. If the resource is NULL // and not a placeholder or in flux (resource is changing) // then create a panic. if (obj == NULL && (type != RT_PLACEHOLDER && type != RT_FLUX)) { DEBIG_PHAT_ERROR; } // Resource at this index must not be in use, but it can be a // placeholder. If the resource is in use, a panic is generated. if(res[index] != NULL || types[index] != RT_PLACEHOLDER) { BIG_PHAT_ERROR(ERR_RES_OVERWRITE); } #ifdef RESOURCE_MEMORY_LIMIT int oldResmem = mResmem; switch(type) { #define CASE_ADDMEM(R, T, D) case R: mResmem += size_##R((T*)obj); break; TYPES(CASE_ADDMEM); } if(mResmem >= mResmemMax) { //BIG_PHAT_ERROR(ERR_RES_OOM); mResmem = oldResmem; __destroy(obj, type, index); //avoids memory leaks return RES_OUT_OF_MEMORY; } #endif //RESOURCE_MEMORY_LIMIT res[index] = obj; types[index] = type; return RES_OK; }
/** * Board destructor * */ Board::~Board() { __destroy(); }