MGE General C Library - API Documentation  v1.8.4
Library of general C functions.
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 
26 struct sllistnode {
27  void *object;
28  struct sllistnode *next;
29 };
30 
31 struct sllistnode *add_head_sll_node(struct sllistnode *head,
32  const void *object, size_t objsize);
33 
34 struct sllistnode *add_tail_sll_node(struct sllistnode *head,
35  const void *object, size_t objsize);
36 
37 void *find_sll_node(struct sllistnode *head, const void *searchobj,
38  int (*comp)(const void *, const void *));
39 
46 static 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 
59 struct sllistnode *free_sllist(struct sllistnode *head);
60 
62 
63 #endif /* ndef SLLIST_H */
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
void * find_sll_node(struct sllistnode *head, const void *searchobj, int(*comp)(const void *, const void *))
Find a node.
Definition: sllist.c:125
Singly linked list node.
Definition: sllist.h:26
static struct sllistnode * find_next_sll_node(struct sllistnode *focus)
Find the next node in the list.
Definition: sllist.h:46
Header file to ease portability.
#define END_C_DECLS
Use END_C_DECLS at the end of C declarations.
Definition: mge-portability.h:34
void * object
Attached object.
Definition: sllist.h:27
struct sllistnode * next
The subsequent node.
Definition: sllist.h:28
#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: mge-portability.h:30
struct sllistnode * free_sllist(struct sllistnode *head)
Free the entire list.
Definition: sllist.c:150
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