void destroy_indirect_table(indirect_table *tab) { int i; indirect_buckets *buckets, *prev; indirect_array *arr = &tab->array; #ifdef O_PLMT simpleMutexDelete(&tab->mutex); #endif clean_block(arr->preallocated, PREALLOCATED_INDIRECT_BLOCKS); for(i=MSB(PREALLOCATED_INDIRECT_BLOCKS); i<MAX_INDIRECT_BLOCKS; i++) { if ( arr->blocks[i] ) { size_t bs = (size_t)1<<i; indirect *block = arr->blocks[i]+bs; clean_block(block, bs); PL_free(block); } } for(buckets = tab->table; buckets; buckets = prev) { prev = buckets->prev; PL_free(buckets->buckets); PL_free(buckets); } PL_free(tab); }
void destroyHTable(Table ht) { #ifdef O_PLMT if ( ht->mutex ) { simpleMutexDelete(ht->mutex); freeHeap(ht->mutex, sizeof(*ht->mutex)); ht->mutex = NULL; } #endif clearHTable(ht); freeHeap(ht->entries, ht->buckets * sizeof(Symbol)); freeHeap(ht, sizeof(struct table)); }