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