aboutsummaryrefslogtreecommitdiff
path: root/src/linked_list.c
diff options
context:
space:
mode:
authorMikkel Thestrup <mithe24@student.sdu.dk>2025-12-11 14:43:42 +0100
committerMikkel Thestrup <mithe24@student.sdu.dk>2025-12-11 14:43:42 +0100
commit5042c3b3fab94d32a3485a736378058e9b4c7e28 (patch)
tree2cf0dfdf53fc725b4f213a1ce34458969f7d7c08 /src/linked_list.c
parent6a2e3b59754dad7d013179bd2cb53c1a802c2046 (diff)
downloadcycle-detector-5042c3b3fab94d32a3485a736378058e9b4c7e28.tar.gz
cycle-detector-5042c3b3fab94d32a3485a736378058e9b4c7e28.zip
Meant to use malloc and not calloc
Diffstat (limited to '')
-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;