]> code.delx.au - pulseaudio/blob - polyp/llist.h
Make the whole stuff LGPL only
[pulseaudio] / polyp / llist.h
1 #ifndef foollistfoo
2 #define foollistfoo
3
4 /* $Id$ */
5
6 /***
7 This file is part of polypaudio.
8
9 polypaudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2 of the License,
12 or (at your option) any later version.
13
14 polypaudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with polypaudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
24
25 #define PA_LLIST_HEAD(t,name) t *name
26
27 #define PA_LLIST_FIELDS(t) t *next, *prev
28
29 #define PA_LLIST_HEAD_INIT(t,item) do { (item) = NULL; } while(0)
30
31 #define PA_LLIST_INIT(t,item) do { \
32 t *_item = (item); \
33 assert(_item); \
34 _item->prev = _item->next = NULL; \
35 } while(0)
36
37 #define PA_LLIST_PREPEND(t,head,item) do { \
38 t **_head = &(head), *_item = (item); \
39 assert(_item); \
40 if ((_item->next = *_head)) \
41 _item->next->prev = _item; \
42 _item->prev = NULL; \
43 *_head = _item; \
44 } while (0)
45
46 #define PA_LLIST_REMOVE(t,head,item) do { \
47 t **_head = &(head), *_item = (item); \
48 assert(_item); \
49 if (_item->next) \
50 _item->next->prev = _item->prev; \
51 if (_item->prev) \
52 _item->prev->next = _item->next; \
53 else {\
54 assert(*_head == _item); \
55 *_head = _item->next; \
56 } \
57 _item->next = _item->prev = NULL; \
58 } while(0)
59
60 #endif