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