]> git.proxmox.com Git - mirror_frr.git/blame - pceplib/pcep_utils_double_linked_list.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / pceplib / pcep_utils_double_linked_list.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: LGPL-2.1-or-later
74971473
JG
2/*
3 * This file is part of the PCEPlib, a PCEP protocol library.
4 *
5 * Copyright (C) 2020 Volta Networks https://voltanet.io/
6 *
74971473
JG
7 * Author : Brady Johnson <brady@voltanet.io>
8 *
9 */
10
11
12#ifndef PCEP_UTILS_INCLUDE_PCEP_UTILS_DOUBLE_LINKED_LIST_H_
13#define PCEP_UTILS_INCLUDE_PCEP_UTILS_DOUBLE_LINKED_LIST_H_
14
15typedef struct double_linked_list_node_ {
16 struct double_linked_list_node_ *prev_node;
17 struct double_linked_list_node_ *next_node;
18 void *data;
19
20} double_linked_list_node;
21
22
23typedef struct double_linked_list_ {
24 double_linked_list_node *head;
25 double_linked_list_node *tail;
26 unsigned int num_entries;
27
28} double_linked_list;
29
30
31/* Initialize a double linked list */
32double_linked_list *dll_initialize(void);
33
34/* Destroy a double linked list, by freeing the handle and nodes,
35 * user data will not be freed, and may be leaked if not handled
36 * externally. */
37void dll_destroy(double_linked_list *handle);
38/* Destroy a double linked list, by freeing the handle and nodes,
39 * and the user data. */
40void dll_destroy_with_data(double_linked_list *handle);
41void dll_destroy_with_data_memtype(double_linked_list *handle,
42 void *data_memory_type);
43
44/* Creates a node and adds it as the first item in the list */
45double_linked_list_node *dll_prepend(double_linked_list *handle, void *data);
46
47/* Creates a node and adds it as the last item in the list */
48double_linked_list_node *dll_append(double_linked_list *handle, void *data);
49
50/* Delete the first node in the list, and return the data */
51void *dll_delete_first_node(double_linked_list *handle);
52
53/* Delete the last node in the list, and return the data */
54void *dll_delete_last_node(double_linked_list *handle);
55
56/* Delete the designated node in the list, and return the data */
57void *dll_delete_node(double_linked_list *handle,
58 double_linked_list_node *node);
59
60#endif /* PCEP_UTILS_INCLUDE_PCEP_UTILS_DOUBLE_LINKED_LIST_H_ */