annotate PrivateHash.h @ 24:b032601956bb

Works -- with send-receive plus normal dependencies
author Sean Halle <seanhalle@yahoo.com>
date Thu, 14 Jun 2012 18:44:46 -0700
parents f5972b1ddb29
children 18ec64d06e35 bd376656f8ab
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
seanhalle@23 19 //===================== defines =====================
Me@14 20 #define TRUE 1
Me@14 21 #define FALSE 0
Me@14 22
seanhalle@23 23 #define DEFAULT_HASH_TABLE_SIZE 1 << 10
seanhalle@23 24 #define DEFAULT_POWER_OF_2_TABLE_SIZE 10
seanhalle@23 25
seanhalle@23 26
seanhalle@23 27 //===================== structs =====================
Me@14 28 union hashkey_t{
Me@14 29 char hashable[8];
Me@14 30 int parts[2];
Me@14 31 };
Me@14 32
Me@14 33 typedef union hashkey_t hashkey_t;
Me@14 34
Me@14 35 typedef struct _HashEntry HashEntry;
Me@14 36
Me@14 37 struct _HashEntry
Me@14 38 {
Me@14 39 char *key;
Me@14 40 void *content;
Me@14 41 HashEntry *next;
Me@14 42 };
Me@14 43
Me@14 44 typedef void (*FreeEntryContentFnPtr) ( void * );
Me@14 45
Me@14 46 typedef struct
seanhalle@23 47 { int tableSz;
seanhalle@23 48 int numEntries;
Me@14 49 HashEntry* *entries;
seanhalle@23 50 int32 hashMask;
seanhalle@23 51 int32 prevHash;
Me@14 52 FreeEntryContentFnPtr freeEntryContentFn;
Me@14 53 }
Me@14 54 HashTable;
Me@14 55
Me@14 56
Me@14 57 //===========================================================================
Me@14 58 // Public functions
Me@14 59 HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
Me@14 60
Me@14 61 int putEntryIntoTable( HashEntry *entry, HashTable *table);
Me@14 62 int addValueIntoTable( char* key, void *value, HashTable *table);
Me@14 63 HashEntry *getEntryFromTable( char *key, HashTable *table );
Me@14 64 void *getValueFromTable( char *key, HashTable *table );
Me@14 65
Me@14 66 bool8 deleteEntryFromTable( char *key, HashTable *table );
Me@14 67 bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table );
Me@14 68 bool8 deleteEntrysValueInTable( char *key, HashTable *table );
Me@14 69 bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table );
Me@14 70 void freeHashTable( HashTable *table );
Me@14 71 //char *paramBagToString( ParamBag * bag )
Me@14 72
seanhalle@23 73 //================= Same Fns, but for 32b array key hash fn ================
seanhalle@23 74 HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn);
seanhalle@23 75 HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn );
seanhalle@23 76
seanhalle@23 77 int putEntryIntoTable32( HashEntry *entry, HashTable *table);
seanhalle@23 78 HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table);
seanhalle@23 79 HashEntry *getEntryFromTable32( uint32 key[], HashTable *table );
seanhalle@23 80 void *getValueFromTable32( uint32 key[], HashTable *table );
seanhalle@23 81
seanhalle@23 82 bool32 deleteEntryFromTable32( uint32 key[], HashTable *table );
seanhalle@23 83
Me@14 84 //===========================================================================
Me@14 85 // Internal functions
Me@14 86 void freeHashEntryUsing( HashEntry *entry, HashTable *table );
Me@14 87 unsigned int hashThisKey( char *s, int hashSz );
Me@14 88 void nullOutTablesArray( HashTable *table );
Me@14 89 void doubleTableSize( HashTable *table );
Me@14 90 void freeHashEntryButNotContent( HashEntry *entry );
Me@14 91
seanhalle@23 92 uint32
seanhalle@23 93 jenkHash32( const uint32 *key, /* array of uint32 values */
seanhalle@23 94 int32 length); /* num uint32 in the key */
seanhalle@23 95
Me@14 96 #endif /* _PRIVATE_HASH_H */
Me@14 97