aboutsummaryrefslogtreecommitdiff
path: root/list/include/list.h
diff options
context:
space:
mode:
Diffstat (limited to 'list/include/list.h')
-rw-r--r--list/include/list.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/list/include/list.h b/list/include/list.h
new file mode 100644
index 0000000..b00b48b
--- /dev/null
+++ b/list/include/list.h
@@ -0,0 +1,21 @@
1/// A doubly linked list.
2///
3/// This list does not hold user data. Instead, the list can be used as an
4/// intrusive list or as part as a more complex data structure.
5#pragma once
6
7#include <stddef.h>
8
9typedef struct list list;
10
11typedef struct list {
12 list* prev;
13 list* next;
14} list;
15
16/// Create a new list from an array of `size` items.
17void list_make(list* list, size_t size);
18
19/// Iterates over all the items in the list.
20#define list_foreach(LIST, iter) \
21 for (struct list* iter = LIST; iter; iter = iter->next)