-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstclear.c
53 lines (47 loc) · 1.56 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yuske <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/31 06:46:37 by yuske #+# #+# */
/* Updated: 2023/04/04 13:55:52 by yuske ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
// lstclear: del==NULL で freel) していないのでleak [ko]
/**
* @brief
*
* @param node
* @param f_del
*/
// void ft_lstclear(t_list **node, void (*f_del)(void *))
// {
// t_list *tmp;
// if (node == NULL || f_del == NULL)
// return ;
// while (*node != NULL)
// {
// tmp = (*node)->next;
// ft_lstdelone(*node, f_del);
// (*node) = tmp;
// }
// }
void ft_lstclear(t_list **node, void (*f_del)(void *))
{
t_list *current;
t_list *next;
if (node == NULL || *node == NULL || f_del == NULL)
return ;
current = *node;
while (current != NULL)
{
next = current->next;
f_del(current->content);
free(current);
current = next;
}
*node = NULL;
}