Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): refactor Hash_DeleteTable



details:   https://anonhg.NetBSD.org/src/rev/1aa682c4650f
branches:  trunk
changeset: 956293:1aa682c4650f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 25 18:12:35 2020 +0000

description:
make(1): refactor Hash_DeleteTable

diffstat:

 usr.bin/make/hash.c |  18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diffs (40 lines):

diff -r e9afdef1989f -r 1aa682c4650f usr.bin/make/hash.c
--- a/usr.bin/make/hash.c       Sun Oct 25 18:03:59 2020 +0000
+++ b/usr.bin/make/hash.c       Sun Oct 25 18:12:35 2020 +0000
@@ -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 @@
 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);



Home | Main Index | Thread Index | Old Index