MGE General C Library - Full Internal Documentation  v1.4.1
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  * *
37  ************************************************************************
38  */
39 
40 #ifndef SLLIST_H
41 #define SLLIST_H
42 
43 #include <portability.h>
44 
46 
48 struct sllistnode {
49  void *object;
50  struct sllistnode *next;
51 };
52 
53 struct sllistnode *add_head_sll_node(struct sllistnode *head,
54  const void *object, size_t objsize);
55 
56 struct sllistnode *add_tail_sll_node(struct sllistnode *head,
57  const void *object, size_t objsize);
58 
59 void *find_sll_node(struct sllistnode *head, const void *searchobj,
60  int (*comp)(const void *, const void *));
61 
68 static inline struct sllistnode *find_next_sll_node(struct sllistnode *focus)
69 {
70  return focus->next;
71 }
72 
78 #define for_each_sll_node(focus, head) \
79  for (focus = head; focus != NULL; focus = focus->next)
80 
81 struct sllistnode *free_sllist(struct sllistnode *head);
82 
84 
85 #endif /* ndef SLLIST_H */
86 
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:68
void * find_sll_node(struct sllistnode *head, const void *searchobj, int(*comp)(const void *, const void *))
Find a node.
Definition: sllist.c:158
Singly linked list node.
Definition: sllist.h:48
Header file to ease portability.
static struct sllistnode * find_next_sll_node(struct sllistnode *focus)
Find the next node in the list.
Definition: sllist.h:68
#define END_C_DECLS
Use END_C_DECLS at the end of C declarations.
Definition: portability.h:50
void * object
Attached object.
Definition: sllist.h:49
struct sllistnode * next
The subsequent node.
Definition: sllist.h:50
#define BEGIN_C_DECLS
BEGIN_C_DECLS should be used at the beginning of declarations so that C++ compilers don&#39;t mangle thei...
Definition: portability.h:46
struct sllistnode * free_sllist(struct sllistnode *head)
Free the entire list.
Definition: sllist.c:183
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:108