library/src/datastructures/BP-HashTable.cc
// These routines utilize a P_BP_HASH_TABLE_KEYED_ENTRY table as a
// first parameter rather than a hreg.  This allows for localized
// table lookups for hashes.  The second parameter is a key to
// use for the lookup.
These routines utilize a P_BP_HASH_TABLE_KEYED_ENTRY table as a
first parameter rather than a hreg.  This allows for localized
table lookups for hashes.  The second parameter is a key to
use for the lookup.
These routines utilize a P_BP_HASH_TABLE_KEYED_ENTRY table as a first parameter rather than a hreg . This allows for localized table lookups for hashes . The second parameter is a key to use for the lookup .
P_BP_HASH_TABLE_KEYED_ENTRY BP_HashRegLookupEntryFromHashKeyViaRelativePosition
(
		P_BP_HASH_TABLE_REGISTRY      hreg,
		P_BP_HASH_TABLE_KEYED_ENTRY relative_position,
		char *key
)
{
	BP_GLOBAL_HASH_TABLE_OVERRIDE(NULL);
	if(!relative_position)
		return NULL;
	if(relative_position->type != BP_HASH_TABLE_KEYED_ENTRY_TYPE_NAMED_HASH_TABLE)
		return NULL;
	if(!relative_position->data)
		return NULL;
	if(!key)
		return NULL;
	if(BP_StringIsReasonablePrintableString(key, bpstrlen(key), BP_FALSE, BP_FALSE) == ERR_FAILURE)
		return NULL;
	P_BP_HASH_TABLE_KEYED_ENTRY entries = (P_BP_HASH_TABLE_KEYED_ENTRY) relative_position->data;
	P_BP_HASH_TABLE_KEYED_ENTRY found_entry = NULL;
	HASH_FIND
	(
		hh,
		entries,
		key,
		bpstrlen(key),
		found_entry
	);
	if(found_entry)
	{
		if(!BP_HashRegMemPtrValid(hreg, found_entry))
		{
			printf("\n Exiting because found entry was bad?");
			return NULL;
		}
		if(found_entry->data)
		{
			if(!BP_HashRegMemPtrValid(hreg, found_entry->data))
			{
				printf("\n Exiting because found DATA was bad?: %p", found_entry->data);
				return NULL;
			}
		}
	}
	if(found_entry)
		return found_entry;
	return NULL;
}
P_BP_HASH_TABLE_KEYED_ENTRY BP_HashRegLookupEntryFromHashKeyViaRelativePosition ( P_BP_HASH_TABLE_REGISTRY hreg , P_BP_HASH_TABLE_KEYED_ENTRY relative_position , char * key ) { BP_GLOBAL_HASH_TABLE_OVERRIDE ( NULL ) ; if ( ! relative_position ) return NULL ; if ( relative_position -> type != BP_HASH_TABLE_KEYED_ENTRY_TYPE_NAMED_HASH_TABLE ) return NULL ; if ( ! relative_position -> data ) return NULL ; if ( ! key ) return NULL ; if ( BP_StringIsReasonablePrintableString ( key , bpstrlen ( key ) , BP_FALSE , BP_FALSE ) == ERR_FAILURE ) return NULL ; P_BP_HASH_TABLE_KEYED_ENTRY entries = ( P_BP_HASH_TABLE_KEYED_ENTRY ) relative_position -> data ; P_BP_HASH_TABLE_KEYED_ENTRY found_entry = NULL ; HASH_FIND ( hh , entries , key , bpstrlen ( key ) , found_entry ) ; if ( found_entry ) { if ( ! BP_HashRegMemPtrValid ( hreg , found_entry ) ) { printf ( " \n " ) ; return NULL ; } if ( found_entry -> data ) { if ( ! BP_HashRegMemPtrValid ( hreg , found_entry -> data ) ) { printf ( " \n " , found_entry -> data ) ; return NULL ; } } } if ( found_entry ) return found_entry ; return NULL ; }
These routines utilize a P_BP_HASH_TABLE_KEYED_ENTRY table as a
first parameter rather than a hreg.
These routines utilize a P_BP_HASH_TABLE_KEYED_ENTRY table as a first parameter rather than a hreg .
// macro to override hreg on null // ensure we have a relative position // ensure the position is a table // ensure we have data to search through // ensure we have a key // ensure string is reasonable/printable ascii // set entries // stores the found lookup // attempt to lookup the table // Run final validation checks. // first ensure that the entry itself is valid // now, if there is data, make sure the data is valid // if we have an entry, return it immediately // return NULL if can't be found