X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/2bcc24ae8e17ed19c51f6e4e4492f44fe2a4fac4..bfdbffbb39cc765f403dee37a7921bd50170a2fc:/usr/src/usr.bin/make/lst.lib/lstDestroy.c diff --git a/usr/src/usr.bin/make/lst.lib/lstDestroy.c b/usr/src/usr.bin/make/lst.lib/lstDestroy.c index 58d73af181..8f00696ea2 100644 --- a/usr/src/usr.bin/make/lst.lib/lstDestroy.c +++ b/usr/src/usr.bin/make/lst.lib/lstDestroy.c @@ -9,7 +9,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)lstDestroy.c 8.2 (Berkeley) %G%"; #endif /* not lint */ /*- @@ -37,7 +37,7 @@ static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) %G%"; void Lst_Destroy (l, freeProc) Lst l; - register void (*freeProc)(); + register void (*freeProc) __P((ClientData)); { register ListNode ln; register ListNode tln = NilListNode; @@ -50,21 +50,25 @@ Lst_Destroy (l, freeProc) */ return; } - + + /* To ease scanning */ + if (list->lastPtr != NilListNode) + list->lastPtr->nextPtr = NilListNode; + else { + free ((Address)l); + return; + } + if (freeProc) { - for (ln = list->firstPtr; - ln != NilListNode && tln != list->firstPtr; - ln = tln) { - tln = ln->nextPtr; - (*freeProc) (ln->datum); - free ((Address)ln); + for (ln = list->firstPtr; ln != NilListNode; ln = tln) { + tln = ln->nextPtr; + (*freeProc) (ln->datum); + free ((Address)ln); } } else { - for (ln = list->firstPtr; - ln != NilListNode && tln != list->firstPtr; - ln = tln) { - tln = ln->nextPtr; - free ((Address)ln); + for (ln = list->firstPtr; ln != NilListNode; ln = tln) { + tln = ln->nextPtr; + free ((Address)ln); } }