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