andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: /* andre@0: * hashops.c andre@0: * andre@0: * This file includes a set of PLHashAllocOps that use NSSArenas. andre@0: */ andre@0: andre@0: #ifndef BASE_H andre@0: #include "base.h" andre@0: #endif /* BASE_H */ andre@0: andre@0: static void * PR_CALLBACK andre@0: nss_arena_hash_alloc_table andre@0: ( andre@0: void *pool, andre@0: PRSize size andre@0: ) andre@0: { andre@0: NSSArena *arena = (NSSArena *)NULL; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( (void *)NULL != arena ) { andre@0: if( PR_SUCCESS != nssArena_verifyPointer(arena) ) { andre@0: return (void *)NULL; andre@0: } andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: return nss_ZAlloc(arena, size); andre@0: } andre@0: andre@0: static void PR_CALLBACK andre@0: nss_arena_hash_free_table andre@0: ( andre@0: void *pool, andre@0: void *item andre@0: ) andre@0: { andre@0: (void)nss_ZFreeIf(item); andre@0: } andre@0: andre@0: static PLHashEntry * PR_CALLBACK andre@0: nss_arena_hash_alloc_entry andre@0: ( andre@0: void *pool, andre@0: const void *key andre@0: ) andre@0: { andre@0: NSSArena *arena = NULL; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( (void *)NULL != arena ) { andre@0: if( PR_SUCCESS != nssArena_verifyPointer(arena) ) { andre@0: return (void *)NULL; andre@0: } andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: return nss_ZNEW(arena, PLHashEntry); andre@0: } andre@0: andre@0: static void PR_CALLBACK andre@0: nss_arena_hash_free_entry andre@0: ( andre@0: void *pool, andre@0: PLHashEntry *he, andre@0: PRUintn flag andre@0: ) andre@0: { andre@0: if( HT_FREE_ENTRY == flag ) { andre@0: (void)nss_ZFreeIf(he); andre@0: } andre@0: } andre@0: andre@0: NSS_IMPLEMENT_DATA PLHashAllocOps andre@0: nssArenaHashAllocOps = { andre@0: nss_arena_hash_alloc_table, andre@0: nss_arena_hash_free_table, andre@0: nss_arena_hash_alloc_entry, andre@0: nss_arena_hash_free_entry andre@0: };