| 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
|
|
hausers@12
|
11 #include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h"
|
|
Me@0
|
12
|
|
Me@0
|
13 #define TRUE 1
|
|
Me@0
|
14 #define FALSE 0
|
|
Me@0
|
15
|
|
msach@9
|
16 union hashkey_t{
|
|
msach@9
|
17 char hashable[8];
|
|
msach@9
|
18 int parts[2];
|
|
msach@9
|
19 };
|
|
msach@9
|
20
|
|
msach@9
|
21 typedef union hashkey_t hashkey_t;
|
|
Me@0
|
22
|
|
Me@1
|
23 #define DEFAULT_HASHSIZE 1 << 10
|
|
Me@0
|
24
|
|
Me@0
|
25 typedef struct _HashEntry HashEntry;
|
|
Me@0
|
26
|
|
Me@0
|
27 struct _HashEntry
|
|
Me@0
|
28 {
|
|
Me@0
|
29 char *key;
|
|
Me@0
|
30 void *content;
|
|
Me@0
|
31 HashEntry *next;
|
|
Me@0
|
32 };
|
|
Me@0
|
33
|
|
Me@0
|
34 typedef void (*FreeEntryContentFnPtr) ( void * );
|
|
Me@0
|
35
|
|
Me@0
|
36 typedef struct
|
|
Me@0
|
37 { int tableSz;
|
|
Me@0
|
38 int numEntries;
|
|
Me@0
|
39 HashEntry* *entries;
|
|
Me@0
|
40 FreeEntryContentFnPtr freeEntryContentFn;
|
|
Me@0
|
41 }
|
|
Me@0
|
42 HashTable;
|
|
Me@0
|
43
|
|
Me@0
|
44
|
|
Me@0
|
45 //===========================================================================
|
|
Me@0
|
46 // Public functions
|
|
Me@0
|
47 HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
|
|
Me@0
|
48
|
|
Me@1
|
49 int putEntryIntoTable( HashEntry *entry, HashTable *table);
|
|
Me@1
|
50 int addValueIntoTable( char* key, void *value, HashTable *table);
|
|
Me@1
|
51 HashEntry *getEntryFromTable( char *key, HashTable *table );
|
|
Me@0
|
52 void *getValueFromTable( char *key, HashTable *table );
|
|
Me@1
|
53
|
|
Me@0
|
54 bool8 deleteEntryFromTable( char *key, HashTable *table );
|
|
Me@1
|
55 bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table );
|
|
Me@0
|
56 bool8 deleteEntrysValueInTable( char *key, HashTable *table );
|
|
Me@1
|
57 bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table );
|
|
Me@1
|
58 void freeHashTable( HashTable *table );
|
|
Me@1
|
59 //char *paramBagToString( ParamBag * bag )
|
|
Me@0
|
60
|
|
Me@1
|
61 //===========================================================================
|
|
Me@1
|
62 // Internal functions
|
|
Me@1
|
63 void freeHashEntryUsing( HashEntry *entry, HashTable *table );
|
|
Me@1
|
64 unsigned int hashThisKey( char *s, int hashSz );
|
|
Me@1
|
65 void nullOutTablesArray( HashTable *table );
|
|
Me@1
|
66 void doubleTableSize( HashTable *table );
|
|
Me@1
|
67 void freeHashEntryButNotContent( HashEntry *entry );
|
|
Me@0
|
68
|
|
Me@0
|
69 #endif /* _PRIVATE_HASH_H */
|
|
Me@0
|
70
|