Changeset 24 for branches/FREEBSD/src/kmk/hash.c
- Timestamp:
- Nov 26, 2002, 10:24:54 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FREEBSD/src/kmk/hash.c
r10 r24 1 1 /* 2 * Copyright (c) 1988, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 2 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 3 * Copyright (c) 1988, 1989 by Adam de Boor 5 4 * Copyright (c) 1989 by Berkeley Softworks … … 36 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 36 * SUCH DAMAGE. 38 * 39 * @(#)hash.c 8.1 (Berkeley) 6/6/93 40 */ 41 42 #include <sys/cdefs.h> 43 __FBSDID("$FreeBSD: src/usr.bin/make/hash.c,v 1.18 2002/10/09 03:42:10 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/hash.c,v 1.9 1999/09/11 13:08:01 hoek Exp $"; 45 #endif 46 #endif /* not lint */ 44 47 45 48 /* hash.c -- … … 50 53 * information increases. 51 54 */ 52 #include <unistd.h>53 55 #include "sprite.h" 54 56 #include "make.h" … … 60 62 */ 61 63 62 static void RebuildTable (Hash_Table *);64 static void RebuildTable __P((Hash_Table *)); 63 65 64 66 /* … … 67 69 */ 68 70 69 #define 71 #define rebuildLimit 8 70 72 71 73 /* … … 73 75 * 74 76 * Hash_InitTable -- 75 * 76 * Set up the hash table t with a given number of buckets, or a 77 * reasonable default if the number requested is less than or 78 * equal to zero. Hash tables will grow in size as needed. 79 * 77 * 78 * This routine just sets up the hash table. 80 79 * 81 80 * Results: … … 89 88 90 89 void 91 Hash_InitTable(Hash_Table *t, int numBuckets) 92 { 93 int i; 94 struct Hash_Entry **hp; 90 Hash_InitTable(t, numBuckets) 91 register Hash_Table *t; /* Structure to use to hold table. */ 92 int numBuckets; /* How many buckets to create for starters. 93 * This number is rounded up to a power of 94 * two. If <= 0, a reasonable default is 95 * chosen. The table will grow in size later 96 * as needed. */ 97 { 98 register int i; 99 register struct Hash_Entry **hp; 95 100 96 101 /* … … 130 135 131 136 void 132 Hash_DeleteTable(Hash_Table *t) 133 { 134 struct Hash_Entry **hp, *h, *nexth = NULL; 135 int i; 137 Hash_DeleteTable(t) 138 Hash_Table *t; 139 { 140 register struct Hash_Entry **hp, *h, *nexth = NULL; 141 register int i; 136 142 137 143 for (hp = t->bucketPtr, i = t->size; --i >= 0;) { … … 169 175 170 176 Hash_Entry * 171 Hash_FindEntry(Hash_Table *t, char *key) 172 { 173 Hash_Entry *e; 174 unsigned h; 175 char *p; 177 Hash_FindEntry(t, key) 178 Hash_Table *t; /* Hash table to search. */ 179 char *key; /* A hash key. */ 180 { 181 register Hash_Entry *e; 182 register unsigned h; 183 register char *p; 176 184 177 185 for (h = 0, p = key; *p;) … … 204 212 205 213 Hash_Entry * 206 Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr) 207 { 208 Hash_Entry *e; 209 unsigned int h; 210 char *p; 214 Hash_CreateEntry(t, key, newPtr) 215 register Hash_Table *t; /* Hash table to search. */ 216 char *key; /* A hash key. */ 217 Boolean *newPtr; /* Filled in with TRUE if new entry created, 218 * FALSE otherwise. */ 219 { 220 register Hash_Entry *e; 221 register unsigned h; 222 register char *p; 211 223 int keylen; 212 224 struct Hash_Entry **hp; … … 267 279 268 280 void 269 Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e) 270 { 271 Hash_Entry **hp, *p; 281 Hash_DeleteEntry(t, e) 282 Hash_Table *t; 283 Hash_Entry *e; 284 { 285 register Hash_Entry **hp, *p; 272 286 273 287 if (e == NULL) … … 282 296 } 283 297 } 284 (void) write( STDERR_FILENO, "bad call to Hash_DeleteEntry\n", 29);298 (void) write(2, "bad call to Hash_DeleteEntry\n", 29); 285 299 abort(); 286 300 } … … 306 320 307 321 Hash_Entry * 308 Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr) 322 Hash_EnumFirst(t, searchPtr) 323 Hash_Table *t; /* Table to be searched. */ 324 register Hash_Search *searchPtr;/* Area in which to keep state 325 * about search.*/ 309 326 { 310 327 searchPtr->tablePtr = t; … … 333 350 334 351 Hash_Entry * 335 Hash_EnumNext(Hash_Search *searchPtr) 336 { 337 Hash_Entry *e; 352 Hash_EnumNext(searchPtr) 353 register Hash_Search *searchPtr; /* Area used to keep state about 354 search. */ 355 { 356 register Hash_Entry *e; 338 357 Hash_Table *t = searchPtr->tablePtr; 339 358 340 359 /* 341 360 * The hashEntryPtr field points to the most recently returned 342 * entry, or is NULL if we are starting up. If not NULL, we have361 * entry, or is nil if we are starting up. If not nil, we have 343 362 * to start at the next one in the chain. 344 363 */ … … 377 396 378 397 static void 379 RebuildTable(Hash_Table *t) 380 { 381 Hash_Entry *e, *next = NULL, **hp, **xp; 382 int i, mask; 383 Hash_Entry **oldhp; 398 RebuildTable(t) 399 register Hash_Table *t; 400 { 401 register Hash_Entry *e, *next = NULL, **hp, **xp; 402 register int i, mask; 403 register Hash_Entry **oldhp; 384 404 int oldsize; 385 405
Note:
See TracChangeset
for help on using the changeset viewer.