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/0b7d0ff1cf37
branches:  trunk
changeset: 977517:0b7d0ff1cf37
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 c6cdd5e7aff7 -r 0b7d0ff1cf37 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