MGE General C Library - API Documentation v1.8.0
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 * 16/09/2022 MG 1.0.9 Rename of portability.h *
33 * Add stddef.h for size_t. *
34 * *
35 ************************************************************************
36 */
37
38#ifndef DLLIST_H
39#define DLLIST_H
40
42
43#include <stddef.h>
44
46
48struct dllistnode {
49 void *object;
52};
53
54struct dllistnode *add_dll_node(struct dllistnode *currentnode,
55 const void *object, size_t objsize);
56
63static inline struct dllistnode *
64find_prev_dll_node(struct dllistnode *currentnode)
65{
66 return currentnode->prevnode;
67}
68
75static inline struct dllistnode *
76find_next_dll_node(struct dllistnode *currentnode)
77{
78 return currentnode->nextnode;
79}
80
81struct dllistnode *free_dllist(struct dllistnode *currentnode);
82
84
85#endif /* ndef DLLIST_H */
struct dllistnode * free_dllist(struct dllistnode *currentnode)
Free the entire list.
Definition: dllist.c:124
static struct dllistnode * find_next_dll_node(struct dllistnode *currentnode)
Find and return the next node.
Definition: dllist.h:76
static struct dllistnode * find_prev_dll_node(struct dllistnode *currentnode)
Find and return the previous node.
Definition: dllist.h:64
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:75
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: mge-portability.h:48
#define END_C_DECLS
Use END_C_DECLS at the end of C declarations.
Definition: mge-portability.h:52
Doubly linked list node.
Definition: dllist.h:48
void * object
The object attached to the node.
Definition: dllist.h:49
struct dllistnode * prevnode
The preceding node.
Definition: dllist.h:50
struct dllistnode * nextnode
The subsequent node.
Definition: dllist.h:51