-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstclear.c
32 lines (28 loc) · 1.27 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: gubranco <gubranco@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/30 12:44:39 by gubranco #+# #+# */
/* Updated: 2022/12/04 16:20:04 by gubranco ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *no;
if (lst == NULL)
return ;
while (*lst != NULL)
{
no = (*lst)->next;
ft_lstdelone(*lst, del);
*lst = no;
}
*lst = NULL;
}
/* Deletes and frees the given node and every successor of that node, using
the function ’del’ and free(3). Finally, the pointer to the list must be
set to NULL. It returns nothing. */