Merge branch 'collectd-3.11' into collectd-4.0
[collectd.git] / src / utils_llist.c
index 2e04152..d8694e3 100644 (file)
@@ -21,6 +21,8 @@
  *   Florian Forster <octo at verplant.org>
  */
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <string.h>
 
@@ -110,6 +112,22 @@ void llist_prepend (llist_t *l, llentry_t *e)
        l->head = e;
 }
 
+void llist_remove (llist_t *l, llentry_t *e)
+{
+       llentry_t *prev;
+
+       prev = l->head;
+       while ((prev != NULL) && (prev->next != e))
+               prev = prev->next;
+
+       if (prev != NULL)
+               prev->next = e->next;
+       if (l->head == e)
+               l->head = e->next;
+       if (l->tail == e)
+               l->tail = prev;
+}
+
 llentry_t *llist_search (llist_t *l, const char *key)
 {
        llentry_t *e;