Statistics
| Branch: | Revision:

iof-bird-daemon / lib / lists.c @ 18c8241a

History | View | Annotate | Download (1.07 KB)

1
/*
2
 *        BIRD Library -- Linked Lists
3
 *
4
 *        (c) 1998 Martin Mares <mj@ucw.cz>
5
 *
6
 *        Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

    
9
#define _BIRD_LISTS_C_
10

    
11
#include "nest/bird.h"
12
#include "lib/lists.h"
13

    
14
LIST_INLINE void
15
add_tail(list *l, node *n)
16
{
17
  node *z = l->tail;
18

    
19
  n->next = (node *) &l->null;
20
  n->prev = z;
21
  z->next = n;
22
  l->tail = n;
23
}
24

    
25
LIST_INLINE void
26
add_head(list *l, node *n)
27
{
28
  node *z = l->head;
29

    
30
  n->next = z;
31
  n->prev = (node *) &l->head;
32
  z->prev = n;
33
  l->head = n;
34
}
35

    
36
LIST_INLINE void
37
insert_node(node *n, node *after)
38
{
39
  node *z = after->next;
40

    
41
  n->next = z;
42
  n->prev = after;
43
  after->next = n;
44
  z->prev = n;
45
}
46

    
47
LIST_INLINE void
48
rem_node(node *n)
49
{
50
  node *z = n->prev;
51
  node *x = n->next;
52

    
53
  z->next = x;
54
  x->prev = z;
55
}
56

    
57
LIST_INLINE void
58
init_list(list *l)
59
{
60
  l->head = (node *) &l->null;
61
  l->null = NULL;
62
  l->tail = (node *) &l->head;
63
}
64

    
65
LIST_INLINE void
66
add_tail_list(list *to, list *l)
67
{
68
  node *p = to->tail;
69
  node *q = l->head;
70

    
71
  p->next = q;
72
  q->prev = p;
73
  q = l->tail;
74
  q->next = (node *) &to->null;
75
  to->tail = q;
76
}