From: Florian Forster Date: Sun, 14 Jan 2007 13:36:17 +0000 (+0100) Subject: src/utils_llist.[ch]: Implemented `llist_remove'. X-Git-Tag: collectd-4.0.0-rc4~151 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=aa4e094aa57f301d7c7710007e8c4eaf6f33ebf0;p=collectd.git src/utils_llist.[ch]: Implemented `llist_remove'. --- diff --git a/src/utils_llist.c b/src/utils_llist.c index 2e04152f..a8150357 100644 --- a/src/utils_llist.c +++ b/src/utils_llist.c @@ -110,6 +110,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; diff --git a/src/utils_llist.h b/src/utils_llist.h index e44d84ef..603fc87b 100644 --- a/src/utils_llist.h +++ b/src/utils_llist.h @@ -49,6 +49,7 @@ void llentry_destroy (llentry_t *e); void llist_append (llist_t *l, llentry_t *e); void llist_prepend (llist_t *l, llentry_t *e); +void llist_remove (llist_t *l, llentry_t *e); llentry_t *llist_search (llist_t *l, const char *key);