OLD | NEW |
| (Empty) |
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 #ifdef DEBUG | |
6 static const char CVS_ID[] = "@(#) $RCSfile: hashops.c,v $ $Revision: 1.7 $ $Dat
e: 2012/04/25 14:49:26 $"; | |
7 #endif /* DEBUG */ | |
8 | |
9 /* | |
10 * hashops.c | |
11 * | |
12 * This file includes a set of PLHashAllocOps that use NSSArenas. | |
13 */ | |
14 | |
15 #ifndef BASE_H | |
16 #include "base.h" | |
17 #endif /* BASE_H */ | |
18 | |
19 static void * PR_CALLBACK | |
20 nss_arena_hash_alloc_table | |
21 ( | |
22 void *pool, | |
23 PRSize size | |
24 ) | |
25 { | |
26 NSSArena *arena = (NSSArena *)NULL; | |
27 | |
28 #ifdef NSSDEBUG | |
29 if( (void *)NULL != arena ) { | |
30 if( PR_SUCCESS != nssArena_verifyPointer(arena) ) { | |
31 return (void *)NULL; | |
32 } | |
33 } | |
34 #endif /* NSSDEBUG */ | |
35 | |
36 return nss_ZAlloc(arena, size); | |
37 } | |
38 | |
39 static void PR_CALLBACK | |
40 nss_arena_hash_free_table | |
41 ( | |
42 void *pool, | |
43 void *item | |
44 ) | |
45 { | |
46 (void)nss_ZFreeIf(item); | |
47 } | |
48 | |
49 static PLHashEntry * PR_CALLBACK | |
50 nss_arena_hash_alloc_entry | |
51 ( | |
52 void *pool, | |
53 const void *key | |
54 ) | |
55 { | |
56 NSSArena *arena = NULL; | |
57 | |
58 #ifdef NSSDEBUG | |
59 if( (void *)NULL != arena ) { | |
60 if( PR_SUCCESS != nssArena_verifyPointer(arena) ) { | |
61 return (void *)NULL; | |
62 } | |
63 } | |
64 #endif /* NSSDEBUG */ | |
65 | |
66 return nss_ZNEW(arena, PLHashEntry); | |
67 } | |
68 | |
69 static void PR_CALLBACK | |
70 nss_arena_hash_free_entry | |
71 ( | |
72 void *pool, | |
73 PLHashEntry *he, | |
74 PRUintn flag | |
75 ) | |
76 { | |
77 if( HT_FREE_ENTRY == flag ) { | |
78 (void)nss_ZFreeIf(he); | |
79 } | |
80 } | |
81 | |
82 NSS_IMPLEMENT_DATA PLHashAllocOps | |
83 nssArenaHashAllocOps = { | |
84 nss_arena_hash_alloc_table, | |
85 nss_arena_hash_free_table, | |
86 nss_arena_hash_alloc_entry, | |
87 nss_arena_hash_free_entry | |
88 }; | |
OLD | NEW |