/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_list_remove_if.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: whaffman +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/03 18:31:10 by whaffman #+# #+# */ /* Updated: 2024/07/03 18:56:38 by whaffman ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_list.h" void ft_list_remove_if( t_list **begin_list, void *data_ref, int (*cmp)(), void (*free_fct)(void *) ) { t_list *prev; t_list *curr; t_list *next; curr = *begin_list; while (curr) { next = curr->next; if (!cmp(curr->data, data_ref)) { if (curr == *begin_list) *begin_list = next; else prev->next = next; free_fct(curr->data); free(curr); } else prev = curr; curr = next; } }