ares_llist.c
Go to the documentation of this file.
1 
2 /* Copyright 1998 by the Massachusetts Institute of Technology.
3  *
4  * Permission to use, copy, modify, and distribute this
5  * software and its documentation for any purpose and without
6  * fee is hereby granted, provided that the above copyright
7  * notice appear in all copies and that both that copyright
8  * notice and this permission notice appear in supporting
9  * documentation, and that the name of M.I.T. not be used in
10  * advertising or publicity pertaining to distribution of the
11  * software without specific, written prior permission.
12  * M.I.T. makes no representations about the suitability of
13  * this software for any purpose. It is provided "as is"
14  * without express or implied warranty.
15  */
16 
17 #include "ares_setup.h"
18 
19 #include "ares.h"
20 #include "ares_private.h"
21 
22 /* Routines for managing doubly-linked circular linked lists with a
23  * dummy head.
24  */
25 
26 /* Initialize a new head node */
27 void ares__init_list_head(struct list_node* head) {
28  head->prev = head;
29  head->next = head;
30  head->data = NULL;
31 }
32 
33 /* Initialize a list node */
34 void ares__init_list_node(struct list_node* node, void* d) {
35  node->prev = NULL;
36  node->next = NULL;
37  node->data = d;
38 }
39 
40 /* Returns true iff the given list is empty */
41 int ares__is_list_empty(struct list_node* head) {
42  return ((head->next == head) && (head->prev == head));
43 }
44 
45 /* Inserts new_node before old_node */
47  struct list_node* old_node) {
48  new_node->next = old_node;
49  new_node->prev = old_node->prev;
50  old_node->prev->next = new_node;
51  old_node->prev = new_node;
52 }
53 
54 /* Removes the node from the list it's in, if any */
55 void ares__remove_from_list(struct list_node* node) {
56  if (node->next != NULL) {
57  node->prev->next = node->next;
58  node->next->prev = node->prev;
59  node->prev = NULL;
60  node->next = NULL;
61  }
62 }
63 
ares.h
list_node::data
void * data
Definition: ares_llist.h:25
ares__is_list_empty
int ares__is_list_empty(struct list_node *head)
Definition: ares_llist.c:41
ares__insert_in_list
void ares__insert_in_list(struct list_node *new_node, struct list_node *old_node)
Definition: ares_llist.c:46
ares__remove_from_list
void ares__remove_from_list(struct list_node *node)
Definition: ares_llist.c:55
list_node::prev
struct list_node * prev
Definition: ares_llist.h:23
d
static const fe d
Definition: curve25519_tables.h:19
ares_setup.h
ares__init_list_head
void ares__init_list_head(struct list_node *head)
Definition: ares_llist.c:27
list_node
Definition: ares_llist.h:22
new_node
static test_node * new_node(size_t i, size_t *ctr)
Definition: mpscq_test.cc:40
ares_private.h
list_node::next
struct list_node * next
Definition: ares_llist.h:24
ares__init_list_node
void ares__init_list_node(struct list_node *node, void *d)
Definition: ares_llist.c:34


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:43