Module Name:    src
Committed By:   rillig
Date:           Sun Oct 25 10:07:23 UTC 2020

Modified Files:
        src/usr.bin/make: lst.c lst.h make.c

Log Message:
make(1): inline Lst_Copy in Make_ExpandUse


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/make/lst.c
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/make/lst.h
cvs rdiff -u -r1.178 -r1.179 src/usr.bin/make/make.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/lst.c
diff -u src/usr.bin/make/lst.c:1.87 src/usr.bin/make/lst.c:1.88
--- src/usr.bin/make/lst.c:1.87	Sat Oct 24 10:36:23 2020
+++ src/usr.bin/make/lst.c	Sun Oct 25 10:07:23 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.87 2020/10/24 10:36:23 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.88 2020/10/25 10:07:23 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -34,7 +34,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: lst.c,v 1.87 2020/10/24 10:36:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.88 2020/10/25 10:07:23 rillig Exp $");
 
 static ListNode *
 LstNodeNew(ListNode *prev, ListNode *next, void *datum)
@@ -58,25 +58,6 @@ Lst_New(void)
     return list;
 }
 
-/* Duplicate an entire list, usually by copying the datum pointers.
- * If copyProc is given, that function is used to create the new datum from the
- * old datum, usually by creating a copy of it. */
-List *
-Lst_Copy(List *list, LstCopyProc copyProc)
-{
-    List *newList;
-    ListNode *node;
-
-    newList = Lst_New();
-
-    for (node = list->first; node != NULL; node = node->next) {
-	void *datum = copyProc != NULL ? copyProc(node->datum) : node->datum;
-	Lst_Append(newList, datum);
-    }
-
-    return newList;
-}
-
 /* Free a list and all its nodes. The node data are not freed though. */
 void
 Lst_Free(List *list)

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.79 src/usr.bin/make/lst.h:1.80
--- src/usr.bin/make/lst.h:1.79	Sat Oct 24 10:36:23 2020
+++ src/usr.bin/make/lst.h	Sun Oct 25 10:07:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.79 2020/10/24 10:36:23 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.80 2020/10/25 10:07:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -102,10 +102,6 @@ struct List {
     ListNode *last;		/* last node in list */
 };
 
-/* Copy a node, usually by allocating a copy of the given object.
- * For reference-counted objects, the original object may need to be
- * modified, therefore the parameter is not const. */
-typedef void *LstCopyProc(void *);
 /* Free the datum of a node, called before freeing the node itself. */
 typedef void LstFreeProc(void *);
 /* An action for Lst_ForEachUntil and Lst_ForEachUntilConcurrent. */
@@ -115,8 +111,6 @@ typedef int LstActionUntilProc(void *dat
 
 /* Create a new list. */
 List *Lst_New(void);
-/* Duplicate an existing list. */
-List *Lst_Copy(List *, LstCopyProc);
 /* Free the list, leaving the node data unmodified. */
 void Lst_Free(List *);
 /* Free the list, freeing the node data using the given function. */

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.178 src/usr.bin/make/make.c:1.179
--- src/usr.bin/make/make.c:1.178	Fri Oct 23 19:48:17 2020
+++ src/usr.bin/make/make.c	Sun Oct 25 10:07:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.178 2020/10/23 19:48:17 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.179 2020/10/25 10:07:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
 #include    "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.178 2020/10/23 19:48:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.179 2020/10/25 10:07:23 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked = 1;
@@ -1126,7 +1126,15 @@ Make_ExpandUse(GNodeList *targs)
 {
     GNodeList *examine;		/* List of targets to examine */
 
-    examine = Lst_Copy(targs, NULL);
+    {
+        /* XXX: Why is it necessary to copy the list? There shouldn't be
+         * any modifications to the list, at least the function name
+         * ExpandUse doesn't suggest that. */
+	GNodeListNode *ln;
+	examine = Lst_New();
+	for (ln = targs->first; ln != NULL; ln = ln->next)
+	    Lst_Append(examine, ln->datum);
+    }
 
     /*
      * Make an initial downward pass over the graph, marking nodes to be made

Reply via email to