]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
ef57eb7b | 2 | * Copyright (C) 1996-2016 The Squid Software Foundation and contributors |
bbc27441 AJ |
3 | * |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
f7f3304a | 9 | #include "squid.h" |
e1f7507e AJ |
10 | #include "dlink.h" |
11 | ||
e1f7507e AJ |
12 | dlink_list ClientActiveRequests; |
13 | ||
e1f7507e AJ |
14 | void |
15 | dlinkAdd(void *data, dlink_node * m, dlink_list * list) | |
16 | { | |
17 | m->data = data; | |
18 | m->prev = NULL; | |
19 | m->next = list->head; | |
20 | ||
21 | if (list->head) | |
22 | list->head->prev = m; | |
23 | ||
24 | list->head = m; | |
25 | ||
26 | if (list->tail == NULL) | |
27 | list->tail = m; | |
28 | } | |
29 | ||
30 | void | |
31 | dlinkAddAfter(void *data, dlink_node * m, dlink_node * n, dlink_list * list) | |
32 | { | |
33 | m->data = data; | |
34 | m->prev = n; | |
35 | m->next = n->next; | |
36 | ||
37 | if (n->next) | |
38 | n->next->prev = m; | |
39 | else { | |
40 | assert(list->tail == n); | |
41 | list->tail = m; | |
42 | } | |
43 | ||
44 | n->next = m; | |
45 | } | |
46 | ||
47 | void | |
48 | dlinkAddTail(void *data, dlink_node * m, dlink_list * list) | |
49 | { | |
50 | m->data = data; | |
51 | m->next = NULL; | |
52 | m->prev = list->tail; | |
53 | ||
54 | if (list->tail) | |
55 | list->tail->next = m; | |
56 | ||
57 | list->tail = m; | |
58 | ||
59 | if (list->head == NULL) | |
60 | list->head = m; | |
61 | } | |
62 | ||
63 | void | |
64 | dlinkDelete(dlink_node * m, dlink_list * list) | |
65 | { | |
66 | if (m->next) | |
67 | m->next->prev = m->prev; | |
68 | ||
69 | if (m->prev) | |
70 | m->prev->next = m->next; | |
71 | ||
72 | if (m == list->head) | |
73 | list->head = m->next; | |
74 | ||
75 | if (m == list->tail) | |
76 | list->tail = m->prev; | |
77 | ||
78 | m->next = m->prev = NULL; | |
79 | } | |
f53969cc | 80 |