]>
code.delx.au - pulseaudio/blob - src/pulsecore/llist.h
8fc8e22b6491750d4b2e15986492950fefb7fe53
7 This file is part of PulseAudio.
9 Copyright 2004-2006 Lennart Poettering
11 PulseAudio is free software; you can redistribute it and/or modify
12 it under the terms of the GNU Lesser General Public License as
13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version.
16 PulseAudio is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public
22 License along with PulseAudio; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 /* Some macros for maintaining doubly linked lists */
31 /* The head of the linked list. Use this in the structure that shall
32 * contain the head of the linked list */
33 #define PA_LLIST_HEAD(t,name) t *name
35 /* The pointers in the linked list's items. Use this in the item structure */
36 #define PA_LLIST_FIELDS(t) t *next, *prev
38 /* Initialize the list's head */
39 #define PA_LLIST_HEAD_INIT(t,item) do { (item) = (t*) NULL; } while(0)
41 /* Initialize a list item */
42 #define PA_LLIST_INIT(t,item) do { \
45 _item->prev = _item->next = NULL; \
48 /* Prepend an item to the list */
49 #define PA_LLIST_PREPEND(t,head,item) do { \
50 t **_head = &(head), *_item = (item); \
52 if ((_item->next = *_head)) \
53 _item->next->prev = _item; \
58 /* Remove an item from the list */
59 #define PA_LLIST_REMOVE(t,head,item) do { \
60 t **_head = &(head), *_item = (item); \
63 _item->next->prev = _item->prev; \
65 _item->prev->next = _item->next; \
67 assert(*_head == _item); \
68 *_head = _item->next; \
70 _item->next = _item->prev = NULL; \
73 #define PA_LLIST_FIND_HEAD(t,item,head) \
75 t **_head = (head), *_item = (item); \
78 while ((*_head)->prev) \
79 *_head = (*_head)->prev; \
82 #define PA_LLIST_INSERT_AFTER(t,head,a,b) \
84 t **_head = &(head), *_a = (a), *_b = (b); \
87 if ((_b->next = *_head)) \
88 _b->next->prev = _b; \
92 if ((_b->next = _a->next)) \
93 _b->next->prev = _b; \