Module Name:    src
Committed By:   rillig
Date:           Sun Oct 25 19:19:07 UTC 2020

Modified Files:
        src/usr.bin/make: arch.c dir.c hash.c hash.h main.c targ.c var.c

Log Message:
make(1): rename hash functions to identify the type name

This makes it easier to spot mismatches between the function name and
its first parameter, although the compiler should already catch most of
them.  Except for void pointers.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/make/arch.c
cvs rdiff -u -r1.187 -r1.188 src/usr.bin/make/dir.c
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/make/hash.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/hash.h
cvs rdiff -u -r1.389 -r1.390 src/usr.bin/make/main.c
cvs rdiff -u -r1.122 -r1.123 src/usr.bin/make/targ.c
cvs rdiff -u -r1.587 -r1.588 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.146 src/usr.bin/make/arch.c:1.147
--- src/usr.bin/make/arch.c:1.146	Sun Oct 25 07:57:01 2020
+++ src/usr.bin/make/arch.c	Sun Oct 25 19:19:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.146 2020/10/25 07:57:01 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.147 2020/10/25 19:19:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include    "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.146 2020/10/25 07:57:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.147 2020/10/25 19:19:07 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -172,11 +172,11 @@ ArchFree(void *ap)
     /* Free memory from hash entries */
     HashIter_Init(&hi, &a->members);
     while ((he = HashIter_Next(&hi)) != NULL)
-	free(Hash_GetValue(he));
+	free(HashEntry_Get(he));
 
     free(a->name);
     free(a->fnametab);
-    Hash_DeleteTable(&a->members);
+    HashTable_Done(&a->members);
     free(a);
 }
 #endif
@@ -445,7 +445,7 @@ ArchStatMember(const char *archive, cons
 	struct ar_hdr *hdr;
 
 	ar = ln->datum;
-	hdr = Hash_FindValue(&ar->members, member);
+	hdr = HashTable_FindValue(&ar->members, member);
 	if (hdr != NULL)
 	    return hdr;
 
@@ -458,7 +458,7 @@ ArchStatMember(const char *archive, cons
 		len = AR_MAX_NAME_LEN;
 		snprintf(copy, sizeof copy, "%s", member);
 	    }
-	    hdr = Hash_FindValue(&ar->members, copy);
+	    hdr = HashTable_FindValue(&ar->members, copy);
 	    return hdr;
 	}
     }
@@ -503,7 +503,7 @@ ArchStatMember(const char *archive, cons
     ar->name = bmake_strdup(archive);
     ar->fnametab = NULL;
     ar->fnamesize = 0;
-    Hash_InitTable(&ar->members);
+    HashTable_Init(&ar->members);
     memName[AR_MAX_NAME_LEN] = '\0';
 
     while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
@@ -580,9 +580,9 @@ ArchStatMember(const char *archive, cons
 
 	    {
 		HashEntry *he;
-		he = Hash_CreateEntry(&ar->members, memName, NULL);
-		Hash_SetValue(he, bmake_malloc(sizeof(struct ar_hdr)));
-		memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));
+		he = HashTable_CreateEntry(&ar->members, memName, NULL);
+		HashEntry_Set(he, bmake_malloc(sizeof(struct ar_hdr)));
+		memcpy(HashEntry_Get(he), &arh, sizeof(struct ar_hdr));
 	    }
 	}
 	if (fseek(arch, ((long)size + 1) & ~1, SEEK_CUR) != 0)
