From 7dd66d70b0470b76b44eb5416f143f080789b27a Mon Sep 17 00:00:00 2001 From: venaas Date: Tue, 18 Sep 2007 15:06:15 +0000 Subject: now changed to allow prefix/prefixlen for host git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@159 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- list.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'list.c') diff --git a/list.c b/list.c index e9dcebb..4e80300 100644 --- a/list.c +++ b/list.c @@ -52,12 +52,40 @@ void *list_shift(struct list *list) { node = list->first; list->first = node->next; + if (!list->first) + list->last = NULL; data = node->data; free(node); return data; } +/* removes first entry with matching data pointer */ +void list_removedata(struct list *list, void *data) { + struct list_node *node, *t; + + if (!list->first) + return; + + node = list->first; + if (node->data == data) { + list->first = node->next; + if (!list->first) + list->last = NULL; + free(node); + return; + } + for (; node->next; node = node->next) + if (node->next->data == data) { + t = node->next; + node->next = node->next->next; + if (!node->next) /* we removed the last one */ + list->last = node; + free(t); + return; + } +} + /* returns first node */ struct list_node *list_first(struct list *list) { return list->first; -- cgit v1.1