From 30efa292790dfdc9eedefa97a9f82e1cac2aeaa0 Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 24 Oct 2025 12:44:06 -0500 Subject: add alloc/dealloc functions for generic linked list --- lichen.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'lichen.h') diff --git a/lichen.h b/lichen.h index fe68d52..b30c8cb 100644 --- a/lichen.h +++ b/lichen.h @@ -1,9 +1,10 @@ #ifndef LICHEN_H #define LICHEN_H +#include #include -// random number generation +/* --===== random number generation =====-- */ typedef struct li_rand32_t { uint32_t (*rand)(void *); void *state; @@ -21,4 +22,28 @@ void li_xorshift32_seed(struct li_xorshift32_t *xor, uint32_t seed); uint32_t li_xorshift32(void *s); +/* --===== generic linked lists =====-- */ + + +typedef struct li_llnode_t { + int tag; + void *data; + struct li_llnode_t *next; +} li_llnode_t; + + +li_llnode_t * li_alloc_llnode(); +li_llnode_t * li_copy_llnode(li_llnode_t *n); +void li_free_llnode(li_llnode_t *n, void (*free_data)(void*)); + + +typedef struct li_ll_t { + int tag; + size_t count; + li_llnode_t *head; +} li_ll_t; + + + + #endif -- cgit v1.2.1