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): reduce memory allocation for CmdOpts.c...



details:   https://anonhg.NetBSD.org/src/rev/6b899129e3ee
branches:  trunk
changeset: 946482:6b899129e3ee
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 28 23:39:58 2020 +0000

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

diffstat:

 usr.bin/make/cond.c  |   6 +++---
 usr.bin/make/main.c  |  18 +++++++++---------
 usr.bin/make/make.h  |   4 ++--
 usr.bin/make/parse.c |   8 ++++----
 4 files changed, 18 insertions(+), 18 deletions(-)

diffs (154 lines):

diff -r b574ec5628d2 -r 6b899129e3ee usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Sat Nov 28 23:35:44 2020 +0000
+++ b/usr.bin/make/cond.c       Sat Nov 28 23:39:58 2020 +0000
@@ -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 @@
 {
        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;
diff -r b574ec5628d2 -r 6b899129e3ee usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Nov 28 23:35:44 2020 +0000
+++ b/usr.bin/make/main.c       Sat Nov 28 23:39:58 2020 +0000
@@ -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 @@
                                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 @@
         * 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 @@
 {
        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 @@
        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 @@
         * 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 */
diff -r b574ec5628d2 -r 6b899129e3ee usr.bin/make/make.h
--- a/usr.bin/make/make.h       Sat Nov 28 23:35:44 2020 +0000
+++ b/usr.bin/make/make.h       Sat Nov 28 23:39:58 2020 +0000
@@ -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 @@
 
        /* The target names specified on the command line.
         * Used to resolve .if make(...) statements. */
-       StringList *create;
+       StringList create;
 
 } CmdOpts;
 
diff -r b574ec5628d2 -r 6b899129e3ee usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Nov 28 23:35:44 2020 +0000
+++ b/usr.bin/make/parse.c      Sat Nov 28 23:39:58 2020 +0000
@@ -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 @@
      * 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 @@
        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:



Home | Main Index | Thread Index | Old Index