Add/update tests.
[eruntime.git] / include / eruntime / list.h
blob4d92ba3265943db43e31683e5ce10ec8bf5c71b5
1 #ifndef ERUNTIME_LIST_H
2 # define ERUNTIME_LIST_H
4 # include <inttypes.h>
6 # define LIST_FOREACH(list, cur) \
7 for ((cur) = (list)->head; (cur); (cur) = (cur)->next)
9 typedef struct _list_node_struct list_node_t;
11 typedef struct _list_struct
13 /* list head pointer. */
14 list_node_t *head;
16 /* list tail pointer. */
17 list_node_t *tail;
19 /* list length. */
20 uint32_t length;
22 } list_t;
24 struct _list_node_struct
26 /* pointer to previous node in the chain. */
27 list_node_t *prev;
29 /* pointer to next node in the chain. */
30 list_node_t *next;
32 /* pointer to node data. */
33 void *data;
36 typedef void (*list_apply_func_t) (void *, void *);
38 int8_t list_init (list_t *list);
39 list_t *list_create (void);
40 int8_t list_append (list_t *list, void *data);
41 int8_t list_prepend (list_t *list, void *data);
42 int32_t list_apply (list_t *list, list_apply_func_t func, void *arg);
43 void list_clear (list_t *list);
44 void list_destroy (list_t *list);
46 #endif /* ! ERUNTIME_LIST_H */
49 * vim: ts=8 sw=8 noet fdm=marker tw=80