Redo tail to use optargs and optionally support lseek. Add support to optargs and llist.c, plus add a test suite entry. Still no -f support though.
diff --git a/lib/llist.c b/lib/llist.c
index c6e7da3..8588721 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -35,18 +35,24 @@
return (void *)next;
}
+void dlist_add_nomalloc(struct double_list **list, struct double_list *new)
+{
+ if (*list) {
+ new->next = *list;
+ new->prev = (*list)->prev;
+ (*list)->prev->next = new;
+ (*list)->prev = new;
+ } else *list = new->next = new->prev = new;
+}
+
+
// Add an entry to the end of a doubly linked list
struct double_list *dlist_add(struct double_list **list, char *data)
{
- struct double_list *line = xmalloc(sizeof(struct double_list));
+ struct double_list *new = xmalloc(sizeof(struct double_list));
- line->data = data;
- if (*list) {
- line->next = *list;
- line->prev = (*list)->prev;
- (*list)->prev->next = line;
- (*list)->prev = line;
- } else *list = line->next = line->prev = line;
+ new->data = data;
+ dlist_add_nomalloc(list, new);
- return line;
+ return new;
}