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): avoid calls to free(3) in the common c...
details: https://anonhg.NetBSD.org/src/rev/a710b7b06691
branches: trunk
changeset: 936656:a710b7b06691
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Aug 01 09:55:00 2020 +0000
description:
make(1): avoid calls to free(3) in the common case of a NULL pointer
diffstat:
usr.bin/make/arch.c | 14 +++++++-------
usr.bin/make/compat.c | 12 ++++++------
usr.bin/make/cond.c | 8 ++++----
usr.bin/make/job.c | 8 ++++----
usr.bin/make/main.c | 22 +++++++++++-----------
usr.bin/make/make.c | 16 ++++++++--------
usr.bin/make/make_malloc.h | 14 +++++++++++++-
usr.bin/make/meta.c | 16 ++++++++--------
usr.bin/make/parse.c | 16 ++++++++--------
usr.bin/make/suff.c | 8 ++++----
usr.bin/make/trace.c | 10 +++++-----
11 files changed, 78 insertions(+), 66 deletions(-)
diffs (truncated from 543 to 300 lines):
diff -r 3f9d1b0521c1 -r a710b7b06691 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Sat Aug 01 09:51:06 2020 +0000
+++ b/usr.bin/make/arch.c Sat Aug 01 09:55:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.78 2020/07/31 16:26:16 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.79 2020/08/01 09:55:00 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.78 2020/07/31 16:26:16 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.79 2020/08/01 09:55:00 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: arch.c,v 1.78 2020/07/31 16:26:16 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.79 2020/08/01 09:55:00 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1010,8 +1010,8 @@
Var_Value(MEMBER, gn, &p2),
&arh, "r+");
- free(p1);
- free(p2);
+ bmake_free(p1);
+ bmake_free(p2);
snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
@@ -1092,8 +1092,8 @@
Var_Value(MEMBER, gn, &p2),
TRUE);
- free(p1);
- free(p2);
+ bmake_free(p1);
+ bmake_free(p2);
if (arhPtr != NULL) {
modTime = (time_t)strtol(arhPtr->ar_date, NULL, 10);
diff -r 3f9d1b0521c1 -r a710b7b06691 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c Sat Aug 01 09:51:06 2020 +0000
+++ b/usr.bin/make/compat.c Sat Aug 01 09:55:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.116 2020/08/01 09:25:36 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.117 2020/08/01 09:55:00 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.116 2020/08/01 09:25:36 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.117 2020/08/01 09:55:00 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: compat.c,v 1.116 2020/08/01 09:25:36 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.117 2020/08/01 09:55:00 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -133,7 +133,7 @@
Error("*** %s removed", file);
}
- free(p1);
+ bmake_free(p1);
}
}
@@ -548,7 +548,7 @@
if (Lst_Member(gn->iParents, pgn) != NULL) {
char *p1;
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
- free(p1);
+ bmake_free(p1);
}
/*
@@ -652,7 +652,7 @@
if (Lst_Member(gn->iParents, pgn) != NULL) {
char *p1;
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
- free(p1);
+ bmake_free(p1);
}
switch(gn->made) {
case BEINGMADE:
diff -r 3f9d1b0521c1 -r a710b7b06691 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Sat Aug 01 09:51:06 2020 +0000
+++ b/usr.bin/make/cond.c Sat Aug 01 09:55:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.83 2020/08/01 09:30:17 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.84 2020/08/01 09:55:00 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.83 2020/08/01 09:30:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.84 2020/08/01 09:55:00 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: cond.c,v 1.83 2020/08/01 09:30:17 rillig Exp $");
+__RCSID("$NetBSD: cond.c,v 1.84 2020/08/01 09:55:00 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -336,7 +336,7 @@
{
char *freeIt;
Boolean result = Var_Value(arg, VAR_CMD, &freeIt) != NULL;
- free(freeIt);
+ bmake_free(freeIt);
return result;
}
diff -r 3f9d1b0521c1 -r a710b7b06691 usr.bin/make/job.c
--- a/usr.bin/make/job.c Sat Aug 01 09:51:06 2020 +0000
+++ b/usr.bin/make/job.c Sat Aug 01 09:55:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.203 2020/07/28 16:42:22 rillig Exp $ */
+/* $NetBSD: job.c,v 1.204 2020/08/01 09:55:00 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.203 2020/07/28 16:42:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.204 2020/08/01 09:55:00 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: job.c,v 1.203 2020/07/28 16:42:22 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.204 2020/08/01 09:55:00 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1258,7 +1258,7 @@
*/
Make_HandleUse(DEFAULT, gn);
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn);
- free(p1);
+ bmake_free(p1);
} else if (Dir_MTime(gn, 0) == 0 && (gn->type & OP_SPECIAL) == 0) {
/*
* The node wasn't the target of an operator we have no .DEFAULT
diff -r 3f9d1b0521c1 -r a710b7b06691 usr.bin/make/main.c
--- a/usr.bin/make/main.c Sat Aug 01 09:51:06 2020 +0000
+++ b/usr.bin/make/main.c Sat Aug 01 09:55:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.289 2020/08/01 09:25:36 rillig Exp $ */
+/* $NetBSD: main.c,v 1.290 2020/08/01 09:55:00 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.289 2020/08/01 09:25:36 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.290 2020/08/01 09:55:00 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.289 2020/08/01 09:25:36 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.290 2020/08/01 09:55:00 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -765,7 +765,7 @@
char *path_freeIt;
const char *path = Var_Value(var, VAR_CMD, &path_freeIt);
if (path == NULL || path[0] == '\0') {
- free(path_freeIt);
+ bmake_free(path_freeIt);
return FALSE;
}
@@ -778,8 +778,8 @@
(void)Main_SetObjdir("%s%s", xpath, suffix);
- free(xpath_freeIt);
- free(path_freeIt);
+ bmake_free(xpath_freeIt);
+ bmake_free(path_freeIt);
return TRUE;
}
@@ -887,7 +887,7 @@
value = Var_Value(var, VAR_GLOBAL, &p1);
}
printf("%s\n", value ? value : "");
- free(p1);
+ bmake_free(p1);
}
}
@@ -1230,8 +1230,8 @@
(void)strncpy(curdir, pwd, MAXPATHLEN);
}
}
- free(ptmp1);
- free(ptmp2);
+ bmake_free(ptmp1);
+ bmake_free(ptmp2);
}
#endif
Var_Set(".CURDIR", curdir, VAR_GLOBAL);
@@ -1369,7 +1369,7 @@
MakeMode(NULL);
Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL);
- free(p1);
+ bmake_free(p1);
if (!forceJobs && !compatMake &&
Var_Exists(".MAKE.JOBS", VAR_GLOBAL)) {
@@ -1991,7 +1991,7 @@
Var_Set(pathname, rp, cache);
} /* else should we negative-cache? */
- free(cp);
+ bmake_free(cp);
return rp ? resolved : NULL;
}
diff -r 3f9d1b0521c1 -r a710b7b06691 usr.bin/make/make.c
--- a/usr.bin/make/make.c Sat Aug 01 09:51:06 2020 +0000
+++ b/usr.bin/make/make.c Sat Aug 01 09:55:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.102 2020/08/01 09:25:36 rillig Exp $ */
+/* $NetBSD: make.c,v 1.103 2020/08/01 09:55:00 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.102 2020/08/01 09:25:36 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.103 2020/08/01 09:55:00 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: make.c,v 1.102 2020/08/01 09:25:36 rillig Exp $");
+__RCSID("$NetBSD: make.c,v 1.103 2020/08/01 09:55:00 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -691,7 +691,7 @@
checked++;
cname = Var_Value(TARGET, cgn, &p1);
- free(p1);
+ bmake_free(p1);
if (DEBUG(MAKE))
fprintf(debug_file, "Make_Update: %s%s\n", cgn->name, cgn->cohort_num);
@@ -836,7 +836,7 @@
Var_Set(PREFIX, cpref, pgn);
}
}
- free(p1);
+ bmake_free(p1);
Lst_Close(cgn->iParents);
}
}
Home |
Main Index |
Thread Index |
Old Index