Module Name: src
Committed By: rillig
Date: Mon Dec 13 01:00:11 UTC 2021
Modified Files:
src/usr.bin/make: var.c
Log Message:
make: fix memory leak when evaluating ${.SUFFIXES} (since yesterday)
perl -e '
printf(".SUFFIXES: %s\n", "x" x 224);
printf("_:=\${.SUFFIXES}\n" x 100_000);
printf("all:\n");
' \
| MALLOC_CONF=stats_print:true \
./make -r -f - 2>&1 \
| awk '/bins:/,/^ *256/ { print $1 "\t" $4}'
Roughly 100000 less allocations for bin size 16, for the variable name.
To generate a diff of this commit:
cvs rdiff -u -r1.974 -r1.975 src/usr.bin/make/var.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.974 src/usr.bin/make/var.c:1.975
--- src/usr.bin/make/var.c:1.974 Mon Dec 13 00:33:33 2021
+++ src/usr.bin/make/var.c Mon Dec 13 01:00:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.974 2021/12/13 00:33:33 rillig Exp $ */
+/* $NetBSD: var.c,v 1.975 2021/12/13 01:00:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.974 2021/12/13 00:33:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.975 2021/12/13 01:00:10 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -4407,7 +4407,8 @@ ParseVarnameLong(
if (v == NULL && Substring_Equals(name, ".SUFFIXES")) {
char *suffixes = Suff_NamesStr();
- v = VarNew(Substring_Str(name), suffixes, false, true);
+ v = VarNew(FStr_InitRefer(".SUFFIXES"), suffixes,
+ false, true);
free(suffixes);
} else if (v == NULL)
v = FindLocalLegacyVar(name, scope, out_true_extraModifiers);