-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstclear.c
More file actions
50 lines (44 loc) · 1.61 KB
/
ft_lstclear.c
File metadata and controls
50 lines (44 loc) · 1.61 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sparth <sparth@student.42heilbronn.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/18 16:31:16 by sparth #+# #+# */
/* Updated: 2023/10/20 11:55:56 by sparth ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *temp;
temp = *lst;
if (!lst)
return ;
while (*lst)
{
temp = temp->next;
ft_lstdelone(*lst, del);
*lst = temp;
}
}
// #include <stdio.h>
// static void helper(void *content)
// {
// free(content);
// }
// int main()
// {
// t_list *head = ft_lstnew(ft_strdup("Hello"));
// t_list *node2 = ft_lstnew(ft_strdup("cucu"));
// t_list *node3 = ft_lstnew(ft_strdup("byebye"));
// ft_lstadd_back(&head, node2);
// ft_lstadd_back(&head, node3);
// // printf("%s\n", node1->content);
// // printf("%s\n", ft_lstlast(node1)->content);
// ft_lstclear(&head, helper);
// // printf("%s\n", node1->content);
// if(head == NULL)
// printf("Head == 0");
// }