library/src/datastructures/BP-HashTable.cc
// Will search a traversal path and return an ENTRY based on a path query.
Will search a traversal path and return an ENTRY based on a path query.
Will search a traversal path and return an ENTRY based on a path query .
P_BP_HASH_TABLE_KEYED_ENTRY BP_HashRegLookupTableEntryByDataKeyIndexAndTablePathQuery
(
	P_BP_HASH_TABLE_REGISTRY      hreg,
	char *                        table_path_lookup_query,
	char *                        data_index_key
)
{
	if(!table_path_lookup_query)
		return NULL;
	if(!data_index_key)
		return NULL;
	if(!BP_StringIsReasonablePrintableString(table_path_lookup_query, bpstrlen(table_path_lookup_query), BP_FALSE, BP_FALSE))
		return NULL;
	if(!BP_StringIsReasonablePrintableString(data_index_key, bpstrlen(data_index_key), 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;
	}
	size_t ptr_array_size = BP_CountNullTerminatedPtrArray(path_lookup_array);
	path_lookup_array = (char **) bprealloc
	(
			path_lookup_array,
			sizeof(char *) * (ptr_array_size+2)
	);
	path_lookup_array[ptr_array_size]   = bpstrdup(data_index_key);
	path_lookup_array[ptr_array_size+1] = NULL;
	P_BP_HASH_TABLE_KEYED_ENTRY lookup_entry = BP_HashRegLookupTableEntryByPath(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_HashRegLookupTableEntryByDataKeyIndexAndTablePathQuery ( P_BP_HASH_TABLE_REGISTRY hreg , char * table_path_lookup_query , char * data_index_key ) { if ( ! table_path_lookup_query ) return NULL ; if ( ! data_index_key ) return NULL ; if ( ! BP_StringIsReasonablePrintableString ( table_path_lookup_query , bpstrlen ( table_path_lookup_query ) , BP_FALSE , BP_FALSE ) ) return NULL ; if ( ! BP_StringIsReasonablePrintableString ( data_index_key , bpstrlen ( data_index_key ) , 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 ; } size_t ptr_array_size = BP_CountNullTerminatedPtrArray ( path_lookup_array ) ; path_lookup_array = ( char * * ) bprealloc ( path_lookup_array , sizeof ( char * ) * ( ptr_array_size + 2 ) ) ; path_lookup_array [ ptr_array_size ] = bpstrdup ( data_index_key ) ; path_lookup_array [ ptr_array_size + 1 ] = NULL ; P_BP_HASH_TABLE_KEYED_ENTRY lookup_entry = BP_HashRegLookupTableEntryByPath ( 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 search a traversal path and return an ENTRY based on a path query.
Will search a traversal path and return an ENTRY based on a path query .
// basic null checks // run basic sanity checks // create path array from lookup query // check to ensure we've created a lookup array // ensure we have a first element // count the pointer array // since it's bpcalloced, it can be bprealloced here without issue to add an extra parameter // append data index and add key // gather lookup query // destroy the path lookup array entries // destroy array structure // return the looked up entry