current -> tail in zad2

This commit is contained in:
jacekpoz 2024-03-11 01:34:25 +01:00
parent f2f78e0cfa
commit 685d4db676
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -28,13 +28,13 @@ void linked_list_insert(LinkedList *l, void *value) {
return; return;
} }
Node *current = l->head; Node *tail = l->head;
while (current->next != l->head) { while (tail->next != l->head) {
current = current->next; tail = tail->next;
} }
current->next = node_new(value, l->element_size); tail->next = node_new(value, l->element_size);
current->next->next = l->head; tail->next->next = l->head;
l->length += 1; l->length += 1;
} }