MGE General C Library - Full Internal Documentation v1.8.4
Library of general C functions.
Loading...
Searching...
No Matches
sllist.h
Go to the documentation of this file.
1
16#ifndef SLLIST_H
17#define SLLIST_H
18
20
21#include <stddef.h>
22
24
26struct sllistnode {
27 void *object;
28 struct sllistnode *next;
29};
30
31struct sllistnode *add_head_sll_node(struct sllistnode *head,
32 const void *object, size_t objsize);
33
34struct sllistnode *add_tail_sll_node(struct sllistnode *head,
35 const void *object, size_t objsize);
36
37void *find_sll_node(struct sllistnode *head, const void *searchobj,
38 int (*comp)(const void *, const void *));
39
46static inline struct sllistnode *find_next_sll_node(struct sllistnode *focus)
47{
48 return focus->next;
49}
50
56#define for_each_sll_node(focus, head) \
57 for (focus = head; focus != NULL; focus = focus->next)
58
59struct sllistnode *free_sllist(struct sllistnode *head);
60
62
63#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:30
#define END_C_DECLS
Use END_C_DECLS at the end of C declarations.
Definition mge-portability.h:34
struct sllistnode * free_sllist(struct sllistnode *head)
Free the entire list.
Definition sllist.c:150
void * find_sll_node(struct sllistnode *head, const void *searchobj, int(*comp)(const void *, const void *))
Find a node.
Definition sllist.c:125
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:35
static struct sllistnode * find_next_sll_node(struct sllistnode *focus)
Find the next node in the list.
Definition sllist.h:46
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:75
Singly linked list node.
Definition sllist.h:26
void * object
Attached object.
Definition sllist.h:27
struct sllistnode * next
The subsequent node.
Definition sllist.h:28