]>
code.delx.au - pulseaudio/blob - src/polypcore/llist.h
c54742d3276a755901fccde31d180f3fa7267d7e
7 This file is part of polypaudio.
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
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
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.
19 You should have received a copy of the GNU Lesser General Public
20 License along with polypaudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 /* Some macros for maintaining doubly linked lists */
27 /* The head of the linked list. Use this in the structure that shall
28 * contain the head of the linked list */
29 #define PA_LLIST_HEAD(t,name) t *name
31 /* The pointers in the linked list's items. Use this in the item structure */
32 #define PA_LLIST_FIELDS(t) t *next, *prev
34 /* Initialize the list's head */
35 #define PA_LLIST_HEAD_INIT(t,item) do { (item) = NULL; } while(0)
37 /* Initialize a list item */
38 #define PA_LLIST_INIT(t,item) do { \
41 _item->prev = _item->next = NULL; \
44 /* Prepend an item to the list */
45 #define PA_LLIST_PREPEND(t,head,item) do { \
46 t **_head = &(head), *_item = (item); \
48 if ((_item->next = *_head)) \
49 _item->next->prev = _item; \
54 /* Remove an item from the list */
55 #define PA_LLIST_REMOVE(t,head,item) do { \
56 t **_head = &(head), *_item = (item); \
59 _item->next->prev = _item->prev; \
61 _item->prev->next = _item->next; \
63 assert(*_head == _item); \
64 *_head = _item->next; \
66 _item->next = _item->prev = NULL; \
69 #define PA_LLIST_FIND_HEAD(t,item,head) \
71 t **_head = (head), *_item = (item); \
74 while ((*_head)->prev) \
75 *_head = (*_head)->prev; \