dlink.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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
9#include "squid.h"
10#include "dlink.h"
11
13
14void
15dlinkAdd(void *data, dlink_node * m, dlink_list * list)
16{
17 m->data = data;
18 m->prev = nullptr;
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 == nullptr)
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;
51 m->next = nullptr;
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 == nullptr)
60 list->head = m;
61}
62
63void
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 = nullptr;
79}
80
#define assert(EX)
Definition: assert.h:17

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors