Ignore:
Timestamp:
Nov 26, 2002, 10:24:54 PM (23 years ago)
Author:
bird
Message:

Import of RELENG_4_7_0_RELEASE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FREEBSD/src/kmk/hash.c

    r10 r24  
    11/*
    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.
    43 * Copyright (c) 1988, 1989 by Adam de Boor
    54 * Copyright (c) 1989 by Berkeley Softworks
     
    3635 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3736 * 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
     41static char sccsid[] = "@(#)hash.c      8.1 (Berkeley) 6/6/93";
     42#else
     43static 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 */
    4447
    4548/* hash.c --
     
    5053 *      information increases.
    5154 */
    52 #include <unistd.h>
    5355#include "sprite.h"
    5456#include "make.h"
     
    6062 */
    6163
    62 static void RebuildTable(Hash_Table *);
     64static void RebuildTable __P((Hash_Table *));
    6365
    6466/*
     
    6769 */
    6870
    69 #define rebuildLimit 8
     71#define rebuildLimit 8
    7072
    7173/*
     
    7375 *
    7476 * 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.
    8079 *
    8180 * Results:
     
    8988
    9089void
    91 Hash_InitTable(Hash_Table *t, int numBuckets)
    92 {
    93         int i;
    94         struct Hash_Entry **hp;
     90Hash_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;
    95100
    96101        /*
     
    130135
    131136void
    132 Hash_DeleteTable(Hash_Table *t)
    133 {
    134         struct Hash_Entry **hp, *h, *nexth = NULL;
    135         int i;
     137Hash_DeleteTable(t)
     138        Hash_Table *t;
     139{
     140        register struct Hash_Entry **hp, *h, *nexth = NULL;
     141        register int i;
    136142
    137143        for (hp = t->bucketPtr, i = t->size; --i >= 0;) {
     
    169175
    170176Hash_Entry *
    171 Hash_FindEntry(Hash_Table *t, char *key)
    172 {
    173         Hash_Entry *e;
    174         unsigned h;
    175         char *p;
     177Hash_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;
    176184
    177185        for (h = 0, p = key; *p;)
     
    204212
    205213Hash_Entry *
    206 Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr)
    207 {
    208         Hash_Entry *e;
    209         unsigned int h;
    210         char *p;
     214Hash_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;
    211223        int keylen;
    212224        struct Hash_Entry **hp;
     
    267279
    268280void
    269 Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
    270 {
    271         Hash_Entry **hp, *p;
     281Hash_DeleteEntry(t, e)
     282        Hash_Table *t;
     283        Hash_Entry *e;
     284{
     285        register Hash_Entry **hp, *p;
    272286
    273287        if (e == NULL)
     
    282296                }
    283297        }
    284         (void) write(STDERR_FILENO, "bad call to Hash_DeleteEntry\n", 29);
     298        (void) write(2, "bad call to Hash_DeleteEntry\n", 29);
    285299        abort();
    286300}
     
    306320
    307321Hash_Entry *
    308 Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr)
     322Hash_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.*/
    309326{
    310327        searchPtr->tablePtr = t;
     
    333350
    334351Hash_Entry *
    335 Hash_EnumNext(Hash_Search *searchPtr)
    336 {
    337         Hash_Entry *e;
     352Hash_EnumNext(searchPtr)
     353        register Hash_Search *searchPtr; /* Area used to keep state about
     354                                            search. */
     355{
     356        register Hash_Entry *e;
    338357        Hash_Table *t = searchPtr->tablePtr;
    339358
    340359        /*
    341360         * The hashEntryPtr field points to the most recently returned
    342          * entry, or is NULL if we are starting up.  If not NULL, we have
     361         * entry, or is nil if we are starting up.  If not nil, we have
    343362         * to start at the next one in the chain.
    344363         */
     
    377396
    378397static void
    379 RebuildTable(Hash_Table *t)
    380 {
    381         Hash_Entry *e, *next = NULL, **hp, **xp;
    382         int i, mask;
    383         Hash_Entry **oldhp;
     398RebuildTable(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;
    384404        int oldsize;
    385405
Note: See TracChangeset for help on using the changeset viewer.