library/src/datastructures/BP-HashTable.cc
// Attempts to destroy an entire hive table by table.
Attempts to destroy an entire hive table by table.
Attempts to destroy an entire hive table by table .
BP_ERROR_T BP_HashRegDestroyHive
(
	P_BP_HASH_TABLE_REGISTRY hreg
)
{
	BP_GLOBAL_HASH_TABLE_OVERRIDE(ERR_FAILURE);
	if(!hreg->hive)
		return ERR_FAILURE;
	P_BP_HASH_TABLE_KEYED_ENTRY entry       = NULL;
	P_BP_HASH_TABLE_KEYED_ENTRY tmp         = NULL;
	P_BP_HASH_TABLE_KEYED_ENTRY sub_table   = NULL;
	BP_ERROR_T data_destroy_status  = ERR_FAILURE;
	BP_ERROR_T table_destroy_status = ERR_FAILURE;
	HASH_ITER(hh, hreg->hive, entry, tmp)
	{
		data_destroy_status  = ERR_FAILURE;
		table_destroy_status = ERR_FAILURE;
		if(entry->type == BP_HASH_TABLE_KEYED_ENTRY_TYPE_NAMED_HASH_TABLE)
		{
			table_destroy_status = BP_HashRegDestroyTable_r
			(
				hreg,
				entry
			);
			if(table_destroy_status == ERR_FAILURE)
			{
				return ERR_FAILURE;
			}
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_HashRegDestroyHive ( P_BP_HASH_TABLE_REGISTRY hreg ) { BP_GLOBAL_HASH_TABLE_OVERRIDE ( ERR_FAILURE ) ; if ( ! hreg -> hive ) return ERR_FAILURE ; P_BP_HASH_TABLE_KEYED_ENTRY entry = NULL ; P_BP_HASH_TABLE_KEYED_ENTRY tmp = NULL ; P_BP_HASH_TABLE_KEYED_ENTRY sub_table = NULL ; BP_ERROR_T data_destroy_status = ERR_FAILURE ; BP_ERROR_T table_destroy_status = ERR_FAILURE ; HASH_ITER ( hh , hreg -> hive , entry , tmp ) { data_destroy_status = ERR_FAILURE ; table_destroy_status = ERR_FAILURE ; if ( entry -> type == BP_HASH_TABLE_KEYED_ENTRY_TYPE_NAMED_HASH_TABLE ) { table_destroy_status = BP_HashRegDestroyTable_r ( hreg , entry ) ; if ( table_destroy_status == ERR_FAILURE ) { return ERR_FAILURE ; } } } return ERR_SUCCESS ; }
Attempts to destroy an entire hive table by table.
Attempts to destroy an entire hive table by table .
// macro to override hreg on null // ensure there is a hive to destroy // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Attempt to Recursively Lock Children %%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // temporary iterator values used during the HASH_ITER loop below // status for last data and table locks // iterate through all hashes and display // reset lock status on loop // It's either a data entry or a hash table.  If it's data, just lock it.  If it's a table, // check out the tables member elements. // recurse and destroy lower tables/data // exit if the destruction fails // printf("\n Ugh.  Failed to destroy: %s", entry->key); // NOTE: hive should be null at this point // if all tables were deleted ok, return indicating so