MGE General C Library - Full Internal Documentation  v1.6.8
Library of general C functions.
dllist.h
Go to the documentation of this file.
1 
16 /* **********************************************************************
17  * *
18  * Changelog *
19  * *
20  * Date Author Version Description *
21  * *
22  * 06/05/2016 MG 1.0.1 First release. *
23  * 16/07/2016 MG 1.0.2 Move towards kernel coding style. *
24  * 17/07/2016 MG 1.0.3 Remove function prototype comments. *
25  * 05/11/2017 MG 1.0.4 Add Doxygen comments. *
26  * 09/11/2017 MG 1.0.5 Add SPDX license tag. *
27  * 02/01/2018 MG 1.0.6 Move to new source directory structure. *
28  * 11/06/2019 MG 1.0.7 clang-format coding style changes. *
29  * Extract find_prev and find_next from .c *
30  * file and make static inline. *
31  * 03/12/2021 MG 1.0.8 Tighten SPDX tag. *
32  * *
33  ************************************************************************
34  */
35 
36 #ifndef DLLIST_H
37 #define DLLIST_H
38 
39 #include <portability.h>
40 
42 
44 struct dllistnode {
45  void *object;
46  struct dllistnode *prevnode;
47  struct dllistnode *nextnode;
48 };
49 
50 struct dllistnode *add_dll_node(struct dllistnode *currentnode,
51  const void *object, size_t objsize);
52 
59 static inline struct dllistnode *
60 find_prev_dll_node(struct dllistnode *currentnode)
61 {
62  return currentnode->prevnode;
63 }
64 
71 static inline struct dllistnode *
72 find_next_dll_node(struct dllistnode *currentnode)
73 {
74  return currentnode->nextnode;
75 }
76 
77 struct dllistnode *free_dllist(struct dllistnode *currentnode);
78 
80 
81 #endif /* ndef DLLIST_H */
82 
struct dllistnode * add_dll_node(struct dllistnode *currentnode, const void *object, size_t objsize)
Add a node to the tail of the doubly linked list.
Definition: dllist.c:73
static struct dllistnode * find_next_dll_node(struct dllistnode *currentnode)
Find and return the next node.
Definition: dllist.h:72
struct dllistnode * free_dllist(struct dllistnode *currentnode)
Free the entire list.
Definition: dllist.c:122
static struct dllistnode * find_prev_dll_node(struct dllistnode *currentnode)
Find and return the previous node.
Definition: dllist.h:60
Header file to ease portability.
#define BEGIN_C_DECLS
BEGIN_C_DECLS should be used at the beginning of declarations so that C++ compilers don't mangle thei...
Definition: portability.h:47
#define END_C_DECLS
Use END_C_DECLS at the end of C declarations.
Definition: portability.h:51
Doubly linked list node.
Definition: dllist.h:44
void * object
The object attached to the node.
Definition: dllist.h:45
struct dllistnode * prevnode
The preceding node.
Definition: dllist.h:46
struct dllistnode * nextnode
The subsequent node.
Definition: dllist.h:47