From 071557e3014909bb8b910eb4e71b7efd491be2c5 Mon Sep 17 00:00:00 2001 From: harti Date: Wed, 8 Dec 2004 17:48:15 +0000 Subject: [PATCH] Now that circular lists are gone remove stuff for them. Simplify somewhat so that we can remove a local variable. --- usr.bin/make/lst.lib/lstDestroy.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/usr.bin/make/lst.lib/lstDestroy.c b/usr.bin/make/lst.lib/lstDestroy.c index d2430717a22..15bac2d5867 100644 --- a/usr.bin/make/lst.lib/lstDestroy.c +++ b/usr.bin/make/lst.lib/lstDestroy.c @@ -68,7 +68,6 @@ void Lst_Destroy(Lst *list, FreeProc *freeProc) { LstNode *ln; - LstNode *tln; if (!Lst_Valid(list)) { /* @@ -78,22 +77,19 @@ Lst_Destroy(Lst *list, FreeProc *freeProc) return; } - if (list->lastPtr == NULL) { + if (list->firstPtr == NULL) { free(list); return; } - /* To ease scanning */ - list->lastPtr->nextPtr = NULL; - - if (freeProc) { - for (ln = list->firstPtr; ln != NULL; ln = tln) { - tln = ln->nextPtr; + if (freeProc != NOFREE) { + while ((ln = list->firstPtr) != NULL) { + list->firstPtr = ln->nextPtr; (*freeProc)(ln->datum); free(ln); } } else { - for (ln = list->firstPtr; ln != NULL; ln = tln) { - tln = ln->nextPtr; + while ((ln = list->firstPtr) != NULL) { + list->firstPtr = ln->nextPtr; free(ln); } } -- 2.45.2