From 01b4cc91d1596cf94d709a627ed8ad64bc1e285d Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 16 Feb 2020 04:51:41 +0100 Subject: Filled lst* tests --- src/lst/ft_lstremove_if.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/lst/ft_lstremove_if.c') diff --git a/src/lst/ft_lstremove_if.c b/src/lst/ft_lstremove_if.c index a597c2e..488539e 100644 --- a/src/lst/ft_lstremove_if.c +++ b/src/lst/ft_lstremove_if.c @@ -6,28 +6,27 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 09:36:49 by cacharle #+# #+# */ -/* Updated: 2020/01/30 09:55:47 by cacharle ### ########.fr */ +/* Updated: 2020/02/16 03:57:07 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" #include "libft_lst.h" -void ft_lstremove_if(t_ftlst **lst, - t_ftbool (*equal)(void *ref, void *content), void *ref, - void (*del)(void *content)) +void ft_lstremove_if(t_ftlst **lst, t_ftcompar_func cmp, + const void *ref, t_ftdel_func del) { t_ftlst *saved_next; if (lst == NULL || *lst == NULL) return ; - if (!equal(ref, &(*lst)->content)) + if (cmp((*lst)->content, ref) == 0) { - ft_lstremove_if(&(*lst)->next, equal, ref, del); + saved_next = (*lst)->next; + ft_lstdelone(*lst, del); + *lst = saved_next; + ft_lstremove_if(lst, cmp, ref, del); return ; } - saved_next = (*lst)->next; - ft_lstdelone(*lst, del); - *lst = saved_next; - ft_lstremove_if(lst, equal, ref, del); + ft_lstremove_if(&(*lst)->next, cmp, ref, del); } -- cgit