Me@14: /* Me@14: * Copyright 2009 OpenSourceStewardshipFoundation.org Me@14: * Licensed under GNU General Public License version 2 Me@14: * Me@14: * Author: seanhalle@yahoo.com Me@14: */ Me@14: Me@14: #ifndef _PRIVATE_HASH_H Me@14: #define _PRIVATE_HASH_H Me@14: Me@14: #include Me@14: #include Me@14: #include Me@14: #include Me@14: Me@14: #include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h" Me@14: #include "../../VMS_Implementations/VMS_impl/vmalloc.h" Me@14: Me@14: #define TRUE 1 Me@14: #define FALSE 0 Me@14: Me@14: union hashkey_t{ Me@14: char hashable[8]; Me@14: int parts[2]; Me@14: }; Me@14: Me@14: typedef union hashkey_t hashkey_t; Me@14: Me@14: #define DEFAULT_HASHSIZE 1 << 10 Me@14: Me@14: typedef struct _HashEntry HashEntry; Me@14: Me@14: struct _HashEntry Me@14: { Me@14: char *key; Me@14: void *content; Me@14: HashEntry *next; Me@14: }; Me@14: Me@14: typedef void (*FreeEntryContentFnPtr) ( void * ); Me@14: Me@14: typedef struct Me@14: { int tableSz; Me@14: int numEntries; Me@14: HashEntry* *entries; Me@14: FreeEntryContentFnPtr freeEntryContentFn; Me@14: } Me@14: HashTable; Me@14: Me@14: Me@14: //=========================================================================== Me@14: // Public functions Me@14: HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn ); Me@14: Me@14: int putEntryIntoTable( HashEntry *entry, HashTable *table); Me@14: int addValueIntoTable( char* key, void *value, HashTable *table); Me@14: HashEntry *getEntryFromTable( char *key, HashTable *table ); Me@14: void *getValueFromTable( char *key, HashTable *table ); Me@14: Me@14: bool8 deleteEntryFromTable( char *key, HashTable *table ); Me@14: bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table ); Me@14: bool8 deleteEntrysValueInTable( char *key, HashTable *table ); Me@14: bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table ); Me@14: void freeHashTable( HashTable *table ); Me@14: //char *paramBagToString( ParamBag * bag ) Me@14: Me@14: //=========================================================================== Me@14: // Internal functions Me@14: void freeHashEntryUsing( HashEntry *entry, HashTable *table ); Me@14: unsigned int hashThisKey( char *s, int hashSz ); Me@14: void nullOutTablesArray( HashTable *table ); Me@14: void doubleTableSize( HashTable *table ); Me@14: void freeHashEntryButNotContent( HashEntry *entry ); Me@14: Me@14: #endif /* _PRIVATE_HASH_H */ Me@14: