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): refactor LstNodeNew



details:   https://anonhg.NetBSD.org/src/rev/80570badf053
branches:  trunk
changeset: 941569:80570badf053
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 24 08:56:27 2020 +0000

description:
make(1): refactor LstNodeNew

diffstat:

 usr.bin/make/lst.c |  24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)

diffs (63 lines):

diff -r c960a77e9434 -r 80570badf053 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Sat Oct 24 08:55:23 2020 +0000
+++ b/usr.bin/make/lst.c        Sat Oct 24 08:56:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.83 2020/10/23 04:58:33 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.84 2020/10/24 08:56:27 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -34,16 +34,14 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: lst.c,v 1.83 2020/10/23 04:58:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.84 2020/10/24 08:56:27 rillig Exp $");
 
-/* Allocate and initialize a list node.
- *
- * The fields 'prev' and 'next' must be initialized by the caller.
- */
 static ListNode *
-LstNodeNew(void *datum)
+LstNodeNew(ListNode *prev, ListNode *next, void *datum)
 {
     ListNode *node = bmake_malloc(sizeof *node);
+    node->prev = prev;
+    node->next = next;
     node->datum = datum;
     return node;
 }
@@ -131,9 +129,7 @@
     assert(!LstIsEmpty(list));
     assert(datum != NULL);
 
-    newNode = LstNodeNew(datum);
-    newNode->prev = node->prev;
-    newNode->next = node;
+    newNode = LstNodeNew(node->prev, node, datum);
 
     if (node->prev != NULL) {
        node->prev->next = newNode;
@@ -153,9 +149,7 @@
 
     assert(datum != NULL);
 
-    node = LstNodeNew(datum);
-    node->prev = NULL;
-    node->next = list->first;
+    node = LstNodeNew(NULL, list->first, datum);
 
     if (list->first == NULL) {
        list->first = node;
@@ -174,9 +168,7 @@
 
     assert(datum != NULL);
 
-    node = LstNodeNew(datum);
-    node->prev = list->last;
-    node->next = NULL;
+    node = LstNodeNew(list->last, NULL, datum);
 
     if (list->last == NULL) {
        list->first = node;



Home | Main Index | Thread Index | Old Index