]> git.gag.com Git - debian/sudo/blobdiff - list.c
Imported Upstream version 1.7.6p1
[debian/sudo] / list.c
diff --git a/list.c b/list.c
index 60c1138026ac7ad0c84858cbd4ad959820abc385..2fb4967a2335b558708e2e6dfccf5c489c397f58 100644 (file)
--- a/list.c
+++ b/list.c
@@ -62,7 +62,7 @@ tq_pop(vh)
            h->last->next = NULL;
        }
     }
-    return (last);
+    return last;
 }
 
 /*
@@ -131,3 +131,33 @@ tq_append(vh, vl)
     l->prev = h->last;
     h->last = tail;
 }
+
+/*
+ * Remove element from the tail_queue
+ */
+void
+tq_remove(vh, vl)
+    void *vh;
+    void *vl;
+{
+    struct list_head_proto *h = (struct list_head_proto *)vh;
+    struct list_proto *l = (struct list_proto *)vl;
+
+    if (h->first == l && h->last == l) {
+       /* Single element in the list. */
+       h->first = NULL;
+       h->last = NULL;
+    } else {
+       /* At least two elements in the list. */
+       if (h->first == l) {
+           h->first = l->next;
+           h->first->prev = h->first;
+       } else if (h->last == l) {
+           h->last = l->prev;
+           h->last->next = NULL;
+       } else {
+           l->prev->next = l->next;
+           l->next->prev = l->prev;
+       }
+    }
+}