diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-30 10:36:49 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-30 10:36:49 +0100 |
| commit | aa9613efb6fb39bd96fc4836b5d38c3746af1b15 (patch) | |
| tree | 0fac2b661a860b3ca2e3effa868384290064f708 /src/lst/ft_lstremove_if.c | |
| parent | fe37597119353ce183fc404417b81bd4702f64b7 (diff) | |
| download | libft-aa9613efb6fb39bd96fc4836b5d38c3746af1b15.tar.gz libft-aa9613efb6fb39bd96fc4836b5d38c3746af1b15.tar.bz2 libft-aa9613efb6fb39bd96fc4836b5d38c3746af1b15.zip | |
hash table draft
Diffstat (limited to 'src/lst/ft_lstremove_if.c')
| -rw-r--r-- | src/lst/ft_lstremove_if.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lst/ft_lstremove_if.c b/src/lst/ft_lstremove_if.c new file mode 100644 index 0000000..2fa06a3 --- /dev/null +++ b/src/lst/ft_lstremove_if.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstremove_if.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/30 09:36:49 by cacharle #+# #+# */ +/* Updated: 2020/01/30 09:55:47 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_lstremove_if(t_list **lst, + t_ftbool (*equal)(void *ref, void *content), void *ref, + void (*del)(void *content)) +{ + t_list *saved_next; + + if (lst == NULL || *lst == NULL) + return ; + if (!equal(ref, &(*lst)->val)) + { + ft_lstremove_if(&(*lst)->next, equal, ref, del); + return ; + } + saved_next = (*lst)->next; + ft_lstdelone(*lst, del); + *lst = saved_next; + ref_ft_list_remove_if(lst, equal, ref, del); +} |
