Module Name:    src
Committed By:   rillig
Date:           Sat Nov 28 19:12:28 UTC 2020

Modified Files:
        src/usr.bin/make: arch.c compat.c job.c make.c make.h parse.c suff.c
            targ.c

Log Message:
make(1): reduce memory allocation for GNode.parents and GNode.children


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/usr.bin/make/arch.c
cvs rdiff -u -r1.193 -r1.194 src/usr.bin/make/compat.c
cvs rdiff -u -r1.332 -r1.333 src/usr.bin/make/job.c
cvs rdiff -u -r1.219 -r1.220 src/usr.bin/make/make.c
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/make/make.h
cvs rdiff -u -r1.454 -r1.455 src/usr.bin/make/parse.c
cvs rdiff -u -r1.309 -r1.310 src/usr.bin/make/suff.c
cvs rdiff -u -r1.142 -r1.143 src/usr.bin/make/targ.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/arch.c
diff -u src/usr.bin/make/arch.c:1.178 src/usr.bin/make/arch.c:1.179
--- src/usr.bin/make/arch.c:1.178	Mon Nov 23 19:02:54 2020
+++ src/usr.bin/make/arch.c	Sat Nov 28 19:12:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.178 2020/11/23 19:02:54 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.179 2020/11/28 19:12: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.178 2020/11/23 19:02:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.179 2020/11/28 19:12:28 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -925,7 +925,7 @@ Arch_UpdateMemberMTime(GNode *gn)
 {
 	GNodeListNode *ln;
 
-	for (ln = gn->parents->first; ln != NULL; ln = ln->next) {
+	for (ln = gn->parents.first; ln != NULL; ln = ln->next) {
 		GNode *pgn = ln->datum;
 
 		if (pgn->type & OP_ARCHV) {
@@ -1021,9 +1021,9 @@ Arch_LibOODate(GNode *gn)
 
 	if (gn->type & OP_PHONY) {
 		oodate = TRUE;
-	} else if (!GNode_IsTarget(gn) && Lst_IsEmpty(gn->children)) {
+	} else if (!GNode_IsTarget(gn) && Lst_IsEmpty(&gn->children)) {
 		oodate = FALSE;
-	} else if ((!Lst_IsEmpty(gn->children) && gn->youngestChild == NULL) ||
+	} else if ((!Lst_IsEmpty(&gn->children) && gn->youngestChild == NULL) ||
 		   (gn->mtime > now) ||
 		   (gn->youngestChild != NULL &&
 		    gn->mtime < gn->youngestChild->mtime)) {

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.193 src/usr.bin/make/compat.c:1.194
--- src/usr.bin/make/compat.c:1.193	Sat Nov 28 18:55:52 2020
+++ src/usr.bin/make/compat.c	Sat Nov 28 19:12:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.193 2020/11/28 18:55:52 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.194 2020/11/28 19:12:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.193 2020/11/28 18:55:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.194 2020/11/28 19:12:28 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -487,7 +487,7 @@ MakeUnmade(GNode *const gn, GNode *const
 	if (!(gn->type & OP_MADE))
 		Suff_FindDeps(gn);
 
-	MakeNodes(gn->children, gn);
+	MakeNodes(&gn->children, gn);
 
 	if (!(gn->flags & REMAKE)) {
 		gn->made = ABORTED;

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.332 src/usr.bin/make/job.c:1.333
--- src/usr.bin/make/job.c:1.332	Sat Nov 28 18:55:52 2020
+++ src/usr.bin/make/job.c	Sat Nov 28 19:12:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.332 2020/11/28 18:55:52 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.333 2020/11/28 19:12:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.332 2020/11/28 18:55:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.333 2020/11/28 19:12:28 rillig Exp $");
 
 /* A shell defines how the commands are run.  All commands for a target are
  * written into a single file, which is then given to the shell to execute
@@ -1177,7 +1177,7 @@ Job_CheckCommands(GNode *gn, void (*abor
 	return TRUE;
     if (!Lst_IsEmpty(&gn->commands))
 	return TRUE;
-    if ((gn->type & OP_LIB) && !Lst_IsEmpty(gn->children))
+    if ((gn->type & OP_LIB) && !Lst_IsEmpty(&gn->children))
 	return TRUE;
 
     /*
@@ -2451,7 +2451,7 @@ int
 Job_Finish(void)
 {
     GNode *endNode = Targ_GetEndNode();
-    if (!Lst_IsEmpty(&endNode->commands) || !Lst_IsEmpty(endNode->children)) {
+    if (!Lst_IsEmpty(&endNode->commands) || !Lst_IsEmpty(&endNode->children)) {
 	if (job_errors != 0) {
 	    Error("Errors reported so .END ignored");
 	} else {

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.219 src/usr.bin/make/make.c:1.220
--- src/usr.bin/make/make.c:1.219	Sat Nov 28 18:55:52 2020
+++ src/usr.bin/make/make.c	Sat Nov 28 19:12:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.219 2020/11/28 18:55:52 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.220 2020/11/28 19:12:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -102,7 +102,7 @@
 #include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.219 2020/11/28 18:55:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.220 2020/11/28 19:12:28 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -329,7 +329,7 @@ GNode_IsOODate(GNode *gn)
      */
     if (!oodate) {
 	GNodeListNode *ln;
-	for (ln = gn->parents->first; ln != NULL; ln = ln->next)
+	for (ln = gn->parents.first; ln != NULL; ln = ln->next)
 	    GNode_UpdateYoungestChild(ln->datum, gn);
     }
 
@@ -341,7 +341,7 @@ PretendAllChildrenAreMade(GNode *pgn)
 {
 	GNodeListNode *ln;
 
-	for (ln = pgn->children->first; ln != NULL; ln = ln->next) {
+	for (ln = pgn->children.first; ln != NULL; ln = ln->next) {
 		GNode *cgn = ln->datum;
 
 		/* This may also update cgn->path. */
@@ -386,7 +386,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
 	}
     }
 
-    for (ln = cgn->children->first; ln != NULL; ln = ln->next) {
+    for (ln = cgn->children.first; ln != NULL; ln = ln->next) {
 	GNode *gn = ln->datum;
 
 	/*
@@ -409,8 +409,8 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
 		gn = tgn;
 	}
 
-	Lst_Append(pgn->children, gn);
-	Lst_Append(gn->parents, pgn);
+	Lst_Append(&pgn->children, gn);
+	Lst_Append(&gn->parents, pgn);
 	pgn->unmade++;
     }
 
@@ -449,7 +449,7 @@ MakeHandleUse(GNode *cgn, GNode *pgn, GN
      * children the parent has. This is used by Make_Run to decide
      * whether to queue the parent or examine its children...
      */
-    Lst_Remove(pgn->children, ln);
+    Lst_Remove(&pgn->children, ln);
     pgn->unmade--;
 }
 
@@ -457,7 +457,7 @@ static void
 HandleUseNodes(GNode *gn)
 {
 	GNodeListNode *ln, *nln;
-	for (ln = gn->children->first; ln != NULL; ln = nln) {
+	for (ln = gn->children.first; ln != NULL; ln = nln) {
 		nln = ln->next;
 		MakeHandleUse(ln->datum, gn, ln);
 	}
@@ -642,7 +642,7 @@ Make_Update(GNode *cgn)
      * which is where all parents are linked.
      */
     if ((centurion = cgn->centurion) != NULL) {
-	if (!Lst_IsEmpty(cgn->parents))
+	if (!Lst_IsEmpty(&cgn->parents))
 		Punt("%s%s: cohort has parents", cgn->name, cgn->cohort_num);
 	centurion->unmade_cohorts--;
 	if (centurion->unmade_cohorts < 0)
@@ -650,7 +650,7 @@ Make_Update(GNode *cgn)
     } else {
 	centurion = cgn;
     }
-    parents = centurion->parents;
+    parents = &centurion->parents;
 
     /* If this was a .ORDER node, schedule the RHS */
     ScheduleOrderSuccessors(centurion);
@@ -751,7 +751,7 @@ UnmarkChildren(GNode *gn)
 {
 	GNodeListNode *ln;
 
-	for (ln = gn->children->first; ln != NULL; ln = ln->next) {
+	for (ln = gn->children.first; ln != NULL; ln = ln->next) {
 		GNode *child = ln->datum;
 		child->type &= ~OP_MARK;
 	}
@@ -846,7 +846,7 @@ Make_DoAllVar(GNode *gn)
 		return;
 
 	UnmarkChildren(gn);
-	for (ln = gn->children->first; ln != NULL; ln = ln->next)
+	for (ln = gn->children.first; ln != NULL; ln = ln->next)
 		MakeAddAllSrc(ln->datum, gn);
 
 	if (!Var_Exists(OODATE, gn))
@@ -964,7 +964,7 @@ MakeStartJobs(void)
 		GNodeListNode *toBeMadeNext = toBeMade->first;
 		GNodeListNode *ln;
 
-		for (ln = gn->children->first; ln != NULL; ln = ln->next)
+		for (ln = gn->children.first; ln != NULL; ln = ln->next)
 		    if (MakeBuildChild(ln->datum, toBeMadeNext) != 0)
 			break;
 	    }
@@ -1086,7 +1086,7 @@ MakePrintStatus(GNode *gn, int *errors)
     if (!(gn->flags & CYCLE)) {
 	/* First time we've seen this node, check all children */
 	gn->flags |= CYCLE;
-	MakePrintStatusList(gn->children, errors);
+	MakePrintStatusList(&gn->children, errors);
 	/* Mark that this node needn't be processed again */
 	gn->flags |= DONECYCLE;
 	return FALSE;
@@ -1100,7 +1100,7 @@ MakePrintStatus(GNode *gn, int *errors)
 	return TRUE;
 
     /* Reporting for our children will give the rest of the loop */
-    MakePrintStatusList(gn->children, errors);
+    MakePrintStatusList(&gn->children, errors);
     return FALSE;
 }
 
@@ -1199,7 +1199,7 @@ Make_ExpandUse(GNodeList *targs)
 	}
 
 	if (gn->unmade != 0)
-	    ExamineLater(examine, gn->children);
+	    ExamineLater(examine, &gn->children);
     }
 
     Lst_Free(examine);
@@ -1217,9 +1217,9 @@ add_wait_dependency(GNodeListNode *owln,
 		    cn->name, cn->cohort_num, wn->name);
 
 		/* XXX: This pattern should be factored out, it repeats often */
-		Lst_Append(wn->children, cn);
+		Lst_Append(&wn->children, cn);
 		wn->unmade++;
-		Lst_Append(cn->parents, wn);
+		Lst_Append(&cn->parents, wn);
 	}
 }
 
@@ -1248,8 +1248,8 @@ Make_ProcessWait(GNodeList *targs)
 	for (ln = targs->first; ln != NULL; ln = ln->next) {
 	    GNode *cgn = ln->datum;
 
-	    Lst_Append(pgn->children, cgn);
-	    Lst_Append(cgn->parents, pgn);
+	    Lst_Append(&pgn->children, cgn);
+	    Lst_Append(&cgn->parents, pgn);
 	    pgn->unmade++;
 	}
     }
@@ -1274,8 +1274,8 @@ Make_ProcessWait(GNodeList *targs)
 	if (pgn->type & OP_DOUBLEDEP)
 	    Lst_PrependAll(examine, pgn->cohorts);
 
-	owln = pgn->children->first;
-	for (ln = pgn->children->first; ln != NULL; ln = ln->next) {
+	owln = pgn->children.first;
+	for (ln = pgn->children.first; ln != NULL; ln = ln->next) {
 	    GNode *cgn = ln->datum;
 	    if (cgn->type & OP_WAIT) {
 		add_wait_dependency(owln, cgn);

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.221 src/usr.bin/make/make.h:1.222
--- src/usr.bin/make/make.h:1.221	Sat Nov 28 18:55:52 2020
+++ src/usr.bin/make/make.h	Sat Nov 28 19:12:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.221 2020/11/28 18:55:52 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.222 2020/11/28 19:12:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -387,9 +387,9 @@ typedef struct GNode {
 
 	/* The nodes that depend on this one, or in other words, the nodes for
 	 * which this is a source. */
-	GNodeList *parents;
+	GNodeList parents;
 	/* The nodes on which this one depends. */
-	GNodeList *children;
+	GNodeList children;
 
 	/* .ORDER nodes we need made. The nodes that must be made (if they're
 	 * made) before this node can be made, but that do not enter into the

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.454 src/usr.bin/make/parse.c:1.455
--- src/usr.bin/make/parse.c:1.454	Sat Nov 28 18:55:52 2020
+++ src/usr.bin/make/parse.c	Sat Nov 28 19:12:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.454 2020/11/28 18:55:52 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.455 2020/11/28 19:12:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.454 2020/11/28 18:55:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.455 2020/11/28 19:12:28 rillig Exp $");
 
 /* types and constants */
 
@@ -761,12 +761,12 @@ LinkSource(GNode *pgn, GNode *cgn, Boole
     if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(pgn->cohorts))
 	pgn = pgn->cohorts->last->datum;
 
-    Lst_Append(pgn->children, cgn);
+    Lst_Append(&pgn->children, cgn);
     pgn->unmade++;
 
     /* Special targets like .END don't need any children. */
     if (!isSpecial)
-	Lst_Append(cgn->parents, pgn);
+	Lst_Append(&cgn->parents, pgn);
 
     if (DEBUG(PARSE)) {
 	debug_printf("# %s: added child %s - %s\n",

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.309 src/usr.bin/make/suff.c:1.310
--- src/usr.bin/make/suff.c:1.309	Sat Nov 28 18:55:52 2020
+++ src/usr.bin/make/suff.c	Sat Nov 28 19:12:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.309 2020/11/28 18:55:52 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.310 2020/11/28 19:12:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.309 2020/11/28 18:55:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.310 2020/11/28 19:12:28 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -569,9 +569,9 @@ Suff_AddTransform(const char *name)
 	 * attached to several different transformations.
 	 */
 	Lst_Done(&gn->commands);
-	Lst_Free(gn->children);
 	Lst_Init(&gn->commands);
-	gn->children = Lst_New();
+	Lst_Done(&gn->children);
+	Lst_Init(&gn->children);
     }
 
     gn->type = OP_TRANSFORM;
@@ -613,7 +613,7 @@ Suff_EndTransform(GNode *gn)
     if (!(gn->type & OP_TRANSFORM))
 	return;
 
-    if (!Lst_IsEmpty(&gn->commands) || !Lst_IsEmpty(gn->children)) {
+    if (!Lst_IsEmpty(&gn->commands) || !Lst_IsEmpty(&gn->children)) {
 	SUFF_DEBUG1("transformation %s complete\n", gn->name);
 	return;
     }
@@ -744,8 +744,8 @@ UpdateTarget(GNode *target, GNode **inou
 	    *inout_main = NULL;
 	    Targ_SetMain(NULL);
 	}
-	Lst_Free(target->children);
-	target->children = Lst_New();
+	Lst_Done(&target->children);
+	Lst_Init(&target->children);
 	target->type = OP_TRANSFORM;
 	/*
 	 * link the two together in the proper relationship and order
@@ -1125,7 +1125,7 @@ FindCmds(Candidate *targ, CandidateSearc
     tgn = targ->node;
     prefLen = strlen(targ->prefix);
 
-    for (gln = tgn->children->first; gln != NULL; gln = gln->next) {
+    for (gln = tgn->children.first; gln != NULL; gln = gln->next) {
 	sgn = gln->datum;
 
 	if (sgn->type & OP_OPTIONAL && Lst_IsEmpty(&tgn->commands)) {
@@ -1204,8 +1204,8 @@ ExpandWildcards(GNodeListNode *cln, GNod
 	gn = Targ_GetNode(cp);
 
 	/* Add gn to the parents child list before the original child */
-	Lst_InsertBefore(pgn->children, cln, gn);
-	Lst_Append(gn->parents, pgn);
+	Lst_InsertBefore(&pgn->children, cln, gn);
+	Lst_Append(&gn->parents, pgn);
 	pgn->unmade++;
     }
 
@@ -1218,8 +1218,8 @@ ExpandWildcards(GNodeListNode *cln, GNod
      * keep it from being processed.
      */
     pgn->unmade--;
-    Lst_Remove(pgn->children, cln);
-    Lst_Remove(cgn->parents, Lst_FindDatum(cgn->parents, pgn));
+    Lst_Remove(&pgn->children, cln);
+    Lst_Remove(&cgn->parents, Lst_FindDatum(&cgn->parents, pgn));
 }
 
 /* Expand the names of any children of a given node that contain variable
@@ -1352,8 +1352,8 @@ ExpandChildren(GNodeListNode *cln, GNode
 
 	    SUFF_DEBUG1("%s...", gn->name);
 	    /* Add gn to the parents child list before the original child */
-	    Lst_InsertBefore(pgn->children, cln, gn);
-	    Lst_Append(gn->parents, pgn);
+	    Lst_InsertBefore(&pgn->children, cln, gn);
+	    Lst_Append(&gn->parents, pgn);
 	    pgn->unmade++;
 	    /* Expand wildcards on new node */
 	    ExpandWildcards(cln->prev, pgn);
@@ -1373,8 +1373,8 @@ ExpandChildren(GNodeListNode *cln, GNode
      * keep it from being processed.
      */
     pgn->unmade--;
-    Lst_Remove(pgn->children, cln);
-    Lst_Remove(cgn->parents, Lst_FindDatum(cgn->parents, pgn));
+    Lst_Remove(&pgn->children, cln);
+    Lst_Remove(&cgn->parents, Lst_FindDatum(&cgn->parents, pgn));
 }
 
 static void
@@ -1382,7 +1382,7 @@ ExpandAllChildren(GNode *gn)
 {
     GNodeListNode *ln, *nln;
 
-    for (ln = gn->children->first; ln != NULL; ln = nln) {
+    for (ln = gn->children.first; ln != NULL; ln = nln) {
 	nln = ln->next;
 	ExpandChildren(ln, gn);
     }
@@ -1447,8 +1447,8 @@ ApplyTransform(GNode *tgn, GNode *sgn, S
     /*
      * Form the proper links between the target and source.
      */
-    Lst_Append(tgn->children, sgn);
-    Lst_Append(sgn->parents, tgn);
+    Lst_Append(&tgn->children, sgn);
+    Lst_Append(&sgn->parents, tgn);
     tgn->unmade++;
 
     /*
@@ -1467,7 +1467,7 @@ ApplyTransform(GNode *tgn, GNode *sgn, S
 		ssuff->name, tsuff->name, tgn->name);
 
     /* Record last child; Make_HandleUse may add child nodes. */
-    ln = tgn->children->last;
+    ln = tgn->children.last;
 
     /* Apply the rule. */
     Make_HandleUse(gn, tgn);
@@ -1568,8 +1568,8 @@ FindDepsArchive(GNode *gn, CandidateSear
     /*
      * Create the link between the two nodes right off
      */
-    Lst_Append(gn->children, mem);
-    Lst_Append(mem->parents, gn);
+    Lst_Append(&gn->children, mem);
+    Lst_Append(&mem->parents, gn);
     gn->unmade++;
 
     /*
@@ -1864,7 +1864,7 @@ FindDepsRegular(GNode *gn, CandidateSear
      */
     {
 	GNodeListNode *ln, *nln;
-	for (ln = gn->children->first; ln != NULL; ln = nln) {
+	for (ln = gn->children.first; ln != NULL; ln = nln) {
 	    nln = ln->next;
 	    ExpandChildren(ln, gn);
 	}
@@ -1888,7 +1888,7 @@ sfnd_abort:
     /*
      * Check for overriding transformation rule implied by sources
      */
-    if (!Lst_IsEmpty(gn->children)) {
+    if (!Lst_IsEmpty(&gn->children)) {
 	src = FindCmds(targ, cs);
 
 	if (src != NULL) {

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.142 src/usr.bin/make/targ.c:1.143
--- src/usr.bin/make/targ.c:1.142	Sat Nov 28 18:55:52 2020
+++ src/usr.bin/make/targ.c	Sat Nov 28 19:12:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.142 2020/11/28 18:55:52 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.143 2020/11/28 19:12:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -119,7 +119,7 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.142 2020/11/28 18:55:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.143 2020/11/28 19:12:28 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -202,8 +202,8 @@ GNode_New(const char *name)
     gn->mtime = 0;
     gn->youngestChild = NULL;
     gn->implicitParents = Lst_New();
-    gn->parents = Lst_New();
-    gn->children = Lst_New();
+    Lst_Init(&gn->parents);
+    Lst_Init(&gn->children);
     gn->order_pred = Lst_New();
     gn->order_succ = Lst_New();
     gn->cohorts = Lst_New();
@@ -235,8 +235,8 @@ GNode_Free(void *gnp)
     free(gn->path);
     /* gn->youngestChild is not owned by this node. */
     Lst_Free(gn->implicitParents); /* Do not free the nodes themselves, */
-    Lst_Free(gn->parents);	/* as they are not owned by this node. */
-    Lst_Free(gn->children);	/* likewise */
+    Lst_Done(&gn->parents);	/* as they are not owned by this node. */
+    Lst_Done(&gn->children);	/* likewise */
     Lst_Free(gn->order_pred);	/* likewise */
     Lst_Free(gn->order_succ);	/* likewise */
     Lst_Free(gn->cohorts);	/* likewise */
@@ -508,13 +508,13 @@ Targ_PrintNode(GNode *gn, int pass)
 	    if (gn->unmade)
 		debug_printf("# %d unmade children\n", gn->unmade);
 	}
-	PrintNodeNamesLine("parents", gn->parents);
+	PrintNodeNamesLine("parents", &gn->parents);
 	PrintNodeNamesLine("order_pred", gn->order_pred);
 	PrintNodeNamesLine("order_succ", gn->order_succ);
 
 	debug_printf("%-16s%s", gn->name, GNode_OpName(gn));
 	Targ_PrintType(gn->type);
-	PrintNodeNames(gn->children);
+	PrintNodeNames(&gn->children);
 	debug_printf("\n");
 	Targ_PrintCmds(gn);
 	debug_printf("\n\n");

Reply via email to