Moved the definition of PLHashTable from plhash.c back to plhash.h, NSPRPUB_RELEASE_3_0_LANDING_BRANCH
authorwtc%netscape.com
Wed, 23 Sep 1998 01:16:48 +0000
branchNSPRPUB_RELEASE_3_0_LANDING_BRANCH
changeset 255 ce164adf6da875aac2cd7df9a7193d740b403e50
parent 254 d655562e82ce72df1d0e2b5e4b8118f0b99de696
child 256 71d3cbcb753a08c5756af4285a15147cfed4fe30
push idunknown
push userunknown
push dateunknown
Moved the definition of PLHashTable from plhash.c back to plhash.h, because js/src and xpcom access the internal fields of the PLHashTable directly.
lib/ds/plhash.c
lib/ds/plhash.h
--- a/lib/ds/plhash.c
+++ b/lib/ds/plhash.c
@@ -22,33 +22,16 @@
 #include "plhash.h"
 #include "prbit.h"
 #include "prlog.h"
 #include "prmem.h"
 #include "prtypes.h"
 #include <stdlib.h>
 #include <string.h>
 
-struct PLHashTable {
-    PLHashEntry         **buckets;      /* vector of hash buckets */
-    PRUint32              nentries;       /* number of entries in table */
-    PRUint32              shift;          /* multiplicative hash shift */
-    PLHashFunction      keyHash;        /* key hash function */
-    PLHashComparator    keyCompare;     /* key comparison function */
-    PLHashComparator    valueCompare;   /* value comparison function */
-    const PLHashAllocOps *allocOps;     /* allocation operations */
-    void                *allocPriv;     /* allocation private data */
-#ifdef HASHMETER
-    PRUint32              nlookups;       /* total number of lookups */
-    PRUint32              nsteps;         /* number of hash chains traversed */
-    PRUint32              ngrows;         /* number of table expansions */
-    PRUint32              nshrinks;       /* number of table contractions */
-#endif
-};
-
 /* Compute the number of buckets in ht */
 #define NBUCKETS(ht)    (1 << (PL_HASH_BITS - (ht)->shift))
 
 /* The smallest table has 16 buckets */
 #define MINBUCKETSLOG2  4
 #define MINBUCKETS      (1 << MINBUCKETSLOG2)
 
 /* Compute the maximum entries given n buckets that we will tolerate, ~90% */
--- a/lib/ds/plhash.h
+++ b/lib/ds/plhash.h
@@ -52,16 +52,33 @@ typedef struct PLHashAllocOps {
 
 struct PLHashEntry {
     PLHashEntry         *next;          /* hash chain linkage */
     PLHashNumber        keyHash;        /* key hash function result */
     const void          *key;           /* ptr to opaque key */
     void                *value;         /* ptr to opaque value */
 };
 
+struct PLHashTable {
+    PLHashEntry         **buckets;      /* vector of hash buckets */
+    PRUint32              nentries;       /* number of entries in table */
+    PRUint32              shift;          /* multiplicative hash shift */
+    PLHashFunction      keyHash;        /* key hash function */
+    PLHashComparator    keyCompare;     /* key comparison function */
+    PLHashComparator    valueCompare;   /* value comparison function */
+    const PLHashAllocOps *allocOps;     /* allocation operations */
+    void                *allocPriv;     /* allocation private data */
+#ifdef HASHMETER
+    PRUint32              nlookups;       /* total number of lookups */
+    PRUint32              nsteps;         /* number of hash chains traversed */
+    PRUint32              ngrows;         /* number of table expansions */
+    PRUint32              nshrinks;       /* number of table contractions */
+#endif
+};
+
 /*
  * Create a new hash table.
  * If allocOps is null, use default allocator ops built on top of malloc().
  */
 PR_EXTERN(PLHashTable *)
 PL_NewHashTable(PRUint32 numBuckets, PLHashFunction keyHash,
                 PLHashComparator keyCompare, PLHashComparator valueCompare,
                 const PLHashAllocOps *allocOps, void *allocPriv);