-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstclear.c
38 lines (35 loc) · 1.36 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
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rdragan <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/06 10:47:53 by rdragan #+# #+# */
/* Updated: 2023/04/26 16:39:09 by rdragan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
Deletes and frees the given node and every successor of that node,
using the function del and free. Finally the pointer to the
list must be set NULL.
@param lst: address of the list
@param del: address of the function used to delete the content
of the node
*/
void ft_lstclear(t_list **lst)
{
t_list *temp1;
t_list *temp2;
if (lst == NULL)
return ;
temp1 = *lst;
while (temp1)
{
temp2 = temp1->next;
ft_lstdelone(temp1);
temp1 = temp2;
}
*lst = NULL;
}