library/src/datastructures/BP-HashTable.cc
// Destroys a hash table registry, removing all associated allocations.
Destroys a hash table registry, removing all associated allocations.
Destroys a hash table registry removing all associated allocations .
BP_ERROR_T BP_DestroyHashTableRegistry(P_BP_HASH_TABLE_REGISTRY hreg)
{
	BP_GLOBAL_HASH_TABLE_OVERRIDE(ERR_FAILURE);
	BP_BOOL is_ght = BP_FALSE;
	if(hreg->is_global == BP_TRUE)
		is_ght = BP_TRUE;
	BP_HASH_TABLE_LOCK_SEM(hreg->lock);
	if(hreg->hive)
	{
		BP_HashRegDestroyHive(hreg);
	}
	if(hreg->memory_table)
	{
		BP_HashRegDeleteAllMemoryEntries(hreg);
		free(hreg->memory_table);
		hreg->memory_table = NULL;
	}
	BP_HASH_TABLE_UNLOCK_SEM(hreg->lock);
	BP_HASH_TABLE_DESTROY_SEM(hreg->lock);
	if(!is_ght)
	{
		free(hreg);
		hreg = NULL;
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DestroyHashTableRegistry ( P_BP_HASH_TABLE_REGISTRY hreg ) { BP_GLOBAL_HASH_TABLE_OVERRIDE ( ERR_FAILURE ) ; BP_BOOL is_ght = BP_FALSE ; if ( hreg -> is_global == BP_TRUE ) is_ght = BP_TRUE ; BP_HASH_TABLE_LOCK_SEM ( hreg -> lock ) ; if ( hreg -> hive ) { BP_HashRegDestroyHive ( hreg ) ; } if ( hreg -> memory_table ) { BP_HashRegDeleteAllMemoryEntries ( hreg ) ; free ( hreg -> memory_table ) ; hreg -> memory_table = NULL ; } BP_HASH_TABLE_UNLOCK_SEM ( hreg -> lock ) ; BP_HASH_TABLE_DESTROY_SEM ( hreg -> lock ) ; if ( ! is_ght ) { free ( hreg ) ; hreg = NULL ; } return ERR_SUCCESS ; }
Destroys a hash table registry, removing all associated allocations.
Destroys a hash table registry removing all associated allocations .
// macro to override hreg on null // flag indicating whether or not this is the singleton global hash table // if the hreg is marked specifically as global, indicate it here. // attempt to acquire the hive semaphore // destroy hive if set // attempt to destroy the registry hive first // NOTE: Since the hive is a recursing set of structures, you don't //       need to destroy the hreg->hive pointer. // destroy memory table if set // purge any dangling memory entries // destroy the memory table // attempt to unlock // attempt to lock the table // if it's not the GHT we can free it // return indicating success