Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make str2Lst_Append tokenizes the string and uses it...



details:   https://anonhg.NetBSD.org/src/rev/896bcecbb5ab
branches:  trunk
changeset: 814116:896bcecbb5ab
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Mar 07 21:45:43 2016 +0000

description:
str2Lst_Append tokenizes the string and uses it in the list so we can't
free the string afterwards. Keep a copy of it and cleanup at the end.

diffstat:

 usr.bin/make/main.c |   9 ++++++---
 usr.bin/make/meta.c |  29 +++++++++++++++++++----------
 usr.bin/make/meta.h |   3 ++-
 3 files changed, 27 insertions(+), 14 deletions(-)

diffs (122 lines):

diff -r 096c0d85e4f3 -r 896bcecbb5ab usr.bin/make/main.c
--- a/usr.bin/make/main.c       Mon Mar 07 20:20:35 2016 +0000
+++ b/usr.bin/make/main.c       Mon Mar 07 21:45:43 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.241 2016/02/19 00:11:45 sjg Exp $   */
+/*     $NetBSD: main.c,v 1.242 2016/03/07 21:45:43 christos Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.241 2016/02/19 00:11:45 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.242 2016/03/07 21:45:43 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.241 2016/02/19 00:11:45 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.242 2016/03/07 21:45:43 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1381,6 +1381,9 @@
        if (enterFlag)
                printf("%s: Leaving directory `%s'\n", progname, curdir);
 
+#ifdef USE_META
+       meta_finish();
+#endif
        Suff_End();
         Targ_End();
        Arch_End();
diff -r 096c0d85e4f3 -r 896bcecbb5ab usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Mon Mar 07 20:20:35 2016 +0000
+++ b/usr.bin/make/meta.c       Mon Mar 07 21:45:43 2016 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.52 2016/02/27 16:20:06 christos Exp $ */
+/*      $NetBSD: meta.c,v 1.53 2016/03/07 21:45:43 christos Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -55,7 +55,9 @@
 
 static BuildMon Mybm;                  /* for compat */
 static Lst metaBailiwick;              /* our scope of control */
+static char *metaBailiwickStr;         /* string storage for the list */
 static Lst metaIgnorePaths;            /* paths we deliberately ignore */
+static char *metaIgnorePathsStr;       /* string storage for the list */
 
 #ifndef MAKE_META_IGNORE_PATHS
 #define MAKE_META_IGNORE_PATHS ".MAKE.META.IGNORE_PATHS"
@@ -597,25 +599,23 @@
      * We consider ourselves master of all within ${.MAKE.META.BAILIWICK}
      */
     metaBailiwick = Lst_Init(FALSE);
-    cp = Var_Subst(NULL, "${.MAKE.META.BAILIWICK:O:u:tA}", VAR_GLOBAL,
-                  VARF_WANTRES);
-    if (cp) {
-       str2Lst_Append(metaBailiwick, cp, NULL);
+    metaBailiwickStr = Var_Subst(NULL, "${.MAKE.META.BAILIWICK:O:u:tA}",
+       VAR_GLOBAL, VARF_WANTRES);
+    if (metaBailiwickStr) {
+       str2Lst_Append(metaBailiwick, metaBailiwickStr, NULL);
     }
-    free(cp);
     /*
      * We ignore any paths that start with ${.MAKE.META.IGNORE_PATHS}
      */
     metaIgnorePaths = Lst_Init(FALSE);
     Var_Append(MAKE_META_IGNORE_PATHS,
               "/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}", VAR_GLOBAL);
-    cp = Var_Subst(NULL,
+    metaIgnorePathsStr = Var_Subst(NULL,
                   "${" MAKE_META_IGNORE_PATHS ":O:u:tA}", VAR_GLOBAL,
                   VARF_WANTRES);
-    if (cp) {
-       str2Lst_Append(metaIgnorePaths, cp, NULL);
+    if (metaIgnorePathsStr) {
+       str2Lst_Append(metaIgnorePaths, metaIgnorePathsStr, NULL);
     }
-    free(cp);
 }
 
 /*
@@ -775,6 +775,15 @@
     }
 }
 
+void
+meta_finish(void)
+{
+    Lst_Destroy(metaBailiwick, NULL);
+    free(metaBailiwickStr);
+    Lst_Destroy(metaIgnorePaths, NULL);
+    free(metaIgnorePathsStr);
+}
+
 /*
  * Fetch a full line from fp - growing bufp if needed
  * Return length in bufp.
diff -r 096c0d85e4f3 -r 896bcecbb5ab usr.bin/make/meta.h
--- a/usr.bin/make/meta.h       Mon Mar 07 20:20:35 2016 +0000
+++ b/usr.bin/make/meta.h       Mon Mar 07 21:45:43 2016 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.h,v 1.3 2013/03/23 05:31:29 sjg Exp $ */
+/*      $NetBSD: meta.h,v 1.4 2016/03/07 21:45:43 christos Exp $ */
 
 /*
  * Things needed for 'meta' mode.
@@ -42,6 +42,7 @@
 
 struct Job;                            /* not defined yet */
 void meta_init(void);
+void meta_finish(void);
 void meta_mode_init(const char *);
 void meta_job_start(struct Job *, GNode *);
 void meta_job_child(struct Job *);



Home | Main Index | Thread Index | Old Index