-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstclear.c
40 lines (36 loc) · 1.34 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edegraev <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/13 15:28:03 by edegraev #+# #+# */
/* Updated: 2023/11/16 09:14:26 by edegraev ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *tmp;
if (!lst || !del)
return ;
while (*lst)
{
tmp = (*lst)->next;
ft_lstdelone(*lst, del);
(*lst) = tmp;
}
*lst = 0;
}
// #include <stdio.h>
// int main(void)
// {
// t_list *lst;
// lst = ft_lstnew("Hello");
// ft_lstadd_back(&lst, ft_lstnew("World"));
// ft_lstadd_back(&lst, ft_lstnew("Linda"));
// ft_lstclear(&lst, free);
// printf("%p\n", lst);
// return (0);
// }