diff options
Diffstat (limited to 'libs/libc/list.c')
-rw-r--r-- | libs/libc/list.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/libs/libc/list.c b/libs/libc/list.c index c86b23d..1fc9a55 100644 --- a/libs/libc/list.c +++ b/libs/libc/list.c @@ -15,8 +15,6 @@ struct list *list_new(void) void list_destroy(struct list *list) { - if (!list) - return; struct node *iterator = list->head; while (iterator != NULL) { if (iterator->next == NULL) { @@ -41,11 +39,8 @@ static struct node *list_new_node(void) return node; } -static struct node *list_add_node(struct list *list, struct node *node) +NONNULL static struct node *list_add_node(struct list *list, struct node *node) { - if (!list || !node) - return NULL; - if (list->head == NULL) { list->head = node; return list->head; @@ -65,7 +60,7 @@ static struct node *list_add_node(struct list *list, struct node *node) struct node *list_last(struct list *list) { - if (!list || !list->head) + if (list->head) return NULL; struct node *iterator = list->head; @@ -80,7 +75,7 @@ struct node *list_last(struct list *list) struct node *list_first_data(struct list *list, void *data) { - if (!list || !list->head || !data) + if (!list->head) return NULL; struct node *iterator = list->head; @@ -96,7 +91,7 @@ struct node *list_first_data(struct list *list, void *data) // TODO: Actually swap the nodes, not the data struct list *list_swap(struct list *list, struct node *a, struct node *b) { - if (!list || !list->head || !a || !b) + if (!list->head) return NULL; void *tmp = a->data; @@ -116,7 +111,7 @@ struct node *list_add(struct list *list, void *data) // Maybe list_remove_node? struct list *list_remove(struct list *list, struct node *node) { - if (!list || !list->head || !node) + if (!list->head) return NULL; if (list->head == node) { |