summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-03-16 16:11:11 +0000
committerharti <harti@FreeBSD.org>2005-03-16 16:11:11 +0000
commit3d5967d36501793e41068bed0ef3fd32fa72411a (patch)
tree58f53d9bcf9b9081d674b794b286c2d59263feae
parentdf4f9cb09a9b495d4414f941dd34e968e222b42f (diff)
downloadFreeBSD-src-3d5967d36501793e41068bed0ef3fd32fa72411a.zip
FreeBSD-src-3d5967d36501793e41068bed0ef3fd32fa72411a.tar.gz
Now that there are no users of Lst_ForEach and Lst_ForEachFrom are left
delete these two macros and all the associated stuff.
-rw-r--r--usr.bin/make/lst.c65
-rw-r--r--usr.bin/make/lst.h27
2 files changed, 3 insertions, 89 deletions
diff --git a/usr.bin/make/lst.c b/usr.bin/make/lst.c
index db4d83c..c3e932b 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;
}
@@ -315,62 +313,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 --
* Insert a new node with the given piece of data before the given
* node in the given list.
@@ -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 b6b57a0..a81e09c 100644
--- a/usr.bin/make/lst.h
+++ b/usr.bin/make/lst.h
@@ -56,23 +56,11 @@
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
*/
struct Lst {
@@ -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,22 +146,12 @@ 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
*/
/* Place an element at tail of queue */
OpenPOWER on IntegriCloud