Append should create a new list when given a NULL head

This commit is contained in:
Andrew Miner
2024-03-09 18:30:37 -07:00
committed by GitHub
parent 8c290a2e7c
commit 97688b1436
+3 -1
View File
@@ -51,7 +51,9 @@ LinkedListNode* LinkedList_prepend(LinkedListNode *head, int value) {
// Add a value to the end of the linked list
LinkedListNode* LinkedList_append(LinkedListNode *head, int value) {
if (head == NULL) return NULL;
if (head == NULL) {
return LinkedList_new(value);
}
LinkedListNode *current = head;
while (current->next != NULL) {