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): make memory allocation simpler in meta...



details:   https://anonhg.NetBSD.org/src/rev/f41231c27de0
branches:  trunk
changeset: 941826:f41231c27de0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 31 12:04:24 2020 +0000

description:
make(1): make memory allocation simpler in meta_create and meta_oodate

Since there is only a single variable left that needs to be freed at the
end (and probably never actually needs to be freed since nobody defines
an environment variable named .OBJDIR), there is no need to loop over
these variables.

diffstat:

 usr.bin/make/meta.c |  23 +++++++----------------
 1 files changed, 7 insertions(+), 16 deletions(-)

diffs (66 lines):

diff -r 3f7f19abab30 -r f41231c27de0 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sat Oct 31 11:54:33 2020 +0000
+++ b/usr.bin/make/meta.c       Sat Oct 31 12:04:24 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.135 2020/10/31 11:54:33 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.136 2020/10/31 12:04:24 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -474,13 +474,11 @@
     const char *tname;
     char *fname;
     const char *cp;
-    void *p[5];                                /* >= possible uses */
-    int i;
+    void *objdir_freeIt;
 
     mf.fp = NULL;
-    i = 0;
 
-    dname = Var_Value(".OBJDIR", gn, &p[i++]);
+    dname = Var_Value(".OBJDIR", gn, &objdir_freeIt);
     tname = GNode_VarTarget(gn);
 
     /* if this succeeds objdir is realpath of dname */
@@ -549,9 +547,7 @@
            gn->type |= OP_SILENT;
     }
  out:
-    for (i--; i >= 0; i--) {
-       bmake_free(p[i]);
-    }
+    bmake_free(objdir_freeIt);
 
     return mf.fp;
 }
@@ -1090,16 +1086,13 @@
     FILE *fp;
     Boolean needOODATE = FALSE;
     StringList *missingFiles;
-    void *pa[4];                       /* >= possible uses */
-    int i;
     int have_filemon = FALSE;
+    void *objdir_freeIt;
 
     if (oodate)
        return oodate;          /* we're done */
 
-    i = 0;
-
-    dname = Var_Value(".OBJDIR", gn, &pa[i++]);
+    dname = Var_Value(".OBJDIR", gn, &objdir_freeIt);
     tname = GNode_VarTarget(gn);
 
     /* if this succeeds fname3 is realpath of dname */
@@ -1612,9 +1605,7 @@
     }
 
  oodate_out:
-    for (i--; i >= 0; i--) {
-       bmake_free(pa[i]);
-    }
+    bmake_free(objdir_freeIt);
     return oodate;
 }
 



Home | Main Index | Thread Index | Old Index