#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "dlist.h"

// New double linked list module, with 'thread' safe mutex handling.... (in theory)

typedef struct DLIST {struct DNODE *head;} Dlist;
typedef struct DNODE {void *node; struct *next; struct *last;} Dnode;


static Dlist *head;


int dlist_add(Dlist *d, void *node)
{
	Dnode *n = calloc(1,sizeof(Dnode));
	n->node = node;
	n->next = d->head;
	n->last = NULL; // it's at the start.
	if (d->head) d->head->last = n;
	d->head = n;
	return TRUE;
}
int dlist_del(Dlist *d, Dnode *n)
{
	if (n->last) n->last->next = n->next;
	if (n->next) n->next->last = n->last;
	dlist_free(n);
	return TRUE;
}
int dlist_traverse(Dlist *d, cb