test_tools.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 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 
15 void
16 dlinkAdd(void *data, dlink_node * m, dlink_list * list)
17 {
18  m->data = data;
19  m->prev = NULL;
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 == NULL)
28  list->tail = m;
29 }
30 
31 void
32 dlinkAddAfter(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 
48 void
49 dlinkAddTail(void *data, dlink_node * m, dlink_list * list)
50 {
51  m->data = data;
52  m->next = NULL;
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 == NULL)
61  list->head = m;
62 }
63 
64 void
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 = NULL;
80 }
81 
void dlinkAddTail(void *data, dlink_node *m, dlink_list *list)
Definition: test_tools.cc:49
#define NULL
Definition: types.h:166
void dlinkAdd(void *data, dlink_node *m, dlink_list *list)
Definition: test_tools.cc:16
void dlinkAddAfter(void *data, dlink_node *m, dlink_node *n, dlink_list *list)
Definition: test_tools.cc:32
#define assert(EX)
Definition: assert.h:19
void dlinkDelete(dlink_node *m, dlink_list *list)
Definition: test_tools.cc:65

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors