library/src/datastructures/BP-HashTable.cc
// Will attempt to lookup a hash table entry with a char * representation
// of a hash lookup (eg. "/table_1/table_2".  This is mostly for convienence
// as this funciton simply parses the lookup query and calls BP_HashRegLookupTableByPath.
Will attempt to lookup a hash table entry with a char * representation
of a hash lookup (eg.
Will attempt to lookup a hash table entry with a char * representation of a hash lookup ( eg .
P_BP_HASH_TABLE_KEYED_ENTRY BP_HashRegLookupTableByPathQuery
(
	P_BP_HASH_TABLE_REGISTRY      hreg,
	char *                        table_path_lookup_query
)
{
	if(!table_path_lookup_query)
		return NULL;
	if(!BP_StringIsReasonablePrintableString(table_path_lookup_query, bpstrlen(table_path_lookup_query), BP_FALSE, BP_FALSE))
		return NULL;
	char ** path_lookup_array = BP_HashRegStringLookupToPathArray(table_path_lookup_query, bpstrlen(table_path_lookup_query));
	if(!path_lookup_array)
		return NULL;
	if(!path_lookup_array[0])
	{
		bpfree(path_lookup_array);
		return NULL;
	}
	P_BP_HASH_TABLE_KEYED_ENTRY lookup_entry = BP_HashRegLookupTableByPath(hreg, path_lookup_array);
	if(!lookup_entry)
	{
		BP_DestroyPointerArrayNullTerminated((void **) path_lookup_array);
		bpfree(path_lookup_array);
		return NULL;
	}
	BP_DestroyPointerArrayNullTerminated((void **) path_lookup_array);
	bpfree(path_lookup_array);
	return lookup_entry;
}
P_BP_HASH_TABLE_KEYED_ENTRY BP_HashRegLookupTableByPathQuery ( P_BP_HASH_TABLE_REGISTRY hreg , char * table_path_lookup_query ) { if ( ! table_path_lookup_query ) return NULL ; if ( ! BP_StringIsReasonablePrintableString ( table_path_lookup_query , bpstrlen ( table_path_lookup_query ) , BP_FALSE , BP_FALSE ) ) return NULL ; char * * path_lookup_array = BP_HashRegStringLookupToPathArray ( table_path_lookup_query , bpstrlen ( table_path_lookup_query ) ) ; if ( ! path_lookup_array ) return NULL ; if ( ! path_lookup_array [ 0 ] ) { bpfree ( path_lookup_array ) ; return NULL ; } P_BP_HASH_TABLE_KEYED_ENTRY lookup_entry = BP_HashRegLookupTableByPath ( hreg , path_lookup_array ) ; if ( ! lookup_entry ) { BP_DestroyPointerArrayNullTerminated ( ( void * * ) path_lookup_array ) ; bpfree ( path_lookup_array ) ; return NULL ; } BP_DestroyPointerArrayNullTerminated ( ( void * * ) path_lookup_array ) ; bpfree ( path_lookup_array ) ; return lookup_entry ; }
Will attempt to lookup a hash table entry with a char * representation
of a hash lookup (eg.
Will attempt to lookup a hash table entry with a char * representation of a hash lookup ( eg .
// do not do hreg check here, it is done via macro in the function which is called below // ensure we have a lookup query set // ensure lookup query is reasonable/printable string // create path array from lookup query // check to ensure we've created a lookup array // ensure we have a first element // gather lookup query // destroy the path lookup array entries // destroy array structure // return the lookup entry