view PrivateHash.h @ 14:5b89d57e5d10

added .brch__VMS__malloc_brch which has purpose of the brch
author Me@portablequad
date Sat, 11 Feb 2012 17:55:51 -0800
parents 40ec8f9583d8
children 4b5abed39ab9
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
11 #include <stdio.h>
12 #include <string.h>
13 #include <errno.h>
14 #include <stdlib.h>
16 #include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h"
17 #include "../../VMS_Implementations/VMS_impl/vmalloc.h"
19 #define TRUE 1
20 #define FALSE 0
22 union hashkey_t{
23 char hashable[8];
24 int parts[2];
25 };
27 typedef union hashkey_t hashkey_t;
29 #define DEFAULT_HASHSIZE 1 << 10
31 typedef struct _HashEntry HashEntry;
33 struct _HashEntry
34 {
35 char *key;
36 void *content;
37 HashEntry *next;
38 };
40 typedef void (*FreeEntryContentFnPtr) ( void * );
42 typedef struct
43 { int tableSz;
44 int numEntries;
45 HashEntry* *entries;
46 FreeEntryContentFnPtr freeEntryContentFn;
47 }
48 HashTable;
51 //===========================================================================
52 // Public functions
53 HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
55 int putEntryIntoTable( HashEntry *entry, HashTable *table);
56 int addValueIntoTable( char* key, void *value, HashTable *table);
57 HashEntry *getEntryFromTable( char *key, HashTable *table );
58 void *getValueFromTable( char *key, HashTable *table );
60 bool8 deleteEntryFromTable( char *key, HashTable *table );
61 bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table );
62 bool8 deleteEntrysValueInTable( char *key, HashTable *table );
63 bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table );
64 void freeHashTable( HashTable *table );
65 //char *paramBagToString( ParamBag * bag )
67 //===========================================================================
68 // Internal functions
69 void freeHashEntryUsing( HashEntry *entry, HashTable *table );
70 unsigned int hashThisKey( char *s, int hashSz );
71 void nullOutTablesArray( HashTable *table );
72 void doubleTableSize( HashTable *table );
73 void freeHashEntryButNotContent( HashEntry *entry );
75 #endif /* _PRIVATE_HASH_H */