-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstdelone.c
56 lines (51 loc) · 1.6 KB
/
ft_lstdelone.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_lstdelone.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thuy-ngu <thuy-ngu@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/02 21:22:25 by thuy-ngu #+# #+# */
/* Updated: 2023/10/21 20:22:14 by thuy-ngu ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*static void ft_del(void *ptr)
{
ptr = NULL;
return ;
}*/
void ft_lstdelone(t_list *lst, void (*del)(void *))
{
if (!lst)
return ;
del(lst->content);
free(lst);
}
/*int main()
{
t_list *list = NULL;
char *s1 = "Content 1";
char *s2 = "Content 2";
char *s3 = "Content 3";
char *s4 = "Content 4";
t_list *n1 = ft_lstnew(s1);
t_list *n2 = ft_lstnew(s2);
t_list *n3 = ft_lstnew(s3);
t_list *n4 = ft_lstnew(s4);
list = n1;
n1->next = n2;
n2->next = n3;
n3->next = n4;
n4->next = NULL;
while(list)
{
printf("%s\n", (char *)list->content);
list = list->next;
}
ft_lstdelone(list, ft_del);
ft_lstdelone(n1, ft_del);
ft_lstdelone(n2, ft_del);
ft_lstdelone(n3, ft_del);
ft_lstdelone(n4, ft_del);
}*/