remove unused variable
[dropbear.git] / list.c
blob8be1a3a2a90329262ed8e7f8fd800cfd60b0474c
1 #include "options.h"
2 #include "dbutil.h"
3 #include "list.h"
5 void list_append(m_list *list, void *item) {
6 m_list_elem *elem;
8 elem = m_malloc(sizeof(*elem));
9 elem->item = item;
10 elem->list = list;
11 elem->next = NULL;
12 if (!list->first) {
13 list->first = elem;
14 elem->prev = NULL;
15 } else {
16 elem->prev = list->last;
17 list->last->next = elem;
19 list->last = elem;
22 m_list * list_new() {
23 m_list *ret = m_malloc(sizeof(m_list));
24 ret->first = ret->last = NULL;
25 return ret;
28 void * list_remove(m_list_elem *elem) {
29 void *item = elem->item;
30 m_list *list = elem->list;
31 if (list->first == elem)
33 list->first = elem->next;
35 if (list->last == elem)
37 list->last = elem->prev;
39 if (elem->prev)
41 elem->prev->next = elem->next;
43 if (elem->next)
45 elem->next->prev = elem->prev;
47 m_free(elem);
48 return item;