make: remove bmake_free

It was only used in 2 places, and in both these places, the pointer was
never null.
This commit is contained in:
rillig 2021-12-15 11:01:39 +00:00
parent d9ab151b25
commit c8c1f26895
2 changed files with 5 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.544 2021/12/15 10:57:01 rillig Exp $ */
/* $NetBSD: main.c,v 1.545 2021/12/15 11:01:39 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -111,7 +111,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: main.c,v 1.544 2021/12/15 10:57:01 rillig Exp $");
MAKE_RCSID("$NetBSD: main.c,v 1.545 2021/12/15 11:01:39 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@ -843,7 +843,7 @@ PrintVar(const char *varname, bool expandVars)
(void)Var_Subst(varname, SCOPE_GLOBAL, VARE_WANTRES, &evalue);
/* TODO: handle errors */
printf("%s\n", evalue);
bmake_free(evalue);
free(evalue);
} else if (expandVars) {
char *expr = str_concat3("${", varname, "}");
@ -852,7 +852,7 @@ PrintVar(const char *varname, bool expandVars)
/* TODO: handle errors */
free(expr);
printf("%s\n", evalue);
bmake_free(evalue);
free(evalue);
} else {
FStr value = Var_Value(SCOPE_GLOBAL, varname);

View File

@ -1,4 +1,4 @@
/* $NetBSD: make_malloc.h,v 1.17 2021/12/15 09:53:41 rillig Exp $ */
/* $NetBSD: make_malloc.h,v 1.18 2021/12/15 11:01:39 rillig Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -40,17 +40,3 @@ char *bmake_strldup(const char *, size_t) MAKE_ATTR_USE;
#endif
char *bmake_strsedup(const char *, const char *) MAKE_ATTR_USE;
/*
* Thin wrapper around free(3) to avoid the extra function call in case
* p is NULL, to save a few machine instructions.
*
* The case of a NULL pointer happens especially often after Var_Value,
* since only environment variables need to be freed, but not others.
*/
MAKE_INLINE void
bmake_free(void *p)
{
if (p != NULL)
free(p);
}