@@ -28,12 +28,10 @@ This implements a hash table.
2828--------------------------------------------------------------------
2929*/
3030
31- #ifndef STANDARD
32- #include "standard.h"
33- #endif
31+ #ifndef HASHTAB_H
32+ #define HASHTAB_H
3433
35- #ifndef HASHTAB
36- #define HASHTAB
34+ #include "standard.h"
3735
3836#ifdef __cplusplus
3937extern "C" {
@@ -43,25 +41,25 @@ extern "C" {
4341
4442struct hitem
4543{
46- ub1 * key ; /* key that is hashed */
47- ub4 keyl ; /* length of key */
48- void * stuff ; /* stuff stored in this hitem */
49- ub4 hval ; /* hash value */
50- struct hitem * next ; /* next hitem in list */
44+ const char * key ; /* key that is hashed */
45+ size_t keyl ; /* length of key */
46+ void * stuff ; /* stuff stored in this hitem */
47+ size_t hval ; /* hash value */
48+ struct hitem * next ; /* next hitem in list */
5149};
5250typedef struct hitem hitem ;
5351
5452
5553struct htab
5654{
5755 struct hitem * * table ; /* hash table, array of size 2^logsize */
58- word logsize ; /* log of size of table */
59- size_t mask ; /* (hashval & mask) is position in table */
60- ub4 count ; /* how many items in this hash table so far? */
61- ub4 apos ; /* position in the array */
56+ int logsize ; /* log of size of table */
57+ size_t mask ; /* (hashval & mask) is position in table */
58+ size_t count ; /* how many items in this hash table so far? */
59+ size_t apos ; /* position in the array */
6260 struct hitem * ipos ; /* current item in the array */
6361 struct reroot * space ; /* space for the hitems */
64- ub4 bcount ; /* # hitems useable in current block */
62+ size_t bcount ; /* # hitems useable in current block */
6563};
6664typedef struct htab htab ;
6765
@@ -77,7 +75,7 @@ typedef struct htab htab;
7775 RETURNS:
7876 the new table
7977 */
80- extern htab * hcreate (/*_ word logsize _*/ );
78+ extern htab * hcreate (int logsize );
8179
8280
8381/* hdestroy - destroy a hash table
@@ -88,16 +86,16 @@ extern htab *hcreate(/*_ word logsize _*/);
8886 RETURNS:
8987 nothing
9088 */
91- extern void hdestroy (/*_ htab *t _*/ );
89+ extern void hdestroy (htab * t );
9290
9391
9492/* hcount, hkey, hkeyl, hstuff
9593 ARGUMENTS:
9694 t - the hash table
9795 RETURNS:
98- hcount - (ub4 ) The number of items in the hash table
99- hkey - (ub1 *) key for the current item
100- hkeyl - (ub4 ) key length for the current item
96+ hcount - (size_t ) The number of items in the hash table
97+ hkey - (const char *) key for the current item
98+ hkeyl - (size_t ) key length for the current item
10199 hstuff - (void *) stuff for the current item
102100 NOTE:
103101 The current position always has an item as long as there
@@ -121,7 +119,7 @@ extern void hdestroy(/*_ htab *t _*/);
121119 TRUE if the item exists, FALSE if it does not.
122120 If the item exists, moves the current position to that item.
123121 */
124- extern word hfind (/*_ htab *t, ub1 *key, ub4 keyl _*/ );
122+ extern int hfind (htab * t , const char * key , size_t keyl );
125123
126124
127125/* hadd - add a new item to the hash table
@@ -134,7 +132,7 @@ extern word hfind(/*_ htab *t, ub1 *key, ub4 keyl _*/);
134132 RETURNS:
135133 FALSE if the operation fails (because that key is already there).
136134 */
137- extern word hadd (/*_ htab *t, ub1 *key, ub4 keyl, void *stuff _*/ );
135+ extern int hadd (htab * t , const char * key , size_t keyl , void * stuff );
138136
139137
140138/* hdel - delete the item at the current position
@@ -153,7 +151,7 @@ extern word hadd(/*_ htab *t, ub1 *key, ub4 keyl, void *stuff _*/);
153151 hdel(tab);
154152 }
155153 */
156- extern word hdel (/* htab *t */ );
154+ extern int hdel (htab * t );
157155
158156
159157/* hfirst - move position to the first item in the table
@@ -163,7 +161,7 @@ extern word hdel(/* htab *t */);
163161 FALSE if there is no current item (meaning the table is empty)
164162 NOTE:
165163 */
166- extern word hfirst (/*_ htab *t _*/ );
164+ extern int hfirst (htab * t );
167165
168166
169167/* hnext - move position to the next item in the table
@@ -193,7 +191,7 @@ extern word hfirst(/*_ htab *t _*/);
193191 NOTE:
194192 This is private to hashtab; do not use it externally.
195193 */
196- extern word hnbucket (/*_ htab *t _*/ );
194+ extern int hnbucket (htab * t );
197195
198196
199197/* hstat - print statistics about the hash table
@@ -218,4 +216,4 @@ extern void hstat(/*_ htab *t _*/);
218216}
219217#endif
220218
221- #endif /* HASHTAB */
219+ #endif /* HASHTAB_H */
0 commit comments