Module Name:    src
Committed By:   rillig
Date:           Mon Nov 16 21:44:29 UTC 2020

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

Log Message:
make(1): in CLEANUP mode, preallocate list of all GNodes

This makes the code simpler and more uniform.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/usr.bin/make/targ.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/targ.c
diff -u src/usr.bin/make/targ.c:1.129 src/usr.bin/make/targ.c:1.130
--- src/usr.bin/make/targ.c:1.129	Mon Nov 16 21:41:02 2020
+++ src/usr.bin/make/targ.c	Mon Nov 16 21:44:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.129 2020/11/16 21:41:02 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.130 2020/11/16 21:44:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,13 +121,14 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.129 2020/11/16 21:41:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.130 2020/11/16 21:44:29 rillig Exp $");
 
 static GNodeList *allTargets;	/* the list of all targets found so far */
+static HashTable targets;	/* a hash table of same */
+
 #ifdef CLEANUP
 static GNodeList *allGNs;	/* List of all the GNodes */
 #endif
-static HashTable targets;	/* a hash table of same */
 
 #ifdef CLEANUP
 static void GNode_Free(void *);
@@ -138,6 +139,9 @@ Targ_Init(void)
 {
     allTargets = Lst_New();
     HashTable_Init(&targets);
+#ifdef CLEANUP
+    allGNs = Lst_New();
+#endif
 }
 
 void
@@ -146,9 +150,8 @@ Targ_End(void)
     Targ_Stats();
 #ifdef CLEANUP
     Lst_Free(allTargets);
-    if (allGNs != NULL)
-	Lst_Destroy(allGNs, GNode_Free);
     HashTable_Done(&targets);
+    Lst_Destroy(allGNs, GNode_Free);
 #endif
 }
 
@@ -203,8 +206,6 @@ GNode_New(const char *name)
     gn->lineno = 0;
 
 #ifdef CLEANUP
-    if (allGNs == NULL)
-	allGNs = Lst_New();
     Lst_Append(allGNs, gn);
 #endif
 

Reply via email to