From 3d5967d36501793e41068bed0ef3fd32fa72411a Mon Sep 17 00:00:00 2001 From: harti Date: Wed, 16 Mar 2005 16:11:11 +0000 Subject: [PATCH] Now that there are no users of Lst_ForEach and Lst_ForEachFrom are left delete these two macros and all the associated stuff. --- usr.bin/make/lst.c | 65 +--------------------------------------------- usr.bin/make/lst.h | 27 ++----------------- 2 files changed, 3 insertions(+), 89 deletions(-) diff --git a/usr.bin/make/lst.c b/usr.bin/make/lst.c index db4d83cb59b9..c3e932b55199 100644 --- a/usr.bin/make/lst.c +++ b/usr.bin/make/lst.c @@ -69,7 +69,6 @@ Lst_Append(Lst *list, LstNode *ln, void *d) nLNode = emalloc(sizeof(*nLNode)); nLNode->datum = d; - nLNode->useCount = nLNode->flags = 0; if (ln == NULL) { nLNode->nextPtr = nLNode->prevPtr = NULL; @@ -161,7 +160,6 @@ Lst_Concat(Lst *list1, Lst *list2, int flags) list1->firstPtr = nln; } nln->prevPtr = last; - nln->flags = nln->useCount = 0; last = nln; } @@ -313,62 +311,6 @@ Lst_FindFrom(Lst *l, LstNode *ln, const void *d, CompareProc *cProc) } } -/*- - *----------------------------------------------------------------------- - * Lst_ForEachFrom -- - * Apply the given function to each element of the given list. The - * function should return 0 if traversal should continue and non- - * zero if it should abort. - * - * Results: - * None. - * - * Side Effects: - * Only those created by the passed-in function. - * - *----------------------------------------------------------------------- - */ -void -Lst_ForEachFrom(Lst *list, LstNode *ln, DoProc *proc, void *d) -{ - LstNode *next; - Boolean done; - int result; - - if (!Lst_Valid(list) || Lst_IsEmpty(list)) { - return; - } - - do { - /* - * Take care of having the current element deleted out from under - * us. - */ - - next = ln->nextPtr; - - ln->useCount++; - result = (*proc)(ln->datum, d); - ln->useCount--; - - /* - * We're done with the traversal if - * - nothing's been added after the current node and - * - the next node to examine is the first in the queue or - * doesn't exist. - */ - done = (next == ln->nextPtr && - (next == NULL || next == list->firstPtr)); - - next = ln->nextPtr; - - if (ln->flags & LN_DELETED) { - free(ln); - } - ln = next; - } while (!result && !Lst_IsEmpty(list) && !done); -} - /*- *----------------------------------------------------------------------- * Lst_Insert -- @@ -393,7 +335,6 @@ Lst_Insert(Lst *list, LstNode *ln, void *d) nLNode = emalloc(sizeof(*nLNode)); nLNode->datum = d; - nLNode->useCount = nLNode->flags = 0; if (ln == NULL) { nLNode->prevPtr = nLNode->nextPtr = NULL; @@ -472,9 +413,5 @@ Lst_Remove(Lst *list, LstNode *ln) * note that the datum is unmolested. The caller must free it as * necessary and as expected. */ - if (ln->useCount == 0) { - free(ln); - } else { - ln->flags |= LN_DELETED; - } + free(ln); } diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h index b6b57a0ad3c4..a81e09cc92b3 100644 --- a/usr.bin/make/lst.h +++ b/usr.bin/make/lst.h @@ -56,22 +56,10 @@ struct LstNode { struct LstNode *prevPtr; /* previous element in list */ struct LstNode *nextPtr; /* next in list */ - int useCount:8; /* Count of functions using the node. Node may not - * be deleted until count goes to 0 */ - int flags:8; /* Node status flags */ - void *datum; /* datum associated with this element */ + void *datum; /* datum associated with this element */ }; typedef struct LstNode LstNode; -/* - * Flags required for synchronization - */ -#define LN_DELETED 0x0001 /* List node should be removed when done */ - -typedef enum { - LstHead, LstMiddle, LstTail, LstUnknown -} LstWhere; - /* * The list itself */ @@ -82,7 +70,6 @@ struct Lst { typedef struct Lst Lst; typedef int CompareProc(const void *, const void *); -typedef int DoProc(void *, void *); typedef void *DuplicateProc(void *); typedef void FreeProc(void *); @@ -159,21 +146,11 @@ LstNode *Lst_FindFrom(Lst *, LstNode *, const void *, CompareProc *); * the datum */ LstNode *Lst_Member(Lst *, void *); -/* Apply a function to all elements of a lst */ -void Lst_ForEach(Lst *, DoProc *, void *); -#define Lst_ForEach(LST, FN, D) (Lst_ForEachFrom((LST), Lst_First(LST), \ - (FN), (D))) +/* Loop through a list. Note, that you may not delete the list element. */ #define LST_FOREACH(PTR, LST) \ for ((PTR) = (LST)->firstPtr; (PTR) != NULL; (PTR) = (PTR)->nextPtr) -/* - * Apply a function to all elements of a lst starting from a certain point. - * If the list is circular, the application will wrap around to the - * beginning of the list again. - */ -void Lst_ForEachFrom(Lst *, LstNode *, DoProc *, void *); - /* * for using the list as a queue */