Module Name:    src
Committed By:   rillig
Date:           Sat Nov 28 23:39:58 UTC 2020

Modified Files:
        src/usr.bin/make: cond.c main.c make.h parse.c

Log Message:
make(1): reduce memory allocation for CmdOpts.create


To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.219 src/usr.bin/make/cond.c
cvs rdiff -u -r1.485 -r1.486 src/usr.bin/make/main.c
cvs rdiff -u -r1.227 -r1.228 src/usr.bin/make/make.h
cvs rdiff -u -r1.459 -r1.460 src/usr.bin/make/parse.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/cond.c
diff -u src/usr.bin/make/cond.c:1.218 src/usr.bin/make/cond.c:1.219
--- src/usr.bin/make/cond.c:1.218	Sat Nov 28 18:55:52 2020
+++ src/usr.bin/make/cond.c	Sat Nov 28 23:39:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.218 2020/11/28 18:55:52 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.219 2020/11/28 23:39:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -94,7 +94,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.218 2020/11/28 18:55:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.219 2020/11/28 23:39:58 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -300,7 +300,7 @@ FuncMake(size_t argLen MAKE_ATTR_UNUSED,
 {
 	StringListNode *ln;
 
-	for (ln = opts.create->first; ln != NULL; ln = ln->next)
+	for (ln = opts.create.first; ln != NULL; ln = ln->next)
 		if (Str_Match(ln->datum, arg))
 			return TRUE;
 	return FALSE;

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.485 src/usr.bin/make/main.c:1.486
--- src/usr.bin/make/main.c:1.485	Sat Nov 28 23:35:44 2020
+++ src/usr.bin/make/main.c	Sat Nov 28 23:39:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.485 2020/11/28 23:35:44 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.486 2020/11/28 23:39:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.485 2020/11/28 23:35:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.486 2020/11/28 23:39:58 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -664,7 +664,7 @@ rearg:
 				Punt("illegal (null) argument.");
 			if (argv[1][0] == '-' && !dashDash)
 				goto rearg;
-			Lst_Append(opts.create, bmake_strdup(argv[1]));
+			Lst_Append(&opts.create, bmake_strdup(argv[1]));
 		}
 	}
 
@@ -922,10 +922,10 @@ runTargets(void)
 	 * we consult the parsing module to find the main target(s)
 	 * to create.
 	 */
-	if (Lst_IsEmpty(opts.create))
+	if (Lst_IsEmpty(&opts.create))
 		targs = Parse_MainName();
 	else
-		targs = Targ_FindList(opts.create);
+		targs = Targ_FindList(&opts.create);
 
 	if (!opts.compatMake) {
 		/*
@@ -964,12 +964,12 @@ InitVarTargets(void)
 {
 	StringListNode *ln;
 
-	if (Lst_IsEmpty(opts.create)) {
+	if (Lst_IsEmpty(&opts.create)) {
 		Var_Set(".TARGETS", "", VAR_GLOBAL);
 		return;
 	}
 
-	for (ln = opts.create->first; ln != NULL; ln = ln->next) {
+	for (ln = opts.create.first; ln != NULL; ln = ln->next) {
 		char *name = ln->datum;
 		Var_Append(".TARGETS", name, VAR_GLOBAL);
 	}
@@ -1141,7 +1141,7 @@ CmdOpts_Init(void)
 	opts.parseWarnFatal = FALSE;
 	opts.enterFlag = FALSE;
 	opts.varNoExportEnv = FALSE;
-	opts.create = Lst_New();
+	Lst_Init(&opts.create);
 }
 
 /* Initialize MAKE and .MAKE to the path of the executable, so that it can be
@@ -1627,7 +1627,7 @@ main_CleanUp(void)
 	 * used in GNodes.
 	 */
 	Lst_Done(&opts.makefiles);
-	Lst_Destroy(opts.create, free);
+	Lst_Destroy(&opts.create, free);
 #endif
 
 	/* print the graph now it's been processed if the user requested it */

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.227 src/usr.bin/make/make.h:1.228
--- src/usr.bin/make/make.h:1.227	Sat Nov 28 23:35:44 2020
+++ src/usr.bin/make/make.h	Sat Nov 28 23:39:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.227 2020/11/28 23:35:44 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.228 2020/11/28 23:39:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -685,7 +685,7 @@ typedef struct CmdOpts {
 
 	/* The target names specified on the command line.
 	 * Used to resolve .if make(...) statements. */
-	StringList *create;
+	StringList create;
 
 } CmdOpts;
 

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.459 src/usr.bin/make/parse.c:1.460
--- src/usr.bin/make/parse.c:1.459	Sat Nov 28 22:56:01 2020
+++ src/usr.bin/make/parse.c	Sat Nov 28 23:39:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.459 2020/11/28 22:56:01 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.460 2020/11/28 23:39:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.459 2020/11/28 22:56:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.460 2020/11/28 23:39:58 rillig Exp $");
 
 /* types and constants */
 
@@ -907,7 +907,7 @@ ParseDoSrcMain(const char *src)
      * See ParseDoDependencyTargetSpecial, branch SP_MAIN.
      * See unit-tests/cond-func-make-main.mk.
      */
-    Lst_Append(opts.create, bmake_strdup(src));
+    Lst_Append(&opts.create, bmake_strdup(src));
     /*
      * Add the name to the .TARGETS variable as well, so the user can
      * employ that, if desired.
@@ -1091,7 +1091,7 @@ ParseDoDependencyTargetSpecial(ParseSpec
 	break;
     case SP_MAIN:
 	/* Allow targets from the command line to override the .MAIN node. */
-	if (!Lst_IsEmpty(opts.create))
+	if (!Lst_IsEmpty(&opts.create))
 	    *inout_specType = SP_NOT;
 	break;
     case SP_BEGIN:

Reply via email to