Fri Oct 30 16:48:58 2020 UTC ()
make(1): make iterating over HashTable simpler


(rillig)
diff -r1.147 -r1.148 src/usr.bin/make/arch.c
diff -r1.602 -r1.603 src/usr.bin/make/var.c

cvs diff -r1.147 -r1.148 src/usr.bin/make/arch.c (expand / switch to context diff)
--- src/usr.bin/make/arch.c 2020/10/25 19:19:07 1.147
+++ src/usr.bin/make/arch.c 2020/10/30 16:48:58 1.148
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.147 2020/10/25 19:19:07 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.148 2020/10/30 16:48:58 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.147 2020/10/25 19:19:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.148 2020/10/30 16:48:58 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -167,12 +167,11 @@
 {
     Arch *a = ap;
     HashIter hi;
-    HashEntry *he;
 
     /* Free memory from hash entries */
     HashIter_Init(&hi, &a->members);
-    while ((he = HashIter_Next(&hi)) != NULL)
-	free(HashEntry_Get(he));
+    while (HashIter_Next(&hi) != NULL)
+	free(hi.entry->value);
 
     free(a->name);
     free(a->fnametab);

cvs diff -r1.602 -r1.603 src/usr.bin/make/var.c (expand / switch to context diff)
--- src/usr.bin/make/var.c 2020/10/30 16:45:37 1.602
+++ src/usr.bin/make/var.c 2020/10/30 16:48:58 1.603
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.602 2020/10/30 16:45:37 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.603 2020/10/30 16:48:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include    "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.602 2020/10/30 16:45:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.603 2020/10/30 16:48:58 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -602,12 +602,11 @@
 
     if (var_exportedVars == VAR_EXPORTED_ALL) {
 	HashIter hi;
-	HashEntry *he;
 
 	/* Ouch! Exporting all variables at once is crazy... */
 	HashIter_Init(&hi, &VAR_GLOBAL->context);
-	while ((he = HashIter_Next(&hi)) != NULL) {
-	    Var *var = HashEntry_Get(he);
+	while (HashIter_Next(&hi) != NULL) {
+	    Var *var = hi.entry->value;
 	    Var_Export1(var->name, 0);
 	}
 	return;
@@ -3893,15 +3892,14 @@
 {
     Vector /* of const char * */ vec;
     HashIter hi;
-    HashEntry *he;
     size_t i;
     const char **varnames;
 
     Vector_Init(&vec, sizeof(const char *));
 
     HashIter_Init(&hi, &ctxt->context);
-    while ((he = HashIter_Next(&hi)) != NULL)
-	*(const char **)Vector_Push(&vec) = he->key;
+    while (HashIter_Next(&hi) != NULL)
+	*(const char **)Vector_Push(&vec) = hi.entry->key;
     varnames = vec.items;
 
     qsort(varnames, vec.len, sizeof varnames[0], str_cmp_asc);