summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-12-08 17:43:43 +0000
committerharti <harti@FreeBSD.org>2004-12-08 17:43:43 +0000
commit7bfaeaf06171fb6d9c4bbc52845c7bf7b370d8d2 (patch)
treedc59788195b2223a8f3b72c0c0d85f4c00e0b2d2 /usr.bin
parent21e06e4bb02890259326936aad2e26187681147e (diff)
downloadFreeBSD-src-7bfaeaf06171fb6d9c4bbc52845c7bf7b370d8d2.zip
FreeBSD-src-7bfaeaf06171fb6d9c4bbc52845c7bf7b370d8d2.tar.gz
No caller checks the return code from Lst_Remove, so don't return one.
Simplify the algorithm now that circular lists are gone.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/lst.h2
-rw-r--r--usr.bin/make/lst.lib/lstRemove.c40
2 files changed, 12 insertions, 30 deletions
diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h
index bb08f2c..e9c8f1c 100644
--- a/usr.bin/make/lst.h
+++ b/usr.bin/make/lst.h
@@ -120,7 +120,7 @@ ReturnStatus Lst_Append(Lst *, LstNode *, void *);
/* Place an element at the end of a lst. */
#define Lst_AtEnd(LST, D) (Lst_Append((LST), Lst_Last(LST), (D)))
/* Remove an element */
-ReturnStatus Lst_Remove(Lst *, LstNode *);
+void Lst_Remove(Lst *, LstNode *);
/* Replace a node with a new value */
#define Lst_Replace(NODE, D) (((NODE) == NULL) ? FAILURE : \
(((NODE)->datum = (D)), SUCCESS))
diff --git a/usr.bin/make/lst.lib/lstRemove.c b/usr.bin/make/lst.lib/lstRemove.c
index 035218d..aa0fd99 100644
--- a/usr.bin/make/lst.lib/lstRemove.c
+++ b/usr.bin/make/lst.lib/lstRemove.c
@@ -64,42 +64,26 @@ __FBSDID("$FreeBSD$");
*
*-----------------------------------------------------------------------
*/
-ReturnStatus
+void
Lst_Remove(Lst *list, LstNode *ln)
{
- if (!Lst_Valid(list) || !Lst_NodeValid(ln, list)) {
- return (FAILURE);
- }
-
/*
* unlink it from the list
*/
- if (ln->nextPtr != NULL) {
+ if (ln->nextPtr != NULL)
+ /* unlink from the backward chain */
ln->nextPtr->prevPtr = ln->prevPtr;
- }
- if (ln->prevPtr != NULL) {
- ln->prevPtr->nextPtr = ln->nextPtr;
- }
-
- /*
- * if either the firstPtr or lastPtr of the list point to this node,
- * adjust them accordingly
- */
- if (list->firstPtr == ln) {
- list->firstPtr = ln->nextPtr;
- }
- if (list->lastPtr == ln) {
+ else
+ /* this was the last element */
list->lastPtr = ln->prevPtr;
- }
- /*
- * the only way firstPtr can still point to ln is if ln is the last
- * node on the list. The list is, therefore, empty and is marked as such
- */
- if (list->firstPtr == ln) {
- list->firstPtr = NULL;
- }
+ if (ln->prevPtr != NULL)
+ /* unlink from the forward chain */
+ ln->prevPtr->nextPtr = ln->nextPtr;
+ else
+ /* this was the first element */
+ list->firstPtr = ln->nextPtr;
/*
* note that the datum is unmolested. The caller must free it as
@@ -110,6 +94,4 @@ Lst_Remove(Lst *list, LstNode *ln)
} else {
ln->flags |= LN_DELETED;
}
-
- return (SUCCESS);
}
OpenPOWER on IntegriCloud