library/src/datastructures/BP-HashTable.cc
// Add a table to the registry by a provided path.
Add a table to the registry by a provided path.
Add a table to the registry by a provided path .
BP_ERROR_T BP_HashRegAddTable
(
	P_BP_HASH_TABLE_REGISTRY hreg,
	P_BP_HASH_TABLE_KEYED_ENTRY table_to_append_to,
	P_BP_HASH_TABLE_KEYED_ENTRY new_table_entry
)
{
	BP_GLOBAL_HASH_TABLE_OVERRIDE(ERR_FAILURE);
	if(!new_table_entry)
		return ERR_FAILURE;
	if(!new_table_entry->key)
		return ERR_FAILURE;
	if(!table_to_append_to)
	{
		HASH_ADD_KEYPTR
		(
			hh,
			hreg->hive,
			new_table_entry->key,
			bpstrlen(new_table_entry->key),
			new_table_entry
		);
	}
	else
	{
		P_BP_HASH_TABLE_KEYED_ENTRY table_to_append_to_data = (P_BP_HASH_TABLE_KEYED_ENTRY) table_to_append_to->data;
		HASH_ADD_KEYPTR
		(
			hh,
			table_to_append_to_data,
			new_table_entry->key,
			bpstrlen(new_table_entry->key),
			new_table_entry
		);
		table_to_append_to->data = (void *) table_to_append_to_data;
	}
	hreg->total_tables_in_hive++;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_HashRegAddTable ( P_BP_HASH_TABLE_REGISTRY hreg , P_BP_HASH_TABLE_KEYED_ENTRY table_to_append_to , P_BP_HASH_TABLE_KEYED_ENTRY new_table_entry ) { BP_GLOBAL_HASH_TABLE_OVERRIDE ( ERR_FAILURE ) ; if ( ! new_table_entry ) return ERR_FAILURE ; if ( ! new_table_entry -> key ) return ERR_FAILURE ; if ( ! table_to_append_to ) { HASH_ADD_KEYPTR ( hh , hreg -> hive , new_table_entry -> key , bpstrlen ( new_table_entry -> key ) , new_table_entry ) ; } else { P_BP_HASH_TABLE_KEYED_ENTRY table_to_append_to_data = ( P_BP_HASH_TABLE_KEYED_ENTRY ) table_to_append_to -> data ; HASH_ADD_KEYPTR ( hh , table_to_append_to_data , new_table_entry -> key , bpstrlen ( new_table_entry -> key ) , new_table_entry ) ; table_to_append_to -> data = ( void * ) table_to_append_to_data ; } hreg -> total_tables_in_hive ++ ; return ERR_SUCCESS ; }
Add a table to the registry by a provided path.
Add a table to the registry by a provided path .
// handle the key // printf("\n WatWa12: %p - %p", new_table_entry, table_to_append_to); // macro to override hreg on null // if there is no append table, //if(!table_to_append_to) //	table_to_append_to = hreg->hive; // ensure we have a new table entry // ensure the addition is a key type // if there is no table to append to, we're using the hive (and it's empty), so go ahead and // use the direct hive pointer here. // add to the main hive if there is nothing to append to // Note: No data reset needs to occur because we're using hreg->hive directly here. // set the data pointer so data can be appended // add to the table // reset data pointer to reflect current situation // increase the total number of tables in the hive // return indicating success