tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

hashops.c (1487B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 /*
      6 * hashops.c
      7 *
      8 * This file includes a set of PLHashAllocOps that use NSSArenas.
      9 */
     10 
     11 #ifndef BASE_H
     12 #include "base.h"
     13 #endif /* BASE_H */
     14 
     15 static void *PR_CALLBACK
     16 nss_arena_hash_alloc_table(void *pool, PRSize size)
     17 {
     18    NSSArena *arena = (NSSArena *)NULL;
     19 
     20 #ifdef NSSDEBUG
     21    if ((void *)NULL != arena) {
     22        if (PR_SUCCESS != nssArena_verifyPointer(arena)) {
     23            return (void *)NULL;
     24        }
     25    }
     26 #endif /* NSSDEBUG */
     27 
     28    return nss_ZAlloc(arena, size);
     29 }
     30 
     31 static void PR_CALLBACK
     32 nss_arena_hash_free_table(void *pool, void *item)
     33 {
     34    (void)nss_ZFreeIf(item);
     35 }
     36 
     37 static PLHashEntry *PR_CALLBACK
     38 nss_arena_hash_alloc_entry(void *pool, const void *key)
     39 {
     40    NSSArena *arena = NULL;
     41 
     42 #ifdef NSSDEBUG
     43    if ((void *)NULL != arena) {
     44        if (PR_SUCCESS != nssArena_verifyPointer(arena)) {
     45            return (void *)NULL;
     46        }
     47    }
     48 #endif /* NSSDEBUG */
     49 
     50    return nss_ZNEW(arena, PLHashEntry);
     51 }
     52 
     53 static void PR_CALLBACK
     54 nss_arena_hash_free_entry(void *pool, PLHashEntry *he, PRUintn flag)
     55 {
     56    if (HT_FREE_ENTRY == flag) {
     57        (void)nss_ZFreeIf(he);
     58    }
     59 }
     60 
     61 NSS_IMPLEMENT_DATA PLHashAllocOps nssArenaHashAllocOps = {
     62    nss_arena_hash_alloc_table, nss_arena_hash_free_table,
     63    nss_arena_hash_alloc_entry, nss_arena_hash_free_entry
     64 };