mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-27 02:47:31 +09:00
update NSPR to 4.24 and keep NSPR Bug 1586070 and win64 patch intact.
This commit is contained in:
parent
dd094ae552
commit
0b9855b841
487 changed files with 42933 additions and 48679 deletions
|
|
@ -51,8 +51,9 @@ DefaultAllocEntry(void *pool, const void *key)
|
|||
static void PR_CALLBACK
|
||||
DefaultFreeEntry(void *pool, PLHashEntry *he, PRUintn flag)
|
||||
{
|
||||
if (flag == HT_FREE_ENTRY)
|
||||
if (flag == HT_FREE_ENTRY) {
|
||||
PR_Free(he);
|
||||
}
|
||||
}
|
||||
|
||||
static PLHashAllocOps defaultHashAllocOps = {
|
||||
|
|
@ -72,15 +73,19 @@ PL_NewHashTable(PRUint32 n, PLHashFunction keyHash,
|
|||
n = MINBUCKETSLOG2;
|
||||
} else {
|
||||
n = PR_CeilingLog2(n);
|
||||
if ((PRInt32)n < 0)
|
||||
if ((PRInt32)n < 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allocOps) allocOps = &defaultHashAllocOps;
|
||||
if (!allocOps) {
|
||||
allocOps = &defaultHashAllocOps;
|
||||
}
|
||||
|
||||
ht = (PLHashTable*)((*allocOps->allocTable)(allocPriv, sizeof *ht));
|
||||
if (!ht)
|
||||
return 0;
|
||||
if (!ht) {
|
||||
return 0;
|
||||
}
|
||||
memset(ht, 0, sizeof *ht);
|
||||
ht->shift = PL_HASH_BITS - n;
|
||||
n = 1 << n;
|
||||
|
|
@ -202,7 +207,7 @@ PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep,
|
|||
oldbuckets = ht->buckets;
|
||||
nb = 2 * n * sizeof(PLHashEntry *);
|
||||
ht->buckets = (PLHashEntry**)
|
||||
((*ht->allocOps->allocTable)(ht->allocPriv, nb));
|
||||
((*ht->allocOps->allocTable)(ht->allocPriv, nb));
|
||||
if (!ht->buckets) {
|
||||
ht->buckets = oldbuckets;
|
||||
return 0;
|
||||
|
|
@ -231,8 +236,9 @@ PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep,
|
|||
|
||||
/* Make a new key value entry */
|
||||
he = (*ht->allocOps->allocEntry)(ht->allocPriv, key);
|
||||
if (!he)
|
||||
return 0;
|
||||
if (!he) {
|
||||
return 0;
|
||||
}
|
||||
he->keyHash = keyHash;
|
||||
he->key = key;
|
||||
he->value = value;
|
||||
|
|
@ -256,8 +262,9 @@ PL_HashTableAdd(PLHashTable *ht, const void *key, void *value)
|
|||
/* key,value pair is already present in table */
|
||||
return he;
|
||||
}
|
||||
if (he->value)
|
||||
if (he->value) {
|
||||
(*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_VALUE);
|
||||
}
|
||||
he->value = value;
|
||||
return he;
|
||||
}
|
||||
|
|
@ -280,7 +287,7 @@ PL_HashTableRawRemove(PLHashTable *ht, PLHashEntry **hep, PLHashEntry *he)
|
|||
oldbuckets = ht->buckets;
|
||||
nb = n * sizeof(PLHashEntry*) / 2;
|
||||
ht->buckets = (PLHashEntry**)(
|
||||
(*ht->allocOps->allocTable)(ht->allocPriv, nb));
|
||||
(*ht->allocOps->allocTable)(ht->allocPriv, nb));
|
||||
if (!ht->buckets) {
|
||||
ht->buckets = oldbuckets;
|
||||
return;
|
||||
|
|
@ -315,8 +322,9 @@ PL_HashTableRemove(PLHashTable *ht, const void *key)
|
|||
|
||||
keyHash = (*ht->keyHash)(key);
|
||||
hep = PL_HashTableRawLookup(ht, keyHash, key);
|
||||
if ((he = *hep) == 0)
|
||||
if ((he = *hep) == 0) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/* Hit; remove element */
|
||||
PL_HashTableRawRemove(ht, hep, he);
|
||||
|
|
@ -414,11 +422,13 @@ PL_HashTableDumpMeter(PLHashTable *ht, PLHashEnumerator dump, FILE *fp)
|
|||
nbuckets = NBUCKETS(ht);
|
||||
for (i = 0; i < nbuckets; i++) {
|
||||
he = ht->buckets[i];
|
||||
if (!he)
|
||||
if (!he) {
|
||||
continue;
|
||||
}
|
||||
nchains++;
|
||||
for (n = 0; he; he = he->next)
|
||||
for (n = 0; he; he = he->next) {
|
||||
n++;
|
||||
}
|
||||
variance += n * n;
|
||||
if (n > maxChainLen) {
|
||||
maxChainLen = n;
|
||||
|
|
@ -434,15 +444,16 @@ PL_HashTableDumpMeter(PLHashTable *ht, PLHashEnumerator dump, FILE *fp)
|
|||
fprintf(fp, " number of grows: %u\n", ht->ngrows);
|
||||
fprintf(fp, " number of shrinks: %u\n", ht->nshrinks);
|
||||
fprintf(fp, " mean steps per hash: %g\n", (double)ht->nsteps
|
||||
/ ht->nlookups);
|
||||
/ ht->nlookups);
|
||||
fprintf(fp, "mean hash chain length: %g\n", mean);
|
||||
fprintf(fp, " standard deviation: %g\n", sqrt(variance));
|
||||
fprintf(fp, " max hash chain length: %u\n", maxChainLen);
|
||||
fprintf(fp, " max hash chain: [%u]\n", maxChain);
|
||||
|
||||
for (he = ht->buckets[maxChain], i = 0; he; he = he->next, i++)
|
||||
if ((*dump)(he, i, fp) != HT_ENUMERATE_NEXT)
|
||||
if ((*dump)(he, i, fp) != HT_ENUMERATE_NEXT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* HASHMETER */
|
||||
|
||||
|
|
@ -465,8 +476,9 @@ PL_HashString(const void *key)
|
|||
const PRUint8 *s;
|
||||
|
||||
h = 0;
|
||||
for (s = (const PRUint8*)key; *s; s++)
|
||||
for (s = (const PRUint8*)key; *s; s++) {
|
||||
h = PR_ROTATE_LEFT32(h, 4) ^ *s;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue