aboutsummaryrefslogtreecommitdiff
path: root/src/lst/ft_lstremove_if.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-02-16 04:51:41 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-16 04:51:41 +0100
commit01b4cc91d1596cf94d709a627ed8ad64bc1e285d (patch)
tree8b15a7758247ed4d4a084bccefedbf426ddfd305 /src/lst/ft_lstremove_if.c
parentbf4dc8e5c1dbb8149f0cab473f73b5e9bac24ae0 (diff)
downloadlibft-01b4cc91d1596cf94d709a627ed8ad64bc1e285d.tar.gz
libft-01b4cc91d1596cf94d709a627ed8ad64bc1e285d.tar.bz2
libft-01b4cc91d1596cf94d709a627ed8ad64bc1e285d.zip
Filled lst* tests
Diffstat (limited to 'src/lst/ft_lstremove_if.c')
-rw-r--r--src/lst/ft_lstremove_if.c19
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);
}