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 in meta mode
details: https://anonhg.NetBSD.org/src/rev/2119354a999b
branches: trunk
changeset: 957486:2119354a999b
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 29 21:28:06 2020 +0000
description:
make(1): reduce memory allocation in meta mode
diffstat:
usr.bin/make/meta.c | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
diffs (85 lines):
diff -r 5fb94d0c43b1 -r 2119354a999b usr.bin/make/meta.c
--- a/usr.bin/make/meta.c Sun Nov 29 21:27:08 2020 +0000
+++ b/usr.bin/make/meta.c Sun Nov 29 21:28:06 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.154 2020/11/29 09:27:40 rillig Exp $ */
+/* $NetBSD: meta.c,v 1.155 2020/11/29 21:28:06 rillig Exp $ */
/*
* Implement 'meta' mode.
@@ -51,9 +51,9 @@
#endif
static BuildMon Mybm; /* for compat */
-static StringList *metaBailiwick; /* our scope of control */
+static StringList metaBailiwick = LST_INIT; /* our scope of control */
static char *metaBailiwickStr; /* string storage for the list */
-static StringList *metaIgnorePaths; /* paths we deliberately ignore */
+static StringList metaIgnorePaths = LST_INIT; /* paths we deliberately ignore */
static char *metaIgnorePathsStr; /* string storage for the list */
#ifndef MAKE_META_IGNORE_PATHS
@@ -631,21 +631,19 @@
/*
* We consider ourselves master of all within ${.MAKE.META.BAILIWICK}
*/
- metaBailiwick = Lst_New();
(void)Var_Subst("${.MAKE.META.BAILIWICK:O:u:tA}",
VAR_GLOBAL, VARE_WANTRES, &metaBailiwickStr);
/* TODO: handle errors */
- str2Lst_Append(metaBailiwick, metaBailiwickStr);
+ str2Lst_Append(&metaBailiwick, metaBailiwickStr);
/*
* We ignore any paths that start with ${.MAKE.META.IGNORE_PATHS}
*/
- metaIgnorePaths = Lst_New();
Var_Append(MAKE_META_IGNORE_PATHS,
"/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}", VAR_GLOBAL);
(void)Var_Subst("${" MAKE_META_IGNORE_PATHS ":O:u:tA}",
VAR_GLOBAL, VARE_WANTRES, &metaIgnorePathsStr);
/* TODO: handle errors */
- str2Lst_Append(metaIgnorePaths, metaIgnorePathsStr);
+ str2Lst_Append(&metaIgnorePaths, metaIgnorePathsStr);
/*
* We ignore any paths that match ${.MAKE.META.IGNORE_PATTERNS}
@@ -896,11 +894,9 @@
void
meta_finish(void)
{
- if (metaBailiwick != NULL)
- Lst_Free(metaBailiwick);
+ Lst_Done(&metaBailiwick);
free(metaBailiwickStr);
- if (metaIgnorePaths != NULL)
- Lst_Free(metaIgnorePaths);
+ Lst_Done(&metaIgnorePaths);
free(metaIgnorePathsStr);
}
@@ -987,7 +983,7 @@
if (*p == '/') {
cached_realpath(p, fname); /* clean it up */
- if (has_any_prefix(fname, metaIgnorePaths)) {
+ if (has_any_prefix(fname, &metaIgnorePaths)) {
#ifdef DEBUG_META_MODE
DEBUG1(META, "meta_oodate: ignoring path: %s\n", p);
#endif
@@ -1372,14 +1368,14 @@
if (*p != '/')
break;
- if (Lst_IsEmpty(metaBailiwick))
+ if (Lst_IsEmpty(&metaBailiwick))
break;
/* ignore cwd - normal dependencies handle those */
if (strncmp(p, cwd, cwdlen) == 0)
break;
- if (!has_any_prefix(p, metaBailiwick))
+ if (!has_any_prefix(p, &metaBailiwick))
break;
/* tmpdir might be within */
Home |
Main Index |
Thread Index |
Old Index