1
2 #ifndef LIST_H
3 #define LIST_H
4
5 #include
6
7 typedef struct ListElmt_ {
8 void *data;
9 struct ListElmt_ *next;
10 } ListElmt;
11
12 typedef struct List_ {
13 int size;
14 int (*match)(const void *key, const void *key2);
15 void (*destroy)(void *data);
16 ListElmt *head;
17 ListElmt *tail;
18 } List;
19
20 void list_init(List *list, void (*destroy)(void *data));
21
22 void list_destroy(List *list);
23
24 int list_ins_next(List *list, ListElmt *element, const void *data);
25
26 int list_rem_next(List *list, ListElmt *element, void **data);
27
28 #define list_size(list) ((list)->size)
29
30 #define list_head(list) ((list)->head)
31
32 #define list_tail(list) ((list)->tail)
33
34 #define list_is_head(list, element) ((element) == (list)->head ? 1 :0)
35
36 #define list_is_tail(element) ((element)->next == NULL ? 1 : 0)
37
38 #define list_data(element) ((element)->data)
39
40 #define list_next(element) ((element)->next)
41
42 #endif
43