-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstclear_bonus.c
More file actions
54 lines (46 loc) · 1.6 KB
/
ft_lstclear_bonus.c
File metadata and controls
54 lines (46 loc) · 1.6 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
51
52
53
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mjusta <mjusta@student.42prague.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/29 11:59:43 by mjusta #+# #+# */
/* Updated: 2025/05/29 12:24:49 by mjusta ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *temp;
if (!lst || !del)
return ;
while (*lst)
{
temp = (*lst)->next;
ft_lstdelone(*lst, del);
*lst = temp;
}
*lst = NULL;
}
/*
#include <stdio.h>
void del_content(void *content)
{
printf("Deleting content: %s\n", (char *)content);
free(content);
}
int main(void)
{
t_list *node1 = ft_lstnew(ft_strdup("Hello"));
t_list *node2 = ft_lstnew(ft_strdup("World"));
t_list *node3 = ft_lstnew(ft_strdup("42Prague"));
node1->next = node2;
node2->next = node3;
ft_lstclear(&node1, del_content);
printf("Content deleted.");
if (!node1)
printf("List cleared successfully!\n");
else
printf("List not fully cleared!\n");
}*/