view PrivateHash.h @ 15:093cad17d992

Removed VMS__malloc and free, added .brch__default (expls why removed)
author Me@portablequad
date Sat, 11 Feb 2012 18:00:56 -0800
parents 40ec8f9583d8
children
line source
1 /*
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
3 * Licensed under GNU General Public License version 2
4 *
5 * Author: seanhalle@yahoo.com
6 */
8 #ifndef _PRIVATE_HASH_H
9 #define _PRIVATE_HASH_H
12 #include <stdio.h>
13 #include <string.h>
14 #include <errno.h>
15 #include <stdlib.h>
17 #define TRUE 1
18 #define FALSE 0
20 union hashkey_t{
21 char hashable[8];
22 int parts[2];
23 };
25 typedef union hashkey_t hashkey_t;
27 #define DEFAULT_HASHSIZE 1 << 10
29 typedef struct _HashEntry HashEntry;
31 struct _HashEntry
32 {
33 char *key;
34 void *content;
35 HashEntry *next;
36 };
38 typedef void (*FreeEntryContentFnPtr) ( void * );
40 typedef struct
41 { int tableSz;
42 int numEntries;
43 HashEntry* *entries;
44 FreeEntryContentFnPtr freeEntryContentFn;
45 }
46 HashTable;
49 //===========================================================================
50 // Public functions
51 HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
53 int putEntryIntoTable( HashEntry *entry, HashTable *table);
54 int addValueIntoTable( char* key, void *value, HashTable *table);
55 HashEntry *getEntryFromTable( char *key, HashTable *table );
56 void *getValueFromTable( char *key, HashTable *table );
58 bool8 deleteEntryFromTable( char *key, HashTable *table );
59 bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table );
60 bool8 deleteEntrysValueInTable( char *key, HashTable *table );
61 bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table );
62 void freeHashTable( HashTable *table );
63 //char *paramBagToString( ParamBag * bag )
65 //===========================================================================
66 // Internal functions
67 void freeHashEntryUsing( HashEntry *entry, HashTable *table );
68 unsigned int hashThisKey( char *s, int hashSz );
69 void nullOutTablesArray( HashTable *table );
70 void doubleTableSize( HashTable *table );
71 void freeHashEntryButNotContent( HashEntry *entry );
73 #endif /* _PRIVATE_HASH_H */