MGE General C Library - API Documentation v1.6.7
Library of general C functions.
Loading...
Searching...
No Matches
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 * *
38 ************************************************************************
39 */
40
41#ifndef SLLIST_H
42#define SLLIST_H
43
44#include <portability.h>
45
47
49struct sllistnode {
50 void *object;
51 struct sllistnode *next;
52};
53
54struct sllistnode *add_head_sll_node(struct sllistnode *head,
55 const void *object, size_t objsize);
56
57struct sllistnode *add_tail_sll_node(struct sllistnode *head,
58 const void *object, size_t objsize);
59
60void *find_sll_node(struct sllistnode *head, const void *searchobj,
61 int (*comp)(const void *, const void *));
62
69static inline struct sllistnode *find_next_sll_node(struct sllistnode *focus)
70{
71 return focus->next;
72}
73
79#define for_each_sll_node(focus, head) \
80 for (focus = head; focus != NULL; focus = focus->next)
81
82struct sllistnode *free_sllist(struct sllistnode *head);
83
85
86#endif /* ndef SLLIST_H */
87
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
struct sllistnode * free_sllist(struct sllistnode *head)
Free the entire list.
Definition: sllist.c:184
void * find_sll_node(struct sllistnode *head, const void *searchobj, int(*comp)(const void *, const void *))
Find a node.
Definition: sllist.c:159
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:69
static struct sllistnode * find_next_sll_node(struct sllistnode *focus)
Find the next node in the list.
Definition: sllist.h:69
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:109
Singly linked list node.
Definition: sllist.h:49
void * object
Attached object.
Definition: sllist.h:50
struct sllistnode * next
The subsequent node.
Definition: sllist.h:51