@@ -597,11 +597,11 @@ ArchStatMember(const char *archive, cons
      * Now that the archive has been read and cached, we can look into
      * the hash table to find the desired member's header.
      */
-    return Hash_FindValue(&ar->members, member);
+    return HashTable_FindValue(&ar->members, member);
 
 badarch:
     fclose(arch);
-    Hash_DeleteTable(&ar->members);
+    HashTable_Done(&ar->members);
     free(ar->fnametab);
     free(ar);
     return NULL;

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.187 src/usr.bin/make/dir.c:1.188
--- src/usr.bin/make/dir.c:1.187	Sun Oct 25 10:00:20 2020
+++ src/usr.bin/make/dir.c	Sun Oct 25 19:19:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.187 2020/10/25 10:00:20 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.188 2020/10/25 19:19:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -135,7 +135,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.187 2020/10/25 10:00:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.188 2020/10/25 19:19:07 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -228,7 +228,7 @@ static void
 OpenDirs_Init(OpenDirs *odirs)
 {
     odirs->list = Lst_New();
-    Hash_InitTable(&odirs->table);
+    HashTable_Init(&odirs->table);
 }
 
 #ifdef CLEANUP
@@ -243,37 +243,37 @@ OpenDirs_Done(OpenDirs *odirs)
 	ln = next;
     }
     Lst_Free(odirs->list);
-    Hash_DeleteTable(&odirs->table);
+    HashTable_Done(&odirs->table);
 }
 #endif
 
 static CachedDir *
 OpenDirs_Find(OpenDirs *odirs, const char *name)
 {
-    CachedDirListNode *ln = Hash_FindValue(&odirs->table, name);
+    CachedDirListNode *ln = HashTable_FindValue(&odirs->table, name);
     return ln != NULL ? ln->datum : NULL;
 }
 
 static void
 OpenDirs_Add(OpenDirs *odirs, CachedDir *cdir)
 {
-    HashEntry *he = Hash_FindEntry(&odirs->table, cdir->name);
+    HashEntry *he = HashTable_FindEntry(&odirs->table, cdir->name);
     if (he != NULL)
 	return;
-    he = Hash_CreateEntry(&odirs->table, cdir->name, NULL);
+    he = HashTable_CreateEntry(&odirs->table, cdir->name, NULL);
     Lst_Append(odirs->list, cdir);
-    Hash_SetValue(he, odirs->list->last);
+    HashEntry_Set(he, odirs->list->last);
 }
 
 static void
 OpenDirs_Remove(OpenDirs *odirs, const char *name)
 {
-    HashEntry *he = Hash_FindEntry(&odirs->table, name);
+    HashEntry *he = HashTable_FindEntry(&odirs->table, name);
     CachedDirListNode *ln;
     if (he == NULL)
 	return;
-    ln = Hash_GetValue(he);
-    Hash_DeleteEntry(&odirs->table, he);
+    ln = HashEntry_Get(he);
+    HashTable_DeleteEntry(&odirs->table, he);
     Lst_Remove(odirs->list, ln);
 }
 
@@ -333,10 +333,10 @@ cached_stats(HashTable *htp, const char 
     if (!pathname || !pathname[0])
 	return -1;
 
-    entry = Hash_FindEntry(htp, pathname);
+    entry = HashTable_FindEntry(htp, pathname);
 
     if (entry && !(flags & CST_UPDATE)) {
-	cst = Hash_GetValue(entry);
+	cst = HashEntry_Get(entry);
 
 	mst->mst_mode = cst->mode;
 	mst->mst_mtime = (flags & CST_LSTAT) ? cst->lmtime : cst->mtime;
@@ -360,12 +360,12 @@ cached_stats(HashTable *htp, const char 
     mst->mst_mtime = sys_st.st_mtime;
 
     if (entry == NULL)
-	entry = Hash_CreateEntry(htp, pathname, NULL);
-    if (Hash_GetValue(entry) == NULL) {
-	Hash_SetValue(entry, bmake_malloc(sizeof(*cst)));
-	memset(Hash_GetValue(entry), 0, sizeof(*cst));
+	entry = HashTable_CreateEntry(htp, pathname, NULL);
+    if (HashEntry_Get(entry) == NULL) {
+	HashEntry_Set(entry, bmake_malloc(sizeof(*cst)));
+	memset(HashEntry_Get(entry), 0, sizeof(*cst));
     }
-    cst = Hash_GetValue(entry);
+    cst = HashEntry_Get(entry);
     if (flags & CST_LSTAT) {
 	cst->lmtime = sys_st.st_mtime;
     } else {
@@ -396,8 +396,8 @@ Dir_Init(void)
 {
     dirSearchPath = Lst_New();
     OpenDirs_Init(&openDirs);
-    Hash_InitTable(&mtimes);
-    Hash_InitTable(&lmtimes);
+    HashTable_Init(&mtimes);
+    HashTable_Init(&lmtimes);
 }
 
 void
@@ -409,7 +409,7 @@ Dir_InitDir(const char *cdname)
     dotLast->refCount = 1;
     dotLast->hits = 0;
     dotLast->name = bmake_strdup(".DOTLAST");
-    Hash_InitTable(&dotLast->files);
+    HashTable_Init(&dotLast->files);
 }
 
 /*
@@ -480,7 +480,7 @@ Dir_End(void)
     Dir_ClearPath(dirSearchPath);
     Lst_Free(dirSearchPath);
     OpenDirs_Done(&openDirs);
-    Hash_DeleteTable(&mtimes);
+    HashTable_Done(&mtimes);
 #endif
 }
 
@@ -872,7 +872,7 @@ DirLookup(CachedDir *dir, const char *ba
 
     DIR_DEBUG1("   %s ...\n", dir->name);
 
-    if (Hash_FindEntry(&dir->files, base) == NULL)
+    if (HashTable_FindEntry(&dir->files, base) == NULL)
 	return NULL;
 
     file = str_concat3(dir->name, "/", base);
@@ -925,7 +925,7 @@ DirLookupAbs(CachedDir *dir, const char 
     if (*dnp != '\0' || np != cp - 1)
 	return NULL;
 
-    if (Hash_FindEntry(&dir->files, cp) == NULL) {
+    if (HashTable_FindEntry(&dir->files, cp) == NULL) {
 	DIR_DEBUG0("   must be here but isn't -- returning\n");
 	return bmake_strdup("");	/* to terminate the search */
     }
@@ -942,13 +942,14 @@ static char *
 DirFindDot(const char *name, const char *base)
 {
 
-    if (Hash_FindEntry(&dot->files, base) != NULL) {
+    if (HashTable_FindEntry(&dot->files, base) != NULL) {
 	DIR_DEBUG0("   in '.'\n");
 	hits++;
 	dot->hits++;
 	return bmake_strdup(name);
     }
-    if (cur != NULL && Hash_FindEntry(&cur->files, base) != NULL) {
+
+    if (cur != NULL && HashTable_FindEntry(&cur->files, base) != NULL) {
 	DIR_DEBUG1("   in ${.CURDIR} = %s\n", cur->name);
 	hits++;
 	cur->hits++;
@@ -1423,7 +1424,7 @@ Dir_AddDir(SearchPath *path, const char 
 	dir->name = bmake_strdup(name);
 	dir->hits = 0;
 	dir->refCount = 1;
-	Hash_InitTable(&dir->files);
+	HashTable_Init(&dir->files);
 
 	while ((dp = readdir(d)) != NULL) {
 #if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */
@@ -1436,7 +1437,7 @@ Dir_AddDir(SearchPath *path, const char 
 		continue;
 	    }
 #endif /* sun && d_ino */
-	    (void)Hash_CreateEntry(&dir->files, dp->d_name, NULL);
+	    (void)HashTable_CreateEntry(&dir->files, dp->d_name, NULL);
 	}
 	(void)closedir(d);
 	OpenDirs_Add(&openDirs, dir);
@@ -1530,7 +1531,7 @@ Dir_Destroy(void *dirp)
     if (dir->refCount == 0) {
 	OpenDirs_Remove(&openDirs, dir->name);
 
-	Hash_DeleteTable(&dir->files);
+	HashTable_Done(&dir->files);
 	free(dir->name);
 	free(dir);
     }

Index: src/usr.bin/make/hash.c
diff -u src/usr.bin/make/hash.c:1.53 src/usr.bin/make/hash.c:1.54
--- src/usr.bin/make/hash.c:1.53	Sun Oct 25 18:40:00 2020
+++ src/usr.bin/make/hash.c	Sun Oct 25 19:19:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.53 2020/10/25 18:40:00 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.54 2020/10/25 19:19:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -74,7 +74,7 @@
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.53 2020/10/25 18:40:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.54 2020/10/25 19:19:07 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -123,9 +123,9 @@ HashTable_Find(HashTable *t, unsigned in
 	return e;
 }
 
-/* Sets up the hash table. */
+/* Set up the hash table. */
 void
-Hash_InitTable(HashTable *t)
+HashTable_Init(HashTable *t)
 {
 	unsigned int n = 16, i;
 	HashEntry **buckets = bmake_malloc(sizeof(*buckets) * n);
@@ -139,10 +139,9 @@ Hash_InitTable(HashTable *t)
 	t->maxchain = 0;
 }
 
-/* Removes everything from the hash table and frees up the memory space it
- * occupied (except for the space in the HashTable structure). */
+/* Remove everything from the hash table and frees up the memory. */
 void
-Hash_DeleteTable(HashTable *t)
+HashTable_Done(HashTable *t)
 {
 	HashEntry **buckets = t->buckets;
 	size_t i, n = t->bucketsSize;
@@ -164,41 +163,35 @@ Hash_DeleteTable(HashTable *t)
 	t->buckets = NULL;
 }
 
-/* Searches the hash table for an entry corresponding to the key.
- *
- * Input:
- *	t		Hash table to search.
- *	key		A hash key.
- *
- * Results:
- *	Returns a pointer to the entry for key, or NULL if the table contains
- *	no entry for the key.
- */
+/* Find the entry corresponding to the key, or return NULL. */
 HashEntry *
-Hash_FindEntry(HashTable *t, const char *key)
+HashTable_FindEntry(HashTable *t, const char *key)
 {
 	unsigned int h = hash(key, NULL);
 	return HashTable_Find(t, h, key);
 }
 
+/* Find the value corresponding to the key, or return NULL. */
 void *
-Hash_FindValue(HashTable *t, const char *key)
+HashTable_FindValue(HashTable *t, const char *key)
 {
-	HashEntry *he = Hash_FindEntry(t, key);
+	HashEntry *he = HashTable_FindEntry(t, key);
 	return he != NULL ? he->value : NULL;
 }
 
+/* Find the value corresponding to the key and the precomputed hash,
+ * or return NULL. */
 void *
-Hash_FindValueHash(HashTable *t, const char *key, unsigned int h)
+HashTable_FindValueHash(HashTable *t, const char *key, unsigned int h)
 {
 	HashEntry *he = HashTable_Find(t, h, key);
 	return he != NULL ? he->value : NULL;
 }
 
-/* Makes a new hash table that is larger than the old one. The entire hash
- * table is moved, so any bucket numbers from the old table become invalid. */
+/* Make the hash table larger. Any bucket numbers from the old table become
+ * invalid; the hash codes stay valid though. */
 static void
-RebuildTable(HashTable *t)
+HashTable_Enlarge(HashTable *t)
 {
 	unsigned int oldSize = t->bucketsSize;
 	HashEntry **oldBuckets = t->buckets;
@@ -230,16 +223,10 @@ RebuildTable(HashTable *t)
 	t->maxchain = 0;
 }
 
-/* Searches the hash table for an entry corresponding to the key.
- * If no entry is found, then one is created.
- *
- * Input:
- *	t		Hash table to search.
- *	key		A hash key.
- *	out_isNew	Filled with TRUE if new entry created, FALSE otherwise.
- */
+/* Find or create an entry corresponding to the key.
+ * Return in out_isNew whether a new entry has been created. */
 HashEntry *
-Hash_CreateEntry(HashTable *t, const char *key, Boolean *out_isNew)
+HashTable_CreateEntry(HashTable *t, const char *key, Boolean *out_isNew)
 {
 	size_t keylen;
 	unsigned int h = hash(key, &keylen);
@@ -251,13 +238,8 @@ Hash_CreateEntry(HashTable *t, const cha
 		return he;
 	}
 
-	/*
-	 * The desired entry isn't there.  Before allocating a new entry,
-	 * expand the table if necessary (and this changes the resulting
-	 * bucket chain).
-	 */
 	if (t->numEntries >= rebuildLimit * t->bucketsSize)
-		RebuildTable(t);
+		HashTable_Enlarge(t);
 
 	he = bmake_malloc(sizeof(*he) + keylen);
 	he->value = NULL;
@@ -273,9 +255,9 @@ Hash_CreateEntry(HashTable *t, const cha
 	return he;
 }
 
-/* Delete the given hash table entry and free memory associated with it. */
+/* Delete the entry from the table and free the associated memory. */
 void
-Hash_DeleteEntry(HashTable *t, HashEntry *he)
+HashTable_DeleteEntry(HashTable *t, HashEntry *he)
 {
 	HashEntry **ref = &t->buckets[he->key_hash & t->bucketsMask];
 	HashEntry *p;
@@ -323,7 +305,7 @@ HashIter_Next(HashIter *hi)
 }
 
 void
-Hash_DebugStats(HashTable *t, const char *name)
+HashTable_DebugStats(HashTable *t, const char *name)
 {
 	DEBUG4(HASH, "HashTable %s: size=%u numEntries=%u maxchain=%u\n",
 	       name, t->bucketsSize, t->numEntries, t->maxchain);

Index: src/usr.bin/make/hash.h
diff -u src/usr.bin/make/hash.h:1.30 src/usr.bin/make/hash.h:1.31
--- src/usr.bin/make/hash.h:1.30	Sun Oct 25 17:01:05 2020
+++ src/usr.bin/make/hash.h	Sun Oct 25 19:19:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.h,v 1.30 2020/10/25 17:01:05 rillig Exp $	*/
+/*	$NetBSD: hash.h,v 1.31 2020/10/25 19:19:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -104,29 +104,28 @@ typedef struct HashIter {
 } HashIter;
 
 static inline MAKE_ATTR_UNUSED void *
-Hash_GetValue(HashEntry *h)
+HashEntry_Get(HashEntry *h)
 {
     return h->value;
 }
 
 static inline MAKE_ATTR_UNUSED void
-Hash_SetValue(HashEntry *h, void *datum)
+HashEntry_Set(HashEntry *h, void *datum)
 {
     h->value = datum;
 }
 
-void Hash_InitTable(HashTable *);
-void Hash_DeleteTable(HashTable *);
-HashEntry *Hash_FindEntry(HashTable *, const char *);
-void *Hash_FindValue(HashTable *, const char *);
+void HashTable_Init(HashTable *);
+void HashTable_Done(HashTable *);
+HashEntry *HashTable_FindEntry(HashTable *, const char *);
+void *HashTable_FindValue(HashTable *, const char *);
 unsigned int Hash_Hash(const char *);
-void *Hash_FindValueHash(HashTable *, const char *, unsigned int);
-HashEntry *Hash_CreateEntry(HashTable *, const char *, Boolean *);
-void Hash_DeleteEntry(HashTable *, HashEntry *);
+void *HashTable_FindValueHash(HashTable *, const char *, unsigned int);
+HashEntry *HashTable_CreateEntry(HashTable *, const char *, Boolean *);
+void HashTable_DeleteEntry(HashTable *, HashEntry *);
+void HashTable_DebugStats(HashTable *, const char *);
 
 void HashIter_Init(HashIter *, HashTable *);
 HashEntry *HashIter_Next(HashIter *);
 
-void Hash_DebugStats(HashTable *, const char *);
-
 #endif /* MAKE_HASH_H */

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.389 src/usr.bin/make/main.c:1.390
--- src/usr.bin/make/main.c:1.389	Sun Oct 25 17:37:36 2020
+++ src/usr.bin/make/main.c	Sun Oct 25 19:19:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.389 2020/10/25 17:37:36 sjg Exp $	*/
+/*	$NetBSD: main.c,v 1.390 2020/10/25 19:19:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.389 2020/10/25 17:37:36 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.390 2020/10/25 19:19:07 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -1987,7 +1987,7 @@ purge_cached_realpaths(void)
 	if (he->key[0] != '/') {
 	    if (DEBUG(DIR))
 		fprintf(stderr, "cached_realpath: purging %s\n", he->key);
-	    Hash_DeleteEntry(&cache->context, he);
+	    HashTable_DeleteEntry(&cache->context, he);
 	}
 	he = nhe;
     }

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.122 src/usr.bin/make/targ.c:1.123
--- src/usr.bin/make/targ.c:1.122	Fri Oct 23 19:48:17 2020
+++ src/usr.bin/make/targ.c	Sun Oct 25 19:19:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.122 2020/10/23 19:48:17 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.123 2020/10/25 19:19:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.122 2020/10/23 19:48:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.123 2020/10/25 19:19:07 rillig Exp $");
 
 static GNodeList *allTargets;	/* the list of all targets found so far */
 #ifdef CLEANUP
@@ -137,7 +137,7 @@ void
 Targ_Init(void)
 {
     allTargets = Lst_New();
-    Hash_InitTable(&targets);
+    HashTable_Init(&targets);
 }
 
 void
@@ -148,14 +148,14 @@ Targ_End(void)
     Lst_Free(allTargets);
     if (allGNs != NULL)
 	Lst_Destroy(allGNs, TargFreeGN);
-    Hash_DeleteTable(&targets);
+    HashTable_Done(&targets);
 #endif
 }
 
 void
 Targ_Stats(void)
 {
-    Hash_DebugStats(&targets, "targets");
+    HashTable_DebugStats(&targets, "targets");
 }
 
 /* Return the list of all targets. */
@@ -196,7 +196,7 @@ Targ_NewGN(const char *name)
     gn->children = Lst_New();
     gn->order_pred = Lst_New();
     gn->order_succ = Lst_New();
-    Hash_InitTable(&gn->context);
+    HashTable_Init(&gn->context);
     gn->commands = Lst_New();
     gn->suffix = NULL;
     gn->fname = NULL;
@@ -227,7 +227,7 @@ TargFreeGN(void *gnp)
     Lst_Free(gn->children);
     Lst_Free(gn->order_succ);
     Lst_Free(gn->order_pred);
-    Hash_DeleteTable(&gn->context);
+    HashTable_Done(&gn->context);
     Lst_Free(gn->commands);
 
     /* XXX: does gn->suffix need to be freed? It is reference-counted. */
@@ -240,7 +240,7 @@ TargFreeGN(void *gnp)
 GNode *
 Targ_FindNode(const char *name)
 {
-    return Hash_FindValue(&targets, name);
+    return HashTable_FindValue(&targets, name);
 }
 
 /* Get the existing global node, or create it. */
@@ -248,13 +248,13 @@ GNode *
 Targ_GetNode(const char *name)
 {
     Boolean isNew;
-    HashEntry *he = Hash_CreateEntry(&targets, name, &isNew);
+    HashEntry *he = HashTable_CreateEntry(&targets, name, &isNew);
     if (!isNew)
-	return Hash_GetValue(he);
+	return HashEntry_Get(he);
 
     {
 	GNode *gn = Targ_NewInternalNode(name);
-	Hash_SetValue(he, gn);
+	HashEntry_Set(he, gn);
 	return gn;
     }
 }

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.587 src/usr.bin/make/var.c:1.588
--- src/usr.bin/make/var.c:1.587	Sun Oct 25 19:11:30 2020
+++ src/usr.bin/make/var.c	Sun Oct 25 19:19:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.587 2020/10/25 19:11:30 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.588 2020/10/25 19:19:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include    "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.587 2020/10/25 19:11:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.588 2020/10/25 19:19:07 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -334,7 +334,7 @@ CanonicalVarname(const char *name)
 static Var *
 GNode_FindVar(GNode *ctxt, const char *varname, unsigned int hash)
 {
-    return Hash_FindValueHash(&ctxt->context, varname, hash);
+    return HashTable_FindValueHash(&ctxt->context, varname, hash);
 }
 
 /*-
@@ -440,10 +440,10 @@ VarFreeEnv(Var *v, Boolean destroy)
 static void
 VarAdd(const char *name, const char *val, GNode *ctxt, VarSet_Flags flags)
 {
-    HashEntry *he = Hash_CreateEntry(&ctxt->context, name, NULL);
+    HashEntry *he = HashTable_CreateEntry(&ctxt->context, name, NULL);
     Var *v = VarNew(he->key, NULL, val,
 		    flags & VAR_SET_READONLY ? VAR_READONLY : 0);
-    Hash_SetValue(he, v);
+    HashEntry_Set(he, v);
     if (!(ctxt->flags & INTERNAL)) {
 	VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val);
     }
@@ -461,19 +461,19 @@ Var_Delete(const char *name, GNode *ctxt
 	/* TODO: handle errors */
 	name = name_freeIt;
     }
-    he = Hash_FindEntry(&ctxt->context, name);
+    he = HashTable_FindEntry(&ctxt->context, name);
     VAR_DEBUG3("%s:delete %s%s\n",
 	       ctxt->name, name, he != NULL ? "" : " (not found)");
     free(name_freeIt);
 
     if (he != NULL) {
-	Var *v = Hash_GetValue(he);
+	Var *v = HashEntry_Get(he);
 	if (v->flags & VAR_EXPORTED)
 	    unsetenv(v->name);
 	if (strcmp(v->name, MAKE_EXPORTED) == 0)
 	    var_exportedVars = VAR_EXPORTED_NONE;
 	assert(v->name_freeIt == NULL);
-	Hash_DeleteEntry(&ctxt->context, he);
+	HashTable_DeleteEntry(&ctxt->context, he);
 	Buf_Destroy(&v->val, TRUE);
 	free(v);
     }
@@ -591,7 +591,7 @@ Var_ExportVars(void)
 	/* Ouch! Exporting all variables at once is crazy... */
 	HashIter_Init(&hi, &VAR_GLOBAL->context);
 	while ((he = HashIter_Next(&hi)) != NULL) {
-	    Var *var = Hash_GetValue(he);
+	    Var *var = HashEntry_Get(he);
 	    Var_Export1(var->name, 0);
 	}
 	return;
@@ -954,8 +954,8 @@ Var_Append(const char *name, const char 
 	     * export other variables...)
 	     */
 	    v->flags &= ~(unsigned)VAR_FROM_ENV;
-	    h = Hash_CreateEntry(&ctxt->context, name, NULL);
-	    Hash_SetValue(h, v);
+	    h = HashTable_CreateEntry(&ctxt->context, name, NULL);
+	    HashEntry_Set(h, v);
 	}
     }
     free(name_freeIt);
@@ -3866,7 +3866,7 @@ Var_End(void)
 void
 Var_Stats(void)
 {
-    Hash_DebugStats(&VAR_GLOBAL->context, "VAR_GLOBAL");
+    HashTable_DebugStats(&VAR_GLOBAL->context, "VAR_GLOBAL");
 }
 
 /* Print all variables in a context, sorted by name. */
@@ -3890,7 +3890,7 @@ Var_Dump(GNode *ctxt)
 
     for (i = 0; i < vec.len; i++) {
         const char *varname = varnames[i];
-        Var *var = Hash_FindValue(&ctxt->context, varname);
+        Var *var = HashTable_FindValue(&ctxt->context, varname);
 	debug_printf("%-16s = %s\n", varname, Buf_GetAll(&var->val, NULL));
     }
 

Reply via email to