rtl433  UNKNOWN
RTL-433 utility
list.h
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_LIST_H_
13 #define INCLUDE_LIST_H_
14 
15 #include <stddef.h>
16 
18 typedef struct list {
19  void **elems;
20  size_t size;
21  size_t len;
22 } list_t;
23 
24 typedef void (*list_elem_free_fn)(void *);
25 
27 void list_ensure_size(list_t *list, size_t min_size);
28 
30 void list_push(list_t *list, void *p);
31 
33 void list_push_all(list_t *list, void **p);
34 
36 void list_remove(list_t *list, size_t idx, list_elem_free_fn elem_free);
37 
39 void list_clear(list_t *list, list_elem_free_fn elem_free);
40 
43 
44 #endif /* INCLUDE_LIST_H_ */
struct list list_t
Dynamically growing list, elems is always NULL terminated, call list_ensure_size() to alloc elems...
void list_remove(list_t *list, size_t idx, list_elem_free_fn elem_free)
Remove element from the list, frees element with fn.
Definition: list.c:41
void list_ensure_size(list_t *list, size_t min_size)
Alloc elems if needed and ensure the list has room for at least min_size elements.
Definition: list.c:15
void list_clear(list_t *list, list_elem_free_fn elem_free)
Clear the list, frees each element with fn, does not free backing or list itself. ...
Definition: list.c:55
void ** elems
Definition: list.h:19
void(* list_elem_free_fn)(void *)
Definition: list.h:24
void list_free_elems(list_t *list, list_elem_free_fn elem_free)
Clear the list, free backing, does not free list itself.
Definition: list.c:68
void list_push(list_t *list, void *p)
Add to the end of elems, allocs or grows the list if needed and ensures the list has a terminating NU...
Definition: list.c:25
Dynamically growing list, elems is always NULL terminated, call list_ensure_size() to alloc elems...
Definition: list.h:18
size_t len
Definition: list.h:21
void list_push_all(list_t *list, void **p)
Adds all elements of a NULL terminated list to the end of elems, allocs or grows the list if needed a...
Definition: list.c:35
size_t size
Definition: list.h:20