From ef9ab1fd141f4057d41f2d6ed8ab8d67c44894d5 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Thu, 9 Jan 2025 16:32:55 -0800 Subject: save state --- src/include/list.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/include/list.h (limited to 'src/include/list.h') diff --git a/src/include/list.h b/src/include/list.h new file mode 100644 index 0000000..055106a --- /dev/null +++ b/src/include/list.h @@ -0,0 +1,36 @@ +#ifndef LIST_H +#define LIST_H +#include +#include + +typedef struct NODE_STRUCT { + void *item; + struct NODE_STRUCT *next; + struct NODE_STRUCT *prev; +} node_t; + +typedef struct { + size_t size; + node_t *head; + node_t *tail; +} list_t; + +node_t *init_node(void *item); + +void node_free(void *x, void (*freefunc)(void *)); + +list_t *init_list(); + +void list_push_front(list_t *l, void *x); + +void list_push_back(list_t *l, void *x); + +void *list_pop_back(list_t *l); + +void *list_pop_front(list_t *l); + +bool list_is_empty(list_t *l); + +void list_free(void *x, void (*freefunc)(void *)); + +#endif -- cgit