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