Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | /* |
michael@0 | 6 | * hashops.c |
michael@0 | 7 | * |
michael@0 | 8 | * This file includes a set of PLHashAllocOps that use NSSArenas. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | #ifndef BASE_H |
michael@0 | 12 | #include "base.h" |
michael@0 | 13 | #endif /* BASE_H */ |
michael@0 | 14 | |
michael@0 | 15 | static void * PR_CALLBACK |
michael@0 | 16 | nss_arena_hash_alloc_table |
michael@0 | 17 | ( |
michael@0 | 18 | void *pool, |
michael@0 | 19 | PRSize size |
michael@0 | 20 | ) |
michael@0 | 21 | { |
michael@0 | 22 | NSSArena *arena = (NSSArena *)NULL; |
michael@0 | 23 | |
michael@0 | 24 | #ifdef NSSDEBUG |
michael@0 | 25 | if( (void *)NULL != arena ) { |
michael@0 | 26 | if( PR_SUCCESS != nssArena_verifyPointer(arena) ) { |
michael@0 | 27 | return (void *)NULL; |
michael@0 | 28 | } |
michael@0 | 29 | } |
michael@0 | 30 | #endif /* NSSDEBUG */ |
michael@0 | 31 | |
michael@0 | 32 | return nss_ZAlloc(arena, size); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | static void PR_CALLBACK |
michael@0 | 36 | nss_arena_hash_free_table |
michael@0 | 37 | ( |
michael@0 | 38 | void *pool, |
michael@0 | 39 | void *item |
michael@0 | 40 | ) |
michael@0 | 41 | { |
michael@0 | 42 | (void)nss_ZFreeIf(item); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | static PLHashEntry * PR_CALLBACK |
michael@0 | 46 | nss_arena_hash_alloc_entry |
michael@0 | 47 | ( |
michael@0 | 48 | void *pool, |
michael@0 | 49 | const void *key |
michael@0 | 50 | ) |
michael@0 | 51 | { |
michael@0 | 52 | NSSArena *arena = NULL; |
michael@0 | 53 | |
michael@0 | 54 | #ifdef NSSDEBUG |
michael@0 | 55 | if( (void *)NULL != arena ) { |
michael@0 | 56 | if( PR_SUCCESS != nssArena_verifyPointer(arena) ) { |
michael@0 | 57 | return (void *)NULL; |
michael@0 | 58 | } |
michael@0 | 59 | } |
michael@0 | 60 | #endif /* NSSDEBUG */ |
michael@0 | 61 | |
michael@0 | 62 | return nss_ZNEW(arena, PLHashEntry); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | static void PR_CALLBACK |
michael@0 | 66 | nss_arena_hash_free_entry |
michael@0 | 67 | ( |
michael@0 | 68 | void *pool, |
michael@0 | 69 | PLHashEntry *he, |
michael@0 | 70 | PRUintn flag |
michael@0 | 71 | ) |
michael@0 | 72 | { |
michael@0 | 73 | if( HT_FREE_ENTRY == flag ) { |
michael@0 | 74 | (void)nss_ZFreeIf(he); |
michael@0 | 75 | } |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | NSS_IMPLEMENT_DATA PLHashAllocOps |
michael@0 | 79 | nssArenaHashAllocOps = { |
michael@0 | 80 | nss_arena_hash_alloc_table, |
michael@0 | 81 | nss_arena_hash_free_table, |
michael@0 | 82 | nss_arena_hash_alloc_entry, |
michael@0 | 83 | nss_arena_hash_free_entry |
michael@0 | 84 | }; |