-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstclear.c
32 lines (29 loc) · 1.25 KB
/
ft_lstclear.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gpiccion <gpiccion@student.42wolfsburg. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/20 18:11:33 by gpiccion #+# #+# */
/* Updated: 2022/03/20 22:24:01 by gpiccion ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
// Deletes and frees the element 'lst' and every successor
// of that element, using the function 'del' and free(3).
// Sets pointer to the list to NULL.
void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *aux;
if (!lst || !del)
return ;
aux = *lst;
while (*lst)
{
aux = (*lst)->next;
ft_lstdelone(*lst, del);
*lst = aux;
}
*lst = NULL;
}