| rev |
line source |
|
Me@0
|
1 /*
|
|
Me@0
|
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
|
|
Me@0
|
3 * Licensed under GNU General Public License version 2
|
|
Me@0
|
4 *
|
|
Me@0
|
5 * Author: seanhalle@yahoo.com
|
|
Me@0
|
6 */
|
|
Me@0
|
7
|
|
Me@0
|
8 #ifndef _PRIVATE_HASH_H
|
|
Me@0
|
9 #define _PRIVATE_HASH_H
|
|
Me@0
|
10
|
|
Me@1
|
11 #include "../VMS_primitive_data_types.h"
|
|
Me@0
|
12
|
|
Me@0
|
13 #define TRUE 1
|
|
Me@0
|
14 #define FALSE 0
|
|
Me@0
|
15
|
|
Me@0
|
16
|
|
Me@1
|
17 #define DEFAULT_HASHSIZE 1 << 10
|
|
Me@0
|
18
|
|
Me@0
|
19 typedef struct _HashEntry HashEntry;
|
|
Me@0
|
20
|
|
Me@0
|
21 struct _HashEntry
|
|
Me@0
|
22 {
|
|
Me@0
|
23 char *key;
|
|
Me@0
|
24 void *content;
|
|
Me@0
|
25 HashEntry *next;
|
|
Me@0
|
26 };
|
|
Me@0
|
27
|
|
Me@0
|
28 typedef void (*FreeEntryContentFnPtr) ( void * );
|
|
Me@0
|
29
|
|
Me@0
|
30 typedef struct
|
|
Me@0
|
31 { int tableSz;
|
|
Me@0
|
32 int numEntries;
|
|
Me@0
|
33 HashEntry* *entries;
|
|
Me@0
|
34 FreeEntryContentFnPtr freeEntryContentFn;
|
|
Me@0
|
35 }
|
|
Me@0
|
36 HashTable;
|
|
Me@0
|
37
|
|
Me@0
|
38
|
|
Me@0
|
39 //===========================================================================
|
|
Me@0
|
40 // Public functions
|
|
Me@0
|
41 HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
|
|
Me@0
|
42
|
|
Me@1
|
43 int putEntryIntoTable( HashEntry *entry, HashTable *table);
|
|
Me@1
|
44 int addValueIntoTable( char* key, void *value, HashTable *table);
|
|
Me@1
|
45 HashEntry *getEntryFromTable( char *key, HashTable *table );
|
|
Me@0
|
46 void *getValueFromTable( char *key, HashTable *table );
|
|
Me@1
|
47
|
|
Me@0
|
48 bool8 deleteEntryFromTable( char *key, HashTable *table );
|
|
Me@1
|
49 bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table );
|
|
Me@0
|
50 bool8 deleteEntrysValueInTable( char *key, HashTable *table );
|
|
Me@1
|
51 bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table );
|
|
Me@1
|
52 void freeHashTable( HashTable *table );
|
|
Me@1
|
53 //char *paramBagToString( ParamBag * bag )
|
|
Me@0
|
54
|
|
Me@1
|
55 //===========================================================================
|
|
Me@1
|
56 // Internal functions
|
|
Me@1
|
57 void freeHashEntryUsing( HashEntry *entry, HashTable *table );
|
|
Me@1
|
58 unsigned int hashThisKey( char *s, int hashSz );
|
|
Me@1
|
59 void nullOutTablesArray( HashTable *table );
|
|
Me@1
|
60 void doubleTableSize( HashTable *table );
|
|
Me@1
|
61 void freeHashEntryButNotContent( HashEntry *entry );
|
|
Me@0
|
62
|
|
Me@0
|
63 #endif /* _PRIVATE_HASH_H */
|
|
Me@0
|
64
|