Go to the documentation of this file.00001 #ifndef foollistfoo
00002 #define foollistfoo
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00027 #include <assert.h>
00028 
00029 #include <avahi-common/cdecl.h>
00030 
00031 AVAHI_C_DECL_BEGIN
00032 
00035 #define AVAHI_LLIST_HEAD(t,name) t *name
00036 
00038 #define AVAHI_LLIST_FIELDS(t,name) t *name##_next, *name##_prev
00039 
00041 #define AVAHI_LLIST_HEAD_INIT(t,head) do { (head) = NULL; } while(0)
00042 
00044 #define AVAHI_LLIST_INIT(t,name,item) do { \
00045                                t *_item = (item); \
00046                                assert(_item); \
00047                                _item->name##_prev = _item->name##_next = NULL; \
00048                                } while(0)
00049 
00051 #define AVAHI_LLIST_PREPEND(t,name,head,item) do { \
00052                                         t **_head = &(head), *_item = (item); \
00053                                         assert(_item); \
00054                                         if ((_item->name##_next = *_head)) \
00055                                            _item->name##_next->name##_prev = _item; \
00056                                         _item->name##_prev = NULL; \
00057                                         *_head = _item; \
00058                                         } while (0)
00059 
00061 #define AVAHI_LLIST_REMOVE(t,name,head,item) do { \
00062                                     t **_head = &(head), *_item = (item); \
00063                                     assert(_item); \
00064                                     if (_item->name##_next) \
00065                                        _item->name##_next->name##_prev = _item->name##_prev; \
00066                                     if (_item->name##_prev) \
00067                                        _item->name##_prev->name##_next = _item->name##_next; \
00068                                     else {\
00069                                        assert(*_head == _item); \
00070                                        *_head = _item->name##_next; \
00071                                     } \
00072                                     _item->name##_next = _item->name##_prev = NULL; \
00073                                     } while(0)
00074 
00075 AVAHI_C_DECL_END
00076 
00077 #endif