make(1): remove initial size argument from Hash_InitTable

In all but one case this argument was set to auto-detect anyway.  The
one case where it was set was not worth keeping this complicated API.
This commit is contained in:
rillig 2020-09-05 13:55:08 +00:00
parent b5ca7043a9
commit 59980735fc
5 changed files with 28 additions and 41 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: arch.c,v 1.107 2020/08/30 11:15:05 rillig Exp $ */
/* $NetBSD: arch.c,v 1.108 2020/09/05 13:55:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: arch.c,v 1.107 2020/08/30 11:15:05 rillig Exp $";
static char rcsid[] = "$NetBSD: arch.c,v 1.108 2020/09/05 13:55:08 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: arch.c,v 1.107 2020/08/30 11:15:05 rillig Exp $");
__RCSID("$NetBSD: arch.c,v 1.108 2020/09/05 13:55:08 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -572,7 +572,7 @@ ArchStatMember(const char *archive, const char *member, Boolean hash)
ar->name = bmake_strdup(archive);
ar->fnametab = NULL;
ar->fnamesize = 0;
Hash_InitTable(&ar->members, -1);
Hash_InitTable(&ar->members);
memName[AR_MAX_NAME_LEN] = '\0';
while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.135 2020/09/02 04:32:13 rillig Exp $ */
/* $NetBSD: dir.c,v 1.136 2020/09/05 13:55:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: dir.c,v 1.135 2020/09/02 04:32:13 rillig Exp $";
static char rcsid[] = "$NetBSD: dir.c,v 1.136 2020/09/05 13:55:08 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: dir.c,v 1.135 2020/09/02 04:32:13 rillig Exp $");
__RCSID("$NetBSD: dir.c,v 1.136 2020/09/05 13:55:08 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -358,8 +358,8 @@ Dir_Init(void)
{
dirSearchPath = Lst_Init();
openDirectories = Lst_Init();
Hash_InitTable(&mtimes, 0);
Hash_InitTable(&lmtimes, 0);
Hash_InitTable(&mtimes);
Hash_InitTable(&lmtimes);
}
void
@ -371,7 +371,7 @@ Dir_InitDir(const char *cdname)
dotLast->refCount = 1;
dotLast->hits = 0;
dotLast->name = bmake_strdup(".DOTLAST");
Hash_InitTable(&dotLast->files, -1);
Hash_InitTable(&dotLast->files);
}
/*
@ -1547,7 +1547,7 @@ Dir_AddDir(Lst path, const char *name)
p->name = bmake_strdup(name);
p->hits = 0;
p->refCount = 1;
Hash_InitTable(&p->files, -1);
Hash_InitTable(&p->files);
while ((dp = readdir(d)) != NULL) {
#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */

View File

@ -1,4 +1,4 @@
/* $NetBSD: hash.c,v 1.30 2020/09/05 13:36:25 rillig Exp $ */
/* $NetBSD: hash.c,v 1.31 2020/09/05 13:55:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: hash.c,v 1.30 2020/09/05 13:36:25 rillig Exp $";
static char rcsid[] = "$NetBSD: hash.c,v 1.31 2020/09/05 13:55:08 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: hash.c,v 1.30 2020/09/05 13:36:25 rillig Exp $");
__RCSID("$NetBSD: hash.c,v 1.31 2020/09/05 13:55:08 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -120,33 +120,20 @@ static void RebuildTable(Hash_Table *);
*
* Input:
* t Structure to to hold the table.
* numBuckets How many buckets to create for starters. This
* number is rounded up to a power of two. If
* <= 0, a reasonable default is chosen. The
* table will grow in size later as needed.
*/
void
Hash_InitTable(Hash_Table *t, int numBuckets)
Hash_InitTable(Hash_Table *t)
{
int i;
size_t n = 16, i;
struct Hash_Entry **hp;
/*
* Round up the size to a power of two.
*/
if (numBuckets <= 0)
i = 16;
else {
for (i = 2; i < numBuckets; i <<= 1)
continue;
}
t->numEntries = 0;
t->maxchain = 0;
t->bucketsSize = i;
t->bucketsMask = i - 1;
t->buckets = hp = bmake_malloc(sizeof(*hp) * i);
while (--i >= 0)
*hp++ = NULL;
t->bucketsSize = n;
t->bucketsMask = n - 1;
t->buckets = hp = bmake_malloc(sizeof(*hp) * n);
for (i = 0; i < n; i++)
hp[i] = NULL;
}
/* Removes everything from the hash table and frees up the memory space it

View File

@ -1,4 +1,4 @@
/* $NetBSD: hash.h,v 1.21 2020/09/01 21:11:31 rillig Exp $ */
/* $NetBSD: hash.h,v 1.22 2020/09/05 13:55:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -118,7 +118,7 @@ Hash_SetValue(Hash_Entry *h, void *datum)
h->value = datum;
}
void Hash_InitTable(Hash_Table *, int);
void Hash_InitTable(Hash_Table *);
void Hash_DeleteTable(Hash_Table *);
Hash_Entry *Hash_FindEntry(Hash_Table *, const char *);
Hash_Entry *Hash_CreateEntry(Hash_Table *, const char *, Boolean *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: targ.c,v 1.82 2020/09/05 06:46:12 rillig Exp $ */
/* $NetBSD: targ.c,v 1.83 2020/09/05 13:55:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: targ.c,v 1.82 2020/09/05 06:46:12 rillig Exp $";
static char rcsid[] = "$NetBSD: targ.c,v 1.83 2020/09/05 13:55:08 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: targ.c,v 1.82 2020/09/05 06:46:12 rillig Exp $");
__RCSID("$NetBSD: targ.c,v 1.83 2020/09/05 13:55:08 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -150,7 +150,7 @@ void
Targ_Init(void)
{
allTargets = Lst_Init();
Hash_InitTable(&targets, 191);
Hash_InitTable(&targets);
}
void
@ -209,7 +209,7 @@ Targ_NewGN(const char *name)
gn->children = Lst_Init();
gn->order_pred = Lst_Init();
gn->order_succ = Lst_Init();
Hash_InitTable(&gn->context, 0);
Hash_InitTable(&gn->context);
gn->commands = Lst_Init();
gn->suffix = NULL;
gn->fname = NULL;