]>
git.proxmox.com Git - mirror_frr.git/blob - pceplib/pcep_utils_double_linked_list.h
2 * This file is part of the PCEPlib, a PCEP protocol library.
4 * Copyright (C) 2020 Volta Networks https://voltanet.io/
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * Author : Brady Johnson <brady@voltanet.io>
24 #ifndef PCEP_UTILS_INCLUDE_PCEP_UTILS_DOUBLE_LINKED_LIST_H_
25 #define PCEP_UTILS_INCLUDE_PCEP_UTILS_DOUBLE_LINKED_LIST_H_
27 typedef struct double_linked_list_node_
{
28 struct double_linked_list_node_
*prev_node
;
29 struct double_linked_list_node_
*next_node
;
32 } double_linked_list_node
;
35 typedef struct double_linked_list_
{
36 double_linked_list_node
*head
;
37 double_linked_list_node
*tail
;
38 unsigned int num_entries
;
43 /* Initialize a double linked list */
44 double_linked_list
*dll_initialize(void);
46 /* Destroy a double linked list, by freeing the handle and nodes,
47 * user data will not be freed, and may be leaked if not handled
49 void dll_destroy(double_linked_list
*handle
);
50 /* Destroy a double linked list, by freeing the handle and nodes,
51 * and the user data. */
52 void dll_destroy_with_data(double_linked_list
*handle
);
53 void dll_destroy_with_data_memtype(double_linked_list
*handle
,
54 void *data_memory_type
);
56 /* Creates a node and adds it as the first item in the list */
57 double_linked_list_node
*dll_prepend(double_linked_list
*handle
, void *data
);
59 /* Creates a node and adds it as the last item in the list */
60 double_linked_list_node
*dll_append(double_linked_list
*handle
, void *data
);
62 /* Delete the first node in the list, and return the data */
63 void *dll_delete_first_node(double_linked_list
*handle
);
65 /* Delete the last node in the list, and return the data */
66 void *dll_delete_last_node(double_linked_list
*handle
);
68 /* Delete the designated node in the list, and return the data */
69 void *dll_delete_node(double_linked_list
*handle
,
70 double_linked_list_node
*node
);
72 #endif /* PCEP_UTILS_INCLUDE_PCEP_UTILS_DOUBLE_LINKED_LIST_H_ */