OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 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 | 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/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 /* | 5 /* |
6 * hash.c | 6 * hash.c |
7 * | 7 * |
8 * This is merely a couple wrappers around NSPR's PLHashTable, using | 8 * This is merely a couple wrappers around NSPR's PLHashTable, using |
9 * the identity hash and arena-aware allocators. | 9 * the identity hash and arena-aware allocators. |
10 * This is a copy of ckfw/hash.c, with modifications to use NSS types | 10 * This is a copy of ckfw/hash.c, with modifications to use NSS types |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 PLHashTable *plHashTable; | 44 PLHashTable *plHashTable; |
45 PRUint32 count; | 45 PRUint32 count; |
46 }; | 46 }; |
47 | 47 |
48 static PLHashNumber | 48 static PLHashNumber |
49 nss_identity_hash | 49 nss_identity_hash |
50 ( | 50 ( |
51 const void *key | 51 const void *key |
52 ) | 52 ) |
53 { | 53 { |
54 PRUint32 i = (PRUint32)key; | 54 return (PLHashNumber)((char *)key - (char *)NULL); |
55 PR_ASSERT(sizeof(PLHashNumber) == sizeof(PRUint32)); | |
56 return (PLHashNumber)i; | |
57 } | 55 } |
58 | 56 |
59 static PLHashNumber | 57 static PLHashNumber |
60 nss_item_hash | 58 nss_item_hash |
61 ( | 59 ( |
62 const void *key | 60 const void *key |
63 ) | 61 ) |
64 { | 62 { |
65 unsigned int i; | 63 unsigned int i; |
66 PLHashNumber h; | 64 PLHashNumber h; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 as.closure = closure; | 362 as.closure = closure; |
365 | 363 |
366 PZ_Lock(hash->mutex); | 364 PZ_Lock(hash->mutex); |
367 | 365 |
368 PL_HashTableEnumerateEntries(hash->plHashTable, nss_hash_enumerator, &as); | 366 PL_HashTableEnumerateEntries(hash->plHashTable, nss_hash_enumerator, &as); |
369 | 367 |
370 (void)PZ_Unlock(hash->mutex); | 368 (void)PZ_Unlock(hash->mutex); |
371 | 369 |
372 return; | 370 return; |
373 } | 371 } |
OLD | NEW |