]> git.ipfire.org Git - thirdparty/squid.git/blame - src/dlink.cc
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / dlink.cc
CommitLineData
bbc27441 1/*
b8ae064d 2 * Copyright (C) 1996-2023 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
12dlink_list ClientActiveRequests;
13
e1f7507e
AJ
14void
15dlinkAdd(void *data, dlink_node * m, dlink_list * list)
16{
17 m->data = data;
aee3523a 18 m->prev = nullptr;
e1f7507e
AJ
19 m->next = list->head;
20
21 if (list->head)
22 list->head->prev = m;
23
24 list->head = m;
25
aee3523a 26 if (list->tail == nullptr)
e1f7507e
AJ
27 list->tail = m;
28}
29
30void
31dlinkAddAfter(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
47void
48dlinkAddTail(void *data, dlink_node * m, dlink_list * list)
49{
50 m->data = data;
aee3523a 51 m->next = nullptr;
e1f7507e
AJ
52 m->prev = list->tail;
53
54 if (list->tail)
55 list->tail->next = m;
56
57 list->tail = m;
58
aee3523a 59 if (list->head == nullptr)
e1f7507e
AJ
60 list->head = m;
61}
62
63void
64dlinkDelete(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
aee3523a 78 m->next = m->prev = nullptr;
e1f7507e 79}
f53969cc 80