Module Name:    src
Committed By:   rillig
Date:           Mon Dec 21 00:30:13 UTC 2020

Modified Files:
        src/usr.bin/make: var.c

Log Message:
make(1): save a few memory allocations in variable expressions


To generate a diff of this commit:
cvs rdiff -u -r1.758 -r1.759 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.758 src/usr.bin/make/var.c:1.759
--- src/usr.bin/make/var.c:1.758	Mon Dec 21 00:20:58 2020
+++ src/usr.bin/make/var.c	Mon Dec 21 00:30:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.758 2020/12/21 00:20:58 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.759 2020/12/21 00:30:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.758 2020/12/21 00:20:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.759 2020/12/21 00:30:13 rillig Exp $");
 
 typedef enum VarFlags {
 	VAR_NONE	= 0,
@@ -2432,7 +2432,7 @@ ApplyModifier_ShellCommand(const char **
 	if (st->eflags & VARE_WANTRES)
 		st->newVal = FStr_InitOwn(Cmd_Exec(cmd, &errfmt));
 	else
-		st->newVal = FStr_InitOwn(bmake_strdup(""));
+		st->newVal = FStr_InitRefer("");
 	if (errfmt != NULL)
 		Error(errfmt, cmd);	/* XXX: why still return AMR_OK? */
 	free(cmd);
@@ -2899,7 +2899,7 @@ ApplyModifier_Words(const char **pp, con
 
 	if (estr[0] == '#' && estr[1] == '\0') { /* Found ":[#]" */
 		if (st->oneBigWord) {
-			st->newVal = FStr_InitOwn(bmake_strdup("1"));
+			st->newVal = FStr_InitRefer("1");
 		} else {
 			Buffer buf;
 
@@ -3177,7 +3177,7 @@ ok:
 		}
 	}
 	free(val);
-	st->newVal = FStr_InitOwn(bmake_strdup(""));
+	st->newVal = FStr_InitRefer("");
 	return AMR_OK;
 }
 
@@ -3303,7 +3303,7 @@ ApplyModifier_SunShell(const char **pp, 
 			if (errfmt != NULL)
 				Error(errfmt, val);
 		} else
-			st->newVal = FStr_InitOwn(bmake_strdup(""));
+			st->newVal = FStr_InitRefer("");
 		*pp = p + 2;
 		return AMR_OK;
 	} else

Reply via email to