MGE General C Library - Full Internal Documentation v1.8.0
Library of general C functions.
sllist.h
Go to the documentation of this file.
1
16/* **********************************************************************
17 * *
18 * Changelog *
19 * *
20 * Date Author Version Description *
21 * *
22 * 02/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 * 05/07/2019 MG 1.0.7 clang-format coding style changes. *
29 * Extract find_next_sll_node from c file *
30 * and make static inline. *
31 * Add for_each_sll_node macro. *
32 * Improve parameter naming. *
33 * %s/add_sll_node/add_tail_sll_node/g *
34 * Add add_head_sll_node *
35 * Add find_sll_node. *
36 * 03/12/2021 MG 1.0.8 Tighten SPDX tag. *
37 * 15/09/2022 MG 1.0.9 Rename of portability.h *
38 * Add stddef.h for size_t. *
39 * *
40 ************************************************************************
41 */
42
43#ifndef SLLIST_H
44#define SLLIST_H
45
47
48#include <stddef.h>
49
51
53struct sllistnode {
54 void *object;
55 struct sllistnode *next;
56};
57
58struct sllistnode *add_head_sll_node(struct sllistnode *head,
59 const void *object, size_t objsize);
60
61struct sllistnode *add_tail_sll_node(struct sllistnode *head,
62 const void *object, size_t objsize);
63
64void *find_sll_node(struct sllistnode *head, const void *searchobj,
65 int (*comp)(const void *, const void *));
66
73static inline struct sllistnode *find_next_sll_node(struct sllistnode *focus)
74{
75 return focus->next;
76}
77
83#define for_each_sll_node(focus, head) \
84 for (focus = head; focus != NULL; focus = focus->next)
85
86struct sllistnode *free_sllist(struct sllistnode *head);
87
89
90#endif /* ndef SLLIST_H */
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
struct sllistnode * free_sllist(struct sllistnode *head)
Free the entire list.
Definition: sllist.c:186
void * find_sll_node(struct sllistnode *head, const void *searchobj, int(*comp)(const void *, const void *))
Find a node.
Definition: sllist.c:161
struct sllistnode * add_head_sll_node(struct sllistnode *head, const void *object, size_t objsize)
Add a node to the start of the singly linked list.
Definition: sllist.c:71
static struct sllistnode * find_next_sll_node(struct sllistnode *focus)
Find the next node in the list.
Definition: sllist.h:73
struct sllistnode * add_tail_sll_node(struct sllistnode *head, const void *object, size_t objsize)
Add a node to the tail of the singly linked list.
Definition: sllist.c:111
Singly linked list node.
Definition: sllist.h:53
void * object
Attached object.
Definition: sllist.h:54
struct sllistnode * next
The subsequent node.
Definition: sllist.h:55