Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Hash_impl
diff 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 diff
1.1 --- a/PrivateHash.h Thu Feb 09 15:51:22 2012 +0100 1.2 +++ b/PrivateHash.h Sat Feb 11 17:55:51 2012 -0800 1.3 @@ -1,70 +1,76 @@ 1.4 -/* 1.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 1.6 - * Licensed under GNU General Public License version 2 1.7 - * 1.8 - * Author: seanhalle@yahoo.com 1.9 - */ 1.10 - 1.11 -#ifndef _PRIVATE_HASH_H 1.12 -#define _PRIVATE_HASH_H 1.13 - 1.14 -#include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h" 1.15 - 1.16 -#define TRUE 1 1.17 -#define FALSE 0 1.18 - 1.19 -union hashkey_t{ 1.20 - char hashable[8]; 1.21 - int parts[2]; 1.22 -}; 1.23 - 1.24 -typedef union hashkey_t hashkey_t; 1.25 - 1.26 -#define DEFAULT_HASHSIZE 1 << 10 1.27 - 1.28 -typedef struct _HashEntry HashEntry; 1.29 - 1.30 -struct _HashEntry 1.31 - { 1.32 - char *key; 1.33 - void *content; 1.34 - HashEntry *next; 1.35 - }; 1.36 - 1.37 -typedef void (*FreeEntryContentFnPtr) ( void * ); 1.38 - 1.39 -typedef struct 1.40 - { int tableSz; 1.41 - int numEntries; 1.42 - HashEntry* *entries; 1.43 - FreeEntryContentFnPtr freeEntryContentFn; 1.44 - } 1.45 -HashTable; 1.46 - 1.47 - 1.48 -//=========================================================================== 1.49 -// Public functions 1.50 -HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn ); 1.51 - 1.52 -int putEntryIntoTable( HashEntry *entry, HashTable *table); 1.53 -int addValueIntoTable( char* key, void *value, HashTable *table); 1.54 -HashEntry *getEntryFromTable( char *key, HashTable *table ); 1.55 -void *getValueFromTable( char *key, HashTable *table ); 1.56 - 1.57 -bool8 deleteEntryFromTable( char *key, HashTable *table ); 1.58 -bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table ); 1.59 -bool8 deleteEntrysValueInTable( char *key, HashTable *table ); 1.60 -bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table ); 1.61 -void freeHashTable( HashTable *table ); 1.62 -//char *paramBagToString( ParamBag * bag ) 1.63 - 1.64 -//=========================================================================== 1.65 -// Internal functions 1.66 -void freeHashEntryUsing( HashEntry *entry, HashTable *table ); 1.67 -unsigned int hashThisKey( char *s, int hashSz ); 1.68 -void nullOutTablesArray( HashTable *table ); 1.69 -void doubleTableSize( HashTable *table ); 1.70 -void freeHashEntryButNotContent( HashEntry *entry ); 1.71 - 1.72 -#endif /* _PRIVATE_HASH_H */ 1.73 - 1.74 +/* 1.75 + * Copyright 2009 OpenSourceStewardshipFoundation.org 1.76 + * Licensed under GNU General Public License version 2 1.77 + * 1.78 + * Author: seanhalle@yahoo.com 1.79 + */ 1.80 + 1.81 +#ifndef _PRIVATE_HASH_H 1.82 +#define _PRIVATE_HASH_H 1.83 + 1.84 +#include <stdio.h> 1.85 +#include <string.h> 1.86 +#include <errno.h> 1.87 +#include <stdlib.h> 1.88 + 1.89 +#include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h" 1.90 +#include "../../VMS_Implementations/VMS_impl/vmalloc.h" 1.91 + 1.92 +#define TRUE 1 1.93 +#define FALSE 0 1.94 + 1.95 +union hashkey_t{ 1.96 + char hashable[8]; 1.97 + int parts[2]; 1.98 +}; 1.99 + 1.100 +typedef union hashkey_t hashkey_t; 1.101 + 1.102 +#define DEFAULT_HASHSIZE 1 << 10 1.103 + 1.104 +typedef struct _HashEntry HashEntry; 1.105 + 1.106 +struct _HashEntry 1.107 + { 1.108 + char *key; 1.109 + void *content; 1.110 + HashEntry *next; 1.111 + }; 1.112 + 1.113 +typedef void (*FreeEntryContentFnPtr) ( void * ); 1.114 + 1.115 +typedef struct 1.116 + { int tableSz; 1.117 + int numEntries; 1.118 + HashEntry* *entries; 1.119 + FreeEntryContentFnPtr freeEntryContentFn; 1.120 + } 1.121 +HashTable; 1.122 + 1.123 + 1.124 +//=========================================================================== 1.125 +// Public functions 1.126 +HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn ); 1.127 + 1.128 +int putEntryIntoTable( HashEntry *entry, HashTable *table); 1.129 +int addValueIntoTable( char* key, void *value, HashTable *table); 1.130 +HashEntry *getEntryFromTable( char *key, HashTable *table ); 1.131 +void *getValueFromTable( char *key, HashTable *table ); 1.132 + 1.133 +bool8 deleteEntryFromTable( char *key, HashTable *table ); 1.134 +bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table ); 1.135 +bool8 deleteEntrysValueInTable( char *key, HashTable *table ); 1.136 +bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table ); 1.137 +void freeHashTable( HashTable *table ); 1.138 +//char *paramBagToString( ParamBag * bag ) 1.139 + 1.140 +//=========================================================================== 1.141 +// Internal functions 1.142 +void freeHashEntryUsing( HashEntry *entry, HashTable *table ); 1.143 +unsigned int hashThisKey( char *s, int hashSz ); 1.144 +void nullOutTablesArray( HashTable *table ); 1.145 +void doubleTableSize( HashTable *table ); 1.146 +void freeHashEntryButNotContent( HashEntry *entry ); 1.147 + 1.148 +#endif /* _PRIVATE_HASH_H */ 1.149 +
