# HG changeset patch # User Sean Halle # Date 1374590334 25200 # Node ID 049a8d8917c5cd08d5640813c9f414f001cc8765 # Parent 097d8ccb18b7c9f902b11e2dbfda8154772d0839 changed headers and PR_WL__malloc plus PR_int__malloc to PR__malloc & elim _WL versions diff -r 097d8ccb18b7 -r 049a8d8917c5 PrivateHash.c --- a/PrivateHash.c Mon Jul 22 06:17:46 2013 -0700 +++ b/PrivateHash.c Tue Jul 23 07:38:54 2013 -0700 @@ -7,32 +7,16 @@ */ #include "PrivateHash.h" - +#include "PR__common_includes/Services_offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h" HashTable * makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn ) { HashTable * retTable; - retTable = PR_int__malloc( sizeof( HashTable ) ); + retTable = PR__malloc( sizeof( HashTable ) ); retTable->freeEntryContentFn = freeFn; - retTable->entries = PR_int__malloc( numHashSlots * sizeof(HashEntry *) ); - retTable->numEntries = 0; - retTable->tableSz = numHashSlots; - - nullOutTablesArray( retTable ); - - return retTable; - } - -HashTable * -makeHashTable_WL( int numHashSlots, FreeEntryContentFnPtr freeFn ) - { HashTable * retTable; - retTable = PR_WL__malloc( sizeof( HashTable ) ); - - retTable->freeEntryContentFn = freeFn; - - retTable->entries = PR_int__malloc( numHashSlots * sizeof(HashEntry *) ); + retTable->entries = PR__malloc( numHashSlots * sizeof(HashEntry *) ); retTable->numEntries = 0; retTable->tableSz = numHashSlots; @@ -50,7 +34,7 @@ oldEntries = table->entries; newTableSz = 2 * oldTableSz; - newEntries = PR_int__malloc( newTableSz * sizeof(HashEntry *) ); + newEntries = PR__malloc( newTableSz * sizeof(HashEntry *) ); table->tableSz = newTableSz; table->entries = newEntries; @@ -97,10 +81,10 @@ int32 len = strlen(key); - hashEntry = (HashEntry*) PR_int__malloc( sizeof( HashEntry ) ); + hashEntry = (HashEntry*) PR__malloc( sizeof( HashEntry ) ); if( hashEntry == NULL ) return NULL; - hashEntry->key = PR_int__malloc( len + 1 ); + hashEntry->key = PR__malloc( len + 1 ); if( hashEntry->key == NULL ) return NULL; memcpy( hashEntry->key, key, len + 1 ); hashEntry->next = NULL; @@ -262,8 +246,26 @@ { if( entry->content != NULL ) (*(table->freeEntryContentFn))( entry->content ); - PR_int__free( entry->key ); //was PR_int__malloc'd above, so free it - PR_int__free( entry ); + PR__free( entry->key ); //was PR__malloc'd above, so free it + PR__free( entry ); + } + +/* obsolete -- delete + +HashTable * +makeHashTable_WL( int numHashSlots, FreeEntryContentFnPtr freeFn ) + { HashTable * retTable; + retTable = PR__malloc( sizeof( HashTable ) ); + + retTable->freeEntryContentFn = freeFn; + + retTable->entries = PR__malloc( numHashSlots * sizeof(HashEntry *) ); + retTable->numEntries = 0; + retTable->tableSz = numHashSlots; + + nullOutTablesArray( retTable ); + + return retTable; } void @@ -271,10 +273,9 @@ { if( entry->content != NULL ) (*(table->freeEntryContentFn))( entry->content ); - PR_WL__free( entry->key ); //was PR_int__malloc'd above, so free it - PR_WL__free( entry ); + PR__free( entry->key ); //was PR__malloc'd above, so free it + PR__free( entry ); } - void freeHashTable_WL( HashTable *table ) { int i; @@ -293,20 +294,13 @@ } } } - +*/ void freeHashEntryButNotContent( HashEntry *entry ) { - PR_int__free( entry->key ); //was PR_int__malloc'd above, so free it - PR_int__free( entry ); - } - -void -freeHashEntryButNotContent_WL( HashEntry *entry ) - { - PR_WL__free( entry->key ); //was PR_int__malloc'd above, so free it - PR_WL__free( entry ); + PR__free( entry->key ); //was PR__malloc'd above, so free it + PR__free( entry ); } @@ -325,7 +319,7 @@ { HashTable * retTable; int32 numHashSlots; - retTable = PR_int__malloc( sizeof( HashTable ) ); + retTable = PR__malloc( sizeof( HashTable ) ); numHashSlots = 1 << powerOf2OfSz; retTable->hashMask = 0xffffffff >> 32 - powerOf2OfSz; @@ -333,7 +327,7 @@ retTable->freeEntryContentFn = freeFn; - retTable->entries = PR_int__malloc( numHashSlots * sizeof(HashEntry *)); + retTable->entries = PR__malloc( numHashSlots * sizeof(HashEntry *)); retTable->numEntries = 0; retTable->tableSz = numHashSlots; @@ -352,9 +346,9 @@ makeHashEntry32( uint32 * key ) { HashEntry *hashEntry; - hashEntry = (HashEntry*) PR_int__malloc( sizeof( HashEntry ) ); + hashEntry = (HashEntry*) PR__malloc( sizeof( HashEntry ) ); if( hashEntry == NULL ) return NULL; - hashEntry->key = PR_int__malloc( sizeOfKey(key) ); + hashEntry->key = PR__malloc( sizeOfKey(key) ); if( hashEntry->key == NULL ) return NULL; memcpy( hashEntry->key, key, sizeOfKey(key) ); hashEntry->next = NULL; @@ -400,7 +394,7 @@ oldEntries = table->entries; newTableSz = 2 * oldTableSz; - newEntries = PR_int__malloc( newTableSz * sizeof(HashEntry *) ); + newEntries = PR__malloc( newTableSz * sizeof(HashEntry *) ); table->tableSz = newTableSz; table->entries = newEntries; diff -r 097d8ccb18b7 -r 049a8d8917c5 PrivateHash.h --- a/PrivateHash.h Mon Jul 22 06:17:46 2013 -0700 +++ b/PrivateHash.h Tue Jul 23 07:38:54 2013 -0700 @@ -13,7 +13,7 @@ #include #include -#include "PR__application_includes/PR__application.h" +#include "PR__common_includes/PR__primitive_data_types.h" //===================== defines ===================== #define TRUE 1