blob: 766f940d0a70dfe55ee4614e4ee2b6b1589787e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
struct LIST *
LIST_UNLINK(struct LIST **root, struct LIST *p)
{
if (p->prev)
p->prev->next = p->next;
else
*root = p->next;
if (p->next)
p->next->prev = p->prev;
p->next = p->prev = NULL;
return p;
}
struct LIST *
LIST_POP(struct LIST **pp)
{
if (*pp)
return LIST_UNLINK(pp, *pp);
return NULL;
}
void
LIST_PUSH(struct LIST **pp, struct LIST *p)
{
p->prev = NULL;
p->next = *pp;
if (*pp)
(*pp)->prev = p;
*pp = p;
}
#undef LIST
#undef LIST_PUSH
#undef LIST_POP
#undef LIST_UNLINK
|