Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Hash_impl
changeset 34:049a8d8917c5 PR_univ
changed headers and PR_WL__malloc plus PR_int__malloc to PR__malloc & elim _WL versions
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Tue, 23 Jul 2013 07:38:54 -0700 |
| parents | 097d8ccb18b7 |
| children | dc1e44b0d702 14c289b351ff |
| files | PrivateHash.c PrivateHash.h |
| diffstat | 2 files changed, 37 insertions(+), 43 deletions(-) [+] |
line diff
1.1 --- a/PrivateHash.c Mon Jul 22 06:17:46 2013 -0700 1.2 +++ b/PrivateHash.c Tue Jul 23 07:38:54 2013 -0700 1.3 @@ -7,32 +7,16 @@ 1.4 */ 1.5 1.6 #include "PrivateHash.h" 1.7 - 1.8 +#include "PR__common_includes/Services_offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h" 1.9 1.10 HashTable * 1.11 makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn ) 1.12 { HashTable * retTable; 1.13 - retTable = PR_int__malloc( sizeof( HashTable ) ); 1.14 + retTable = PR__malloc( sizeof( HashTable ) ); 1.15 1.16 retTable->freeEntryContentFn = freeFn; 1.17 1.18 - retTable->entries = PR_int__malloc( numHashSlots * sizeof(HashEntry *) ); 1.19 - retTable->numEntries = 0; 1.20 - retTable->tableSz = numHashSlots; 1.21 - 1.22 - nullOutTablesArray( retTable ); 1.23 - 1.24 - return retTable; 1.25 - } 1.26 - 1.27 -HashTable * 1.28 -makeHashTable_WL( int numHashSlots, FreeEntryContentFnPtr freeFn ) 1.29 - { HashTable * retTable; 1.30 - retTable = PR_WL__malloc( sizeof( HashTable ) ); 1.31 - 1.32 - retTable->freeEntryContentFn = freeFn; 1.33 - 1.34 - retTable->entries = PR_int__malloc( numHashSlots * sizeof(HashEntry *) ); 1.35 + retTable->entries = PR__malloc( numHashSlots * sizeof(HashEntry *) ); 1.36 retTable->numEntries = 0; 1.37 retTable->tableSz = numHashSlots; 1.38 1.39 @@ -50,7 +34,7 @@ 1.40 oldEntries = table->entries; 1.41 1.42 newTableSz = 2 * oldTableSz; 1.43 - newEntries = PR_int__malloc( newTableSz * sizeof(HashEntry *) ); 1.44 + newEntries = PR__malloc( newTableSz * sizeof(HashEntry *) ); 1.45 1.46 table->tableSz = newTableSz; 1.47 table->entries = newEntries; 1.48 @@ -97,10 +81,10 @@ 1.49 1.50 int32 len = strlen(key); 1.51 1.52 - hashEntry = (HashEntry*) PR_int__malloc( sizeof( HashEntry ) ); 1.53 + hashEntry = (HashEntry*) PR__malloc( sizeof( HashEntry ) ); 1.54 if( hashEntry == NULL ) return NULL; 1.55 1.56 - hashEntry->key = PR_int__malloc( len + 1 ); 1.57 + hashEntry->key = PR__malloc( len + 1 ); 1.58 if( hashEntry->key == NULL ) return NULL; 1.59 memcpy( hashEntry->key, key, len + 1 ); 1.60 hashEntry->next = NULL; 1.61 @@ -262,8 +246,26 @@ 1.62 { 1.63 if( entry->content != NULL ) 1.64 (*(table->freeEntryContentFn))( entry->content ); 1.65 - PR_int__free( entry->key ); //was PR_int__malloc'd above, so free it 1.66 - PR_int__free( entry ); 1.67 + PR__free( entry->key ); //was PR__malloc'd above, so free it 1.68 + PR__free( entry ); 1.69 + } 1.70 + 1.71 +/* obsolete -- delete 1.72 + 1.73 +HashTable * 1.74 +makeHashTable_WL( int numHashSlots, FreeEntryContentFnPtr freeFn ) 1.75 + { HashTable * retTable; 1.76 + retTable = PR__malloc( sizeof( HashTable ) ); 1.77 + 1.78 + retTable->freeEntryContentFn = freeFn; 1.79 + 1.80 + retTable->entries = PR__malloc( numHashSlots * sizeof(HashEntry *) ); 1.81 + retTable->numEntries = 0; 1.82 + retTable->tableSz = numHashSlots; 1.83 + 1.84 + nullOutTablesArray( retTable ); 1.85 + 1.86 + return retTable; 1.87 } 1.88 1.89 void 1.90 @@ -271,10 +273,9 @@ 1.91 { 1.92 if( entry->content != NULL ) 1.93 (*(table->freeEntryContentFn))( entry->content ); 1.94 - PR_WL__free( entry->key ); //was PR_int__malloc'd above, so free it 1.95 - PR_WL__free( entry ); 1.96 + PR__free( entry->key ); //was PR__malloc'd above, so free it 1.97 + PR__free( entry ); 1.98 } 1.99 - 1.100 void 1.101 freeHashTable_WL( HashTable *table ) 1.102 { int i; 1.103 @@ -293,20 +294,13 @@ 1.104 } 1.105 } 1.106 } 1.107 - 1.108 +*/ 1.109 1.110 void 1.111 freeHashEntryButNotContent( HashEntry *entry ) 1.112 { 1.113 - PR_int__free( entry->key ); //was PR_int__malloc'd above, so free it 1.114 - PR_int__free( entry ); 1.115 - } 1.116 - 1.117 -void 1.118 -freeHashEntryButNotContent_WL( HashEntry *entry ) 1.119 - { 1.120 - PR_WL__free( entry->key ); //was PR_int__malloc'd above, so free it 1.121 - PR_WL__free( entry ); 1.122 + PR__free( entry->key ); //was PR__malloc'd above, so free it 1.123 + PR__free( entry ); 1.124 } 1.125 1.126 1.127 @@ -325,7 +319,7 @@ 1.128 { HashTable * retTable; 1.129 int32 numHashSlots; 1.130 1.131 - retTable = PR_int__malloc( sizeof( HashTable ) ); 1.132 + retTable = PR__malloc( sizeof( HashTable ) ); 1.133 1.134 numHashSlots = 1 << powerOf2OfSz; 1.135 retTable->hashMask = 0xffffffff >> 32 - powerOf2OfSz; 1.136 @@ -333,7 +327,7 @@ 1.137 1.138 retTable->freeEntryContentFn = freeFn; 1.139 1.140 - retTable->entries = PR_int__malloc( numHashSlots * sizeof(HashEntry *)); 1.141 + retTable->entries = PR__malloc( numHashSlots * sizeof(HashEntry *)); 1.142 retTable->numEntries = 0; 1.143 retTable->tableSz = numHashSlots; 1.144 1.145 @@ -352,9 +346,9 @@ 1.146 makeHashEntry32( uint32 * key ) 1.147 { HashEntry *hashEntry; 1.148 1.149 - hashEntry = (HashEntry*) PR_int__malloc( sizeof( HashEntry ) ); 1.150 + hashEntry = (HashEntry*) PR__malloc( sizeof( HashEntry ) ); 1.151 if( hashEntry == NULL ) return NULL; 1.152 - hashEntry->key = PR_int__malloc( sizeOfKey(key) ); 1.153 + hashEntry->key = PR__malloc( sizeOfKey(key) ); 1.154 if( hashEntry->key == NULL ) return NULL; 1.155 memcpy( hashEntry->key, key, sizeOfKey(key) ); 1.156 hashEntry->next = NULL; 1.157 @@ -400,7 +394,7 @@ 1.158 oldEntries = table->entries; 1.159 1.160 newTableSz = 2 * oldTableSz; 1.161 - newEntries = PR_int__malloc( newTableSz * sizeof(HashEntry *) ); 1.162 + newEntries = PR__malloc( newTableSz * sizeof(HashEntry *) ); 1.163 1.164 table->tableSz = newTableSz; 1.165 table->entries = newEntries;
2.1 --- a/PrivateHash.h Mon Jul 22 06:17:46 2013 -0700 2.2 +++ b/PrivateHash.h Tue Jul 23 07:38:54 2013 -0700 2.3 @@ -13,7 +13,7 @@ 2.4 #include <errno.h> 2.5 #include <stdlib.h> 2.6 2.7 -#include "PR__application_includes/PR__application.h" 2.8 +#include "PR__common_includes/PR__primitive_data_types.h" 2.9 2.10 //===================== defines ===================== 2.11 #define TRUE 1
