2 ** Copyright 2002/03, Thomas Kurschel. All rights reserved.
3 ** Distributed under the terms of the OpenBeOS License.
7 Macros for double linked lists
13 #define REMOVE_DL_LIST( item, head, prefix ) \
15 if( item->prefix##prev ) \
16 item->prefix##prev->prefix##next = item->prefix##next; \
18 head = item->prefix##next; \
20 if( item->prefix##next ) \
21 item->prefix##next->prefix##prev = item->prefix##prev; \
24 #define ADD_DL_LIST_HEAD( item, head, prefix ) \
26 item->prefix##next = head; \
27 item->prefix##prev = NULL; \
30 (head)->prefix##prev = item; \
35 #define REMOVE_CDL_LIST( item, head, prefix ) \
37 item->prefix##next->prefix##prev = item->prefix##prev; \
38 item->prefix##prev->prefix##next = item->prefix##next; \
40 if( item == (head) ) { \
41 if( item->prefix##next != item ) \
42 (head) = item->prefix##next; \
48 #define ADD_CDL_LIST_TAIL( item, type, head, prefix ) \
50 type *old_head = head; \
56 last = first->prefix##prev; \
58 item->prefix##next = first; \
59 item->prefix##prev = last; \
60 first->prefix##prev = item; \
61 last->prefix##next = item; \
64 item->prefix##next = item->prefix##prev = item; \
68 #define ADD_CDL_LIST_HEAD( item, type, head, prefix ) \
70 type *old_head = head; \
77 last = first->prefix##prev; \
79 item->prefix##next = first; \
80 item->prefix##prev = last; \
81 first->prefix##prev = item; \
82 last->prefix##next = item; \
84 item->prefix##next = item->prefix##prev = item; \