summaryrefslogtreecommitdiff
path: root/src/ll.h
blob: 154cfe22d6349abea6abedb9a88c1995372cabdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef __VXGG_REWRITE___LL_H___305861098005___
#define __VXGG_REWRITE___LL_H___305861098005___

// Notice: dlinked functions are no longer necessarily xalloc, but MAY be IF the `___VXGG___USE_XALLOC_FOR_VALLOC___` is greater than 0

/* TODO: Implement a way to register a set of alloc functions to a linked list so I can give it arenas for memory allocation
// instead of just xcalloc */
    // I don't know if I care to do this right now. I might be able to hack it in but it would be a fugly hack, something as bad if not worse than that weird callback thing I was doing with the ALWAYS_CHECK_LIBSODIUM macro

typedef void (*dll_freecb)(void*);
typedef struct dlinked dlinkedlist;

#ifndef __VXGG_REWRITE___LL_INTERNAL___

dlinkedlist * dlinkedlist_init(void);
void dlinkedlist_free(dlinkedlist *ll);
int dlinkedlist_append(dlinkedlist * const ll, void *data, dll_freecb fcb);
int dlinkedlist_prepend(dlinkedlist * const ll, void *data, dll_freecb fcb);
int dlinkedlist_insert(dlinkedlist * const ll, void *data, dll_freecb fcb, int index);
void* dlinkedlist_get(const dlinkedlist * const ll, int index);
int dlinkedlist_remove(dlinkedlist * const ll, int index);
void * dlinkedlist_poplast(dlinkedlist *ll);

int dlinkedlist_size(const dlinkedlist * const ll);
#define dlinkedlist_isempty(ll) (dlinkedlist_size((ll)) == 0)

int dlinkedlist_foreach(dlinkedlist *ll, int (*callback)(void*));

#endif

#endif