2 * Sherlock Library -- Linked Lists
4 * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
8 struct node *next, *prev;
10 typedef struct node node;
13 struct node head, tail;
15 typedef struct list list;
18 #define HEAD(list) ((void *)((list).head.next))
19 #define TAIL(list) ((void *)((list).tail.prev))
20 #define DO_FOR_ALL(n,list) for((n)=HEAD(list);(NODE (n))->next; \
21 n=(void *)((NODE (n))->next))
22 #define EMPTY_LIST(list) (!(list).head.next->next)
23 #define OFFSETOF(s, i) ((unsigned int)&((s *)0)->i)
24 #define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i)))
26 void add_tail(list *, node *);
27 void add_head(list *, node *);
28 void rem_node(node *);
29 void add_tail_list(list *, list *);
30 void init_list(list *);
31 void insert_node(node *, node *);
36 add_tail(list *l, node *n)
38 node *z = l->tail.prev;
47 add_head(list *l, node *n)
49 node *z = l->head.next;
58 insert_node(node *n, node *after)
60 node *z = after->next;
81 l->head.next = &l->tail;
84 l->tail.prev = &l->head;
88 add_tail_list(list *to, list *l)
90 node *p = to->tail.prev;
91 node *q = l->head.next;