-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstclear.c
56 lines (50 loc) · 1.75 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: elel-yak <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/11 20:29:12 by elel-yak #+# #+# */
/* Updated: 2022/10/26 11:02:51 by elel-yak ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *tmp;
if (!(lst && del))
return ;
while (*lst != 0)
{
tmp = *lst;
*lst = (*lst)->next;
ft_lstdelone(tmp, del);
}
*lst = 0;
}
// void ft_del(void *content)
// {
// printf("%s\n", content);
// }
// int main()
// {
// t_list *head;
// t_list *second;
// t_list *third;
// t_list *fourth;
// t_list *ptr;
// head = (t_list *)malloc(sizeof(t_list));
// second = (t_list *)malloc(sizeof(t_list));
// third = (t_list *)malloc(sizeof(t_list));
// fourth = (t_list *)malloc(sizeof(t_list));
// head->content = "one";
// head->next = second;
// second->content = "two";
// second->next = third;
// third->content = "three";
// third->next = fourth;
// fourth->content = "last";
// fourth->next = NULL;
// ft_lstclear(&head, ft_del);
// }