diff options
Diffstat (limited to 'src/lst/ft_lstremove_if.c')
| -rw-r--r-- | src/lst/ft_lstremove_if.c | 19 |
1 files changed, 9 insertions, 10 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); } |
