aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/linked_list.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/linked_list.c b/src/linked_list.c
index 2023c65..12cfd9b 100644
--- a/src/linked_list.c
+++ b/src/linked_list.c
@@ -24,10 +24,14 @@ void linked_list_delete(LinkedList *ll) {
}
LinkedListNode *linked_list_append(LinkedList *ll, void *elem) {
- LinkedListNode *new_node = calloc(1, sizeof(LinkedListNode));
+ LinkedListNode *new_node = malloc(sizeof(LinkedListNode));
if (!new_node)
return NULL;
- new_node->data = elem;
+ *new_node = (LinkedListNode) {
+ .data = elem,
+ .next = NULL,
+ .prev = ll->tail,
+ };
if (!ll->head) {
new_node->prev = NULL;