aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/inc/list.h2
-rw-r--r--libc/list.c11
2 files changed, 7 insertions, 6 deletions
diff --git a/libc/inc/list.h b/libc/inc/list.h
index 5deaf59..0a5c6c0 100644
--- a/libc/inc/list.h
+++ b/libc/inc/list.h
@@ -19,7 +19,7 @@ struct node {
struct list *list_new();
/* struct node *list_new_node(); */ // TODO: Make node-specific things static/private?
/* void list_add_node(struct list *list, struct node *node); */
-void list_add(struct list *list, void *data);
+struct node *list_add(struct list *list, void *data);
void list_remove(struct list *list, struct node *node);
#endif
diff --git a/libc/list.c b/libc/list.c
index c36d6e1..89de4d0 100644
--- a/libc/list.c
+++ b/libc/list.c
@@ -23,14 +23,14 @@ struct node *list_new_node()
return node;
}
-void list_add_node(struct list *list, struct node *node)
+struct node *list_add_node(struct list *list, struct node *node)
{
if (list == NULL)
- return;
+ return NULL;
if (list->head == NULL) {
list->head = node;
- return;
+ return list->head;
}
struct node *iterator = list->head;
@@ -42,13 +42,14 @@ void list_add_node(struct list *list, struct node *node)
}
iterator = iterator->next;
}
+ return node;
}
-void list_add(struct list *list, void *data)
+struct node *list_add(struct list *list, void *data)
{
struct node *node = list_new_node();
node->data = data;
- list_add_node(list, node);
+ return list_add_node(list, node);
}
// Maybe list_remove_node?