From 2d5e1fa41c65c70ad18c5912a79190d08e6d9e98 Mon Sep 17 00:00:00 2001 From: justanothercatgirl Date: Sat, 31 Aug 2024 16:25:24 +0300 Subject: Fixed ll_remove_elem bug --- include/container.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/container.h') diff --git a/include/container.h b/include/container.h index db4fa4f..c84b894 100644 --- a/include/container.h +++ b/include/container.h @@ -897,9 +897,13 @@ void ll_remove_elem(struct linked_list* list, const void* elem, qsort_cmp_t cmp) *snd = fst->next; while (snd != NULL) { if (cmp(snd->data, elem) == 0) { + if (snd->next == NULL) list->last = fst; fst->next = ll_free_node(list, snd); + --list->meta.assumed_size; return; } + fst = snd; + snd = snd->next; } if (cmp(fst->data, elem) == 0) ll_remove_back(list); } -- cgit v1.2.3-70-g09d2