add scc and update other code
[ccc.git] / list.h
diff --git a/list.h b/list.h
new file mode 100644 (file)
index 0000000..1cc3fb2
--- /dev/null
+++ b/list.h
@@ -0,0 +1,19 @@
+#ifndef LIST_H
+#define LIST_H
+
+#include <stdbool.h>
+
+#define FOREACH(x, l) for(struct list *x = l; x != NULL; x = x->tail)
+
+struct list {
+       void *el;
+       struct list *tail;
+};
+
+struct list *list_append(void *el, struct list *head);
+struct list *list_cons(void *el, struct list *tail);
+void list_free(struct list *head, void (*freefun)(void *));
+void **list_to_array(struct list *list, int *num, bool reverse);
+int list_length(struct list *head);
+
+#endif