-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstclear_bonus.c
40 lines (36 loc) · 1.35 KB
/
ft_lstclear_bonus.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
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rruiz-sa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/07 19:35:17 by rruiz-sa #+# #+# */
/* Updated: 2022/10/13 19:40:00 by rruiz-sa ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *temp;
if (*lst)
{
while (*lst)
{
temp = (*lst)-> next;
ft_lstdelone(*lst, del);
*lst = temp;
}
*lst = NULL;
}
}
/*
1- IF lst exist, Iterate lst
2- Save next of lst in a temp list
3- Call lstdelone
4- Lst its equal to temp (next)
5- When finish iteration close lst
[Description ft_lstdelone]
1- If lst exist call del and sent the content of lst
2- Free the memory of lst
*/