From 82b27616de634964db1a71bd5d9813db71e391a1 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 26 Jul 2001 07:00:09 +0000 Subject: mdctl-v0.4 --- dlink.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 dlink.h (limited to 'dlink.h') diff --git a/dlink.h b/dlink.h new file mode 100644 index 0000000..aa178e6 --- /dev/null +++ b/dlink.h @@ -0,0 +1,25 @@ + +/* doubley linked lists */ +/* This is free software. No strings attached. No copyright claimed */ + +struct __dl_head +{ + struct __dl_head * dh_prev; + struct __dl_head * dh_next; +}; + +#define dl_alloc(size) ((void*)(((char*)calloc(1,(size)+sizeof(struct __dl_head)))+sizeof(struct __dl_head))) +#define dl_new(t) ((t*)dl_alloc(sizeof(t))) +#define dl_newv(t,n) ((t*)dl_alloc(sizeof(t)*n)) + +#define dl_next(p) *((void**)&(((struct __dl_head*)(p))[-1].dh_next)) +#define dl_prev(p) *((void**)&(((struct __dl_head*)(p))[-1].dh_prev)) + +void *dl_head(); +char *dl_strdup(char *); +char *dl_strndup(char *, int); +void dl_insert(void*, void*); +void dl_add(void*, void*); +void dl_del(void*); +void dl_free(void*); +void dl_init(void*); -- cgit