Module Name:    src
Committed By:   rillig
Date:           Sun Oct 25 18:12:35 UTC 2020

Modified Files:
        src/usr.bin/make: hash.c

Log Message:
make(1): refactor Hash_DeleteTable


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/make/hash.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/hash.c
diff -u src/usr.bin/make/hash.c:1.50 src/usr.bin/make/hash.c:1.51
--- src/usr.bin/make/hash.c:1.50	Sun Oct 25 18:03:59 2020
+++ src/usr.bin/make/hash.c	Sun Oct 25 18:12:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.50 2020/10/25 18:03:59 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.51 2020/10/25 18:12:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -79,7 +79,7 @@
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.50 2020/10/25 18:03:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.51 2020/10/25 18:12:35 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -149,13 +149,15 @@ Hash_InitTable(HashTable *t)
 void
 Hash_DeleteTable(HashTable *t)
 {
-	HashEntry **hp, *h, *nexth = NULL;
-	int i;
+	HashEntry **buckets = t->buckets;
+	size_t i, n = t->bucketsSize;
 
-	for (hp = t->buckets, i = (int)t->bucketsSize; --i >= 0;) {
-		for (h = *hp++; h != NULL; h = nexth) {
-			nexth = h->next;
-			free(h);
+	for (i = 0; i < n; i++) {
+		HashEntry *he = buckets[i];
+		while (he != NULL) {
+			HashEntry *next = he->next;
+			free(he);
+			he = next;
 		}
 	}
 	free(t->buckets);

Reply via email to