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): move reference counting for suffixes t...



details:   https://anonhg.NetBSD.org/src/rev/73ddd5c92da5
branches:  trunk
changeset: 957185:73ddd5c92da5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 21 13:16:37 2020 +0000

description:
make(1): move reference counting for suffixes to SrcNew

diffstat:

 usr.bin/make/suff.c |  17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diffs (73 lines):

diff -r 770cf3cdc49a -r 73ddd5c92da5 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Sat Nov 21 13:11:13 2020 +0000
+++ b/usr.bin/make/suff.c       Sat Nov 21 13:16:37 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.259 2020/11/21 13:11:13 rillig Exp $        */
+/*     $NetBSD: suff.c,v 1.260 2020/11/21 13:16:37 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.259 2020/11/21 13:11:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.260 2020/11/21 13:16:37 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -203,6 +203,13 @@
 static void SuffFindDeps(GNode *, SrcList *);
 static void SuffExpandWildcards(GNodeListNode *, GNode *);
 
+static Suff *
+SuffRef(Suff *suff)
+{
+    suff->refCount++;
+    return suff;
+}
+
 /* Change the value of a Suff variable, adjusting the reference counts. */
 static void
 SuffReassign(Suff **var, Suff *suff)
@@ -856,7 +863,7 @@
 
     src->file = name;
     src->pref = pref;
-    src->suff = suff;
+    src->suff = SuffRef(suff);
     src->parent = parent;
     src->node = gn;
     src->numChildren = 0;
@@ -872,7 +879,6 @@
           const char *debug_tag MAKE_ATTR_UNUSED)
 {
     Src *s2 = SrcNew(srcName, targ->pref, suff, targ, NULL);
-    suff->refCount++;
     targ->numChildren++;
     Lst_Append(srcList, s2);
 #ifdef DEBUG_SRC
@@ -1086,7 +1092,6 @@
      * again (ick)), and return the new structure.
      */
     ret = SrcNew(bmake_strdup(sgn->name), targ->pref, suff, targ, sgn);
-    suff->refCount++;
     targ->numChildren++;
 #ifdef DEBUG_SRC
     debug_printf("3 add targ %p ret %p\n", targ, ret);
@@ -1555,7 +1560,6 @@
 
        pref = bmake_strldup(name, (size_t)(nameLen - suff->nameLen));
        targ = SrcNew(bmake_strdup(gn->name), pref, suff, NULL, gn);
-       suff->refCount++;
 
        /*
         * Add nodes from which the target can be made
@@ -1582,7 +1586,6 @@
 
     targ = SrcNew(bmake_strdup(gn->name), bmake_strdup(sopref),
                  suffNull, NULL, gn);
-    targ->suff->refCount++;
 
     /*
      * Only use the default suffix rules if we don't have commands



Home | Main Index | Thread Index | Old Index