2
Declarations for a doubly linked list.
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
This program is released under the GPL with the additional exemption
19
that compiling, linking, and/or using OpenSSL is allowed.
21
Copyright (C) 2008 Bertrand Mesot <http://www.objectif-securite.ch>
33
typedef struct list_nd_t_ {
34
void *data; /**< The element to be stored. */
35
struct list_nd_t_ *prev; /**< A pointer to the previous node. */
36
struct list_nd_t_ *next; /**< A pointer to the following node. */
39
/** A doubly linked list. */
41
typedef struct list_t_ {
42
int size; /**< The size of the list */
43
list_nd_t *head; /**< A pointer to the head of the list. */
44
list_nd_t *tail; /**< A pointer to the tail of the list. */
47
/** Allocate memory for a list. */
49
list_t *list_alloc(void);
51
/** Free the memory used by the list.
53
* The memory used by the element is not freed. It is therefore your
54
* responsability to clean up that part of the memory.
56
* @param l A pointer to the list to be cleared.
59
void list_free(list_t *l);
61
/** Empty the list. */
63
void list_clean(list_t *l);
65
/** Add an element to the head of the list.
66
* @param l A pointer to the list.
67
* @param data A pointer to the element.
70
void list_add_head(list_t *l, void *data);
72
/** Add an element to the tail of the list.
73
* @param l A pointer to the list.
74
* @param data A pointer to the element.
77
void list_add_tail(list_t *l, void *data);
79
/** Remove an element from the head of the list.
80
* @param l A pointer to the list.
81
* @return A pointer to the element stored in the head.
84
void *list_rem_head(list_t *l);
86
/** Remove an element from the tail of the list.
87
* @param l A pointer to the list.
88
* @return A pointer to the element stored in the tail.
91
void *list_rem_tail(list_t *l);
93
/** Allocate memory for a list node.
94
* @param data A pointer to the element.
95
* @return A list node containing the element.
98
list_nd_t *list_nd_alloc(void *data);
100
/** Free the memory used by a node.
101
* @param nd The node to be freed.
102
* @return A pointer to the element stored in the node.
105
void *list_nd_free(list_nd_t *nd);