aboutsummaryrefslogtreecommitdiff
path: root/list.h
diff options
context:
space:
mode:
Diffstat (limited to 'list.h')
-rw-r--r--list.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/list.h b/list.h
new file mode 100644
index 0000000..571b6d7
--- /dev/null
+++ b/list.h
@@ -0,0 +1,21 @@
+#ifndef LIST_H
+#define LIST_H
+
+#define list_add(Type, Head, Item) do {\
+ Item->next = Head; \
+ Head = Item; \
+ } while (0);
+
+#define list_remove(Type, Head, Item) do {\
+ Type **p; \
+ for (p = &Head; *p; p = &((*p)->next)) { \
+ if (*p = Item) { \
+ *p = Item->next; \
+ } \
+ } \
+ } while (0);
+
+#define list_foreach(Type, Head, Item) \
+ for (Item = Head; Item; Item = Item->next)
+
+#endif \ No newline at end of file