dlink.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
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
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
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
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 }
80 
#define assert(EX)
Definition: assert.h:17
void const char HLPCB void * data
Definition: stub_helper.cc:16
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors