]> git.neil.brown.name Git - metad.git/blob - dlink.h
Assorted reformating
[metad.git] / dlink.h
1
2 /* doubley linked lists */
3
4 struct __dl_head
5 {
6     struct __dl_head *  dh_prev;
7     struct __dl_head *  dh_next;
8 };
9
10 #define dl_alloc(size)  ((void*)(((char*)calloc(1,(size)+sizeof(struct __dl_head)))+sizeof(struct __dl_head)))
11 #define dl_new(t)       ((t*)dl_alloc(sizeof(t)))
12 #define dl_newv(t,n)    ((t*)dl_alloc(sizeof(t)*n))
13
14 #define dl_next(p) *((void**)&(((struct __dl_head*)(p))[-1].dh_next))
15 #define dl_prev(p) *((void**)&(((struct __dl_head*)(p))[-1].dh_prev))
16
17 void *dl_head();
18 char *dl_strdup(char *);
19 char *dl_strndup(char *, int);
20 void dl_insert(void*, void*);
21 void dl_add(void*, void*);
22 void dl_del(void*);
23 void dl_free(void*);