]>
git.proxmox.com Git - mirror_frr.git/blob - pceplib/pcep_utils_double_linked_list.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
3 * This file is part of the PCEPlib, a PCEP protocol library.
5 * Copyright (C) 2020 Volta Networks https://voltanet.io/
7 * Author : Brady Johnson <brady@voltanet.io>
12 #ifndef PCEP_UTILS_INCLUDE_PCEP_UTILS_DOUBLE_LINKED_LIST_H_
13 #define PCEP_UTILS_INCLUDE_PCEP_UTILS_DOUBLE_LINKED_LIST_H_
15 typedef struct double_linked_list_node_
{
16 struct double_linked_list_node_
*prev_node
;
17 struct double_linked_list_node_
*next_node
;
20 } double_linked_list_node
;
23 typedef struct double_linked_list_
{
24 double_linked_list_node
*head
;
25 double_linked_list_node
*tail
;
26 unsigned int num_entries
;
31 /* Initialize a double linked list */
32 double_linked_list
*dll_initialize(void);
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
37 void dll_destroy(double_linked_list
*handle
);
38 /* Destroy a double linked list, by freeing the handle and nodes,
39 * and the user data. */
40 void dll_destroy_with_data(double_linked_list
*handle
);
41 void dll_destroy_with_data_memtype(double_linked_list
*handle
,
42 void *data_memory_type
);
44 /* Creates a node and adds it as the first item in the list */
45 double_linked_list_node
*dll_prepend(double_linked_list
*handle
, void *data
);
47 /* Creates a node and adds it as the last item in the list */
48 double_linked_list_node
*dll_append(double_linked_list
*handle
, void *data
);
50 /* Delete the first node in the list, and return the data */
51 void *dll_delete_first_node(double_linked_list
*handle
);
53 /* Delete the last node in the list, and return the data */
54 void *dll_delete_last_node(double_linked_list
*handle
);
56 /* Delete the designated node in the list, and return the data */
57 void *dll_delete_node(double_linked_list
*handle
,
58 double_linked_list_node
*node
);
60 #endif /* PCEP_UTILS_INCLUDE_PCEP_UTILS_DOUBLE_LINKED_LIST_H_ */