Module Name:    src
Committed By:   rillig
Date:           Sun Nov 29 01:16:38 UTC 2020

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

Log Message:
make(1): reduce memory allocation in ExpandChildren for suffixes


To generate a diff of this commit:
cvs rdiff -u -r1.318 -r1.319 src/usr.bin/make/suff.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/suff.c
diff -u src/usr.bin/make/suff.c:1.318 src/usr.bin/make/suff.c:1.319
--- src/usr.bin/make/suff.c:1.318	Sun Nov 29 01:12:45 2020
+++ src/usr.bin/make/suff.c	Sun Nov 29 01:16:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.318 2020/11/29 01:12:45 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.319 2020/11/29 01:16:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.318 2020/11/29 01:12:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.319 2020/11/29 01:16:37 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -1263,7 +1263,7 @@ ExpandChildren(GNodeListNode *cln, GNode
     /* TODO: handle errors */
 
     {
-	GNodeList *members = Lst_New();
+	GNodeList members = LST_INIT;
 
 	if (cgn->type & OP_ARCHV) {
 	    /*
@@ -1273,7 +1273,7 @@ ExpandChildren(GNodeListNode *cln, GNode
 	     */
 	    char *sacrifice = cp;
 
-	    (void)Arch_ParseArchive(&sacrifice, members, pgn);
+	    (void)Arch_ParseArchive(&sacrifice, &members, pgn);
 	} else {
 	    /*
 	     * Break the result into a vector of strings whose nodes
@@ -1296,7 +1296,7 @@ ExpandChildren(GNodeListNode *cln, GNode
 		     */
 		    *cp++ = '\0';
 		    gn = Targ_GetNode(start);
-		    Lst_Append(members, gn);
+		    Lst_Append(&members, gn);
 		    pp_skip_hspace(&cp);
 		    start = cp;		/* Continue at the next non-space. */
 		} else if (*cp == '$') {
@@ -1335,7 +1335,7 @@ ExpandChildren(GNodeListNode *cln, GNode
 		 * Stuff left over -- add it to the list too
 		 */
 		gn = Targ_GetNode(start);
-		Lst_Append(members, gn);
+		Lst_Append(&members, gn);
 	    }
 	    /*
 	     * Point cp back at the beginning again so the variable value
@@ -1347,8 +1347,8 @@ ExpandChildren(GNodeListNode *cln, GNode
 	/*
 	 * Add all elements of the members list to the parent node.
 	 */
-	while(!Lst_IsEmpty(members)) {
-	    gn = Lst_Dequeue(members);
+	while(!Lst_IsEmpty(&members)) {
+	    gn = Lst_Dequeue(&members);
 
 	    SUFF_DEBUG1("%s...", gn->name);
 	    /* Add gn to the parents child list before the original child */
@@ -1358,7 +1358,7 @@ ExpandChildren(GNodeListNode *cln, GNode
 	    /* Expand wildcards on new node */
 	    ExpandWildcards(cln->prev, pgn);
 	}
-	Lst_Free(members);
+	Lst_Done(&members);
 
 	/*
 	 * Free the result

Reply via email to