summaryrefslogtreecommitdiff
path: root/usr.bin/make/lst.lib/lstDestroy.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2000-06-17 14:38:23 +0000
committerMarc Espie <espie@cvs.openbsd.org>2000-06-17 14:38:23 +0000
commitecbebb6e3cb3428095eb28e7e03e6872e5d24a68 (patch)
tree25a3cb92a8ac766285ba464991f3a7d4d6f10cf4 /usr.bin/make/lst.lib/lstDestroy.c
parent93fa2e228c8792a5468e8d398b5bb6c290eecb73 (diff)
This patch introduces a distinction between
Lst_Init (constructor) and Lst_New (allocation + construction) Lst_Destroy (destructor) and Lst_Delete (deallocation + destruction), and uses that to turn most dynamic allocation of lists (Lst pointers) into static structures (LIST). Most of this is mundane, except for allGNs in targ.c, where the code must be checked to verify that Targ_Init is called soon enough. Lst_New is a temporary addition. All lists will soon be static. Reviewed by millert@, like the previous patch.
Diffstat (limited to 'usr.bin/make/lst.lib/lstDestroy.c')
-rw-r--r--usr.bin/make/lst.lib/lstDestroy.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/usr.bin/make/lst.lib/lstDestroy.c b/usr.bin/make/lst.lib/lstDestroy.c
index 74f285ea40e..e584fb16834 100644
--- a/usr.bin/make/lst.lib/lstDestroy.c
+++ b/usr.bin/make/lst.lib/lstDestroy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lstDestroy.c,v 1.8 2000/06/17 14:34:07 espie Exp $ */
+/* $OpenBSD: lstDestroy.c,v 1.9 2000/06/17 14:38:21 espie Exp $ */
/* $NetBSD: lstDestroy.c,v 1.6 1996/11/06 17:59:37 christos Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.8 2000/06/17 14:34:07 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.9 2000/06/17 14:38:21 espie Exp $";
#endif
#endif /* not lint */
@@ -52,6 +52,16 @@ static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.8 2000/06/17 14:34:07 espie Ex
#include "lstInt.h"
+void
+Lst_Delete(l, freeProc)
+ Lst l;
+ SimpleProc freeProc;
+{
+ if (l != NULL)
+ Lst_Destroy(l, freeProc);
+ free(l);
+}
+
/*-
*-----------------------------------------------------------------------
* Lst_Destroy --
@@ -59,9 +69,6 @@ static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.8 2000/06/17 14:34:07 espie Ex
* given, it is called with the datum from each node in turn before
* the node is freed.
*
- * Results:
- * None.
- *
* Side Effects:
* The given list is freed in its entirety.
*
@@ -75,9 +82,6 @@ Lst_Destroy(l, freeProc)
LstNode ln;
LstNode tln;
- if (l == NULL)
- return;
-
if (freeProc) {
for (ln = l->firstPtr; ln != NULL; ln = tln) {
tln = ln->nextPtr;
@@ -90,6 +94,4 @@ Lst_Destroy(l, freeProc)
free(ln);
}
}
-
- free(l);
}