#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include "util.h"
node->next = next;
node->prev = next ? next->prev : NULL;
if (node->next) node->next->prev = node;
- if (node->prev) node->next->next = node;
+ if (node->prev) node->prev->next = node;
return node;
}
+list_t *list_append(list_t *head, void *data)
+{
+ list_t *last = head;
+ while (last->next)
+ last = last->next;
+ list_t *node = new0(list_t);
+ node->data = data;
+ node->prev = last;
+ if (last) last->next = node;
+ return last ? head : node;
+}
+
list_t *list_remove(list_t *head, list_t *node)
{
list_t *next = node->next;
return len;
}
-void list_move(list_t *node, int offset)
+/* Misc */
+int error(char *fmt, ...)
{
+ va_list ap;
+ va_start(ap, fmt);
+ fprintf(stderr, "Error: ");
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+ exit(1);
+ return 0;
}