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.
This commit is contained in:
christos 2016-03-07 21:45:43 +00:00
parent ab15168ea5
commit e46a288cba
3 changed files with 27 additions and 14 deletions

View File

@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#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 @@ main(int argc, char **argv)
if (enterFlag)
printf("%s: Leaving directory `%s'\n", progname, curdir);
#ifdef USE_META
meta_finish();
#endif
Suff_End();
Targ_End();
Arch_End();

View File

@ -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 @@ meta_mode_init(const char *make_mode)
* 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 @@ meta_job_finish(Job *job)
}
}
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.

View File

@ -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 @@ extern Boolean useMeta;
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 *);