diff options
Diffstat (limited to 'lib/linklist.c')
-rw-r--r-- | lib/linklist.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/linklist.c b/lib/linklist.c index 86649dd49..effd384e4 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -70,6 +70,26 @@ void listnode_add(struct list *list, void *val) list->count++; } +void listnode_add_head(struct list *list, void *val) +{ + struct listnode *node; + + assert(val != NULL); + + node = listnode_new(); + + node->next = list->head; + node->data = val; + + if (list->head == NULL) + list->head = node; + else + list->head->prev = node; + list->head = node; + + list->count++; +} + void listnode_add_sort(struct list *list, void *val) { struct listnode *n; |