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): extract CachedDir_Free0 from CachedDir...



details:   https://anonhg.NetBSD.org/src/rev/322a06cf71b0
branches:  trunk
changeset: 946518:322a06cf71b0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 29 15:58:37 2020 +0000

description:
make(1): extract CachedDir_Free0 from CachedDir_Destroy

diffstat:

 usr.bin/make/dir.c |  29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diffs (69 lines):

diff -r 9b9f88010814 -r 322a06cf71b0 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Sun Nov 29 15:14:32 2020 +0000
+++ b/usr.bin/make/dir.c        Sun Nov 29 15:58:37 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.237 2020/11/29 15:14:32 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.238 2020/11/29 15:58:37 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -136,7 +136,7 @@
 #include "job.h"
 
 /*     "@(#)dir.c      8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: dir.c,v 1.237 2020/11/29 15:14:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.238 2020/11/29 15:58:37 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -287,6 +287,7 @@
 
 
 static void CachedDir_Destroy(CachedDir *);
+static void OpenDirs_Remove(OpenDirs *, const char *);
 
 
 static CachedDir *
@@ -311,13 +312,24 @@
        return dir;
 }
 
-static CachedDir *
+/* Free a cached directory with reference count 0. */
+static void
+CachedDir_Free0(CachedDir *dir)
+{
+
+       OpenDirs_Remove(&openDirs, dir->name);
+
+       free(dir->name);
+       HashSet_Done(&dir->files);
+       free(dir);
+}
+
+static void
 CachedDir_Unref(CachedDir *dir)
 {
        dir->refCount--;
        DEBUG2(DIR, "CachedDir refCount-- to %d for \"%s\"\n",
            dir->refCount, dir->name);
-       return dir;
 }
 
 static void
@@ -1608,13 +1620,8 @@
 {
        CachedDir_Unref(dir);
 
-       if (dir->refCount == 0) {
-               OpenDirs_Remove(&openDirs, dir->name);
-
-               HashSet_Done(&dir->files);
-               free(dir->name);
-               free(dir);
-       }
+       if (dir->refCount == 0)
+               CachedDir_Free0(dir);
 }
 
 /* Free the search path and all directories mentioned in it. */



Home | Main Index | Thread Index | Old Index