-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstclear.c
57 lines (45 loc) · 1.48 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
54
55
56
57
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ael-haib <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/13 00:59:17 by ael-haib #+# #+# */
/* Updated: 2024/02/15 00:46:39 by ael-haib ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *tmp;
tmp = NULL;
while (*lst)
{
tmp = (*lst)->next;
ft_lstdelone(*lst, del);
*lst = tmp;
}
*lst = NULL;
}
/* void leaks(void)
{
system("leaks -q a.out");
}
int main(void)
{
atexit(leaks);
char *s = ft_strdup("hello");
char *s2 = ft_strdup("world");
t_list *head = NULL;
ft_lstadd_back(&head, ft_lstnew(s));
ft_lstadd_back(&head, ft_lstnew(s2));
t_list *tmp = head;
while (tmp != NULL)
{
printf("the content of the lst's %s\n", tmp->content);
tmp = tmp->next;
}
ft_lstclear(&head, free);
return (0);
} */