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 Arch_Parse...
details: https://anonhg.NetBSD.org/src/rev/8623559adbaf
branches: trunk
changeset: 957448:8623559adbaf
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Nov 28 23:13:28 2020 +0000
description:
make(1): reduce memory allocation in Arch_ParseArchive
diffstat:
usr.bin/make/arch.c | 14 +++++++-------
usr.bin/make/lst.h | 4 +++-
2 files changed, 10 insertions(+), 8 deletions(-)
diffs (61 lines):
diff -r a5cfa261c2f3 -r 8623559adbaf usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Sat Nov 28 22:59:53 2020 +0000
+++ b/usr.bin/make/arch.c Sat Nov 28 23:13:28 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.180 2020/11/28 19:26:10 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.181 2020/11/28 23:13:28 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -125,7 +125,7 @@
#include "config.h"
/* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: arch.c,v 1.180 2020/11/28 19:26:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.181 2020/11/28 23:13:28 rillig Exp $");
typedef struct List ArchList;
typedef struct ListNode ArchListNode;
@@ -344,11 +344,11 @@
free(buf);
} else if (Dir_HasWildcards(memName)) {
- StringList *members = Lst_New();
- Dir_Expand(memName, dirSearchPath, members);
+ StringList members = LST_INIT;
+ Dir_Expand(memName, dirSearchPath, &members);
- while (!Lst_IsEmpty(members)) {
- char *member = Lst_Dequeue(members);
+ while (!Lst_IsEmpty(&members)) {
+ char *member = Lst_Dequeue(&members);
char *fullname = str_concat4(libName, "(",
member, ")");
free(member);
@@ -359,7 +359,7 @@
gn->type |= OP_ARCHV;
Lst_Append(nodeLst, gn);
}
- Lst_Free(members);
+ Lst_Done(&members);
} else {
char *fullname = str_concat4(libName, "(", memName,
diff -r a5cfa261c2f3 -r 8623559adbaf usr.bin/make/lst.h
--- a/usr.bin/make/lst.h Sat Nov 28 22:59:53 2020 +0000
+++ b/usr.bin/make/lst.h Sat Nov 28 23:13:28 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.h,v 1.89 2020/11/28 19:26:10 rillig Exp $ */
+/* $NetBSD: lst.h,v 1.90 2020/11/28 23:13:28 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -118,6 +118,8 @@
/* Free the list, freeing the node data using the given function. */
void Lst_Destroy(List *, LstFreeProc);
+#define LST_INIT { NULL, NULL }
+
/* Initialize a list, without memory allocation. */
MAKE_INLINE void
Lst_Init(List *list)
Home |
Main Index |
Thread Index |
Old Index