test_tools.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// XXX: This file is made of large pieces of src/tools.cc
10// with only a few minor modifications. TODO: redesign or delete.
11
12#include "squid.h"
13#include "dlink.h"
14
15void
16dlinkAdd(void *data, dlink_node * m, dlink_list * list)
17{
18 m->data = data;
19 m->prev = nullptr;
20 m->next = list->head;
21
22 if (list->head)
23 list->head->prev = m;
24
25 list->head = m;
26
27 if (list->tail == nullptr)
28 list->tail = m;
29}
30
31void
32dlinkAddAfter(void *data, dlink_node * m, dlink_node * n, dlink_list * list)
33{
34 m->data = data;
35 m->prev = n;
36 m->next = n->next;
37
38 if (n->next)
39 n->next->prev = m;
40 else {
41 assert(list->tail == n);
42 list->tail = m;
43 }
44
45 n->next = m;
46}
47
48void
49dlinkAddTail(void *data, dlink_node * m, dlink_list * list)
50{
51 m->data = data;
52 m->next = nullptr;
53 m->prev = list->tail;
54
55 if (list->tail)
56 list->tail->next = m;
57
58 list->tail = m;
59
60 if (list->head == nullptr)
61 list->head = m;
62}
63
64void
66{
67 if (m->next)
68 m->next->prev = m->prev;
69
70 if (m->prev)
71 m->prev->next = m->next;
72
73 if (m == list->head)
74 list->head = m->next;
75
76 if (m == list->tail)
77 list->tail = m->prev;
78
79 m->next = m->prev = nullptr;
80}
81
#define assert(EX)
Definition: assert.h:17
void dlinkDelete(dlink_node *m, dlink_list *list)
Definition: test_tools.cc:65
void dlinkAdd(void *data, dlink_node *m, dlink_list *list)
Definition: test_tools.cc:16
void dlinkAddTail(void *data, dlink_node *m, dlink_list *list)
Definition: test_tools.cc:49
void dlinkAddAfter(void *data, dlink_node *m, dlink_node *n, dlink_list *list)
Definition: test_tools.cc:32

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors