lstclear fonctionne plus en recursive

This commit is contained in:
Hugo LAMY
2019-11-28 17:08:30 +01:00
parent ff5e4c9645
commit 1fc3aab389
3 changed files with 18 additions and 20 deletions

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:13:30 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:31:30 by hulamy ### ########.fr */
/* Updated: 2019/11/28 17:06:48 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -96,7 +96,12 @@
void ft_lstclear(t_list **lst, void (*del)(void *))
{
if ((*lst)->next)
ft_lstclear(&(*lst)->next, del);
ft_lstdelone(*lst, del);
t_list *next;
while (*lst != NULL)
{
next = (*lst)->next;
ft_lstdelone(*lst, del);
*lst = next;
}
}

View File

@@ -1,15 +1,3 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:13:30 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:31:30 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** delete and free an element of the list and all the followings
*/
@@ -96,7 +84,12 @@
void ft_lstclear(t_list **lst, void (*del)(void *))
{
if ((*lst)->next)
ft_lstclear(&(*lst)->next, del);
ft_lstdelone(*lst, del);
t_list *next;
while (*lst != NULL)
{
next = (*lst)->next;
ft_lstdelone(*lst, del);
*lst = next;
}
}

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:14:03 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:35:53 by hulamy ### ########.fr */
/* Updated: 2019/11/28 16:56:40 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */