-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstclear_bonus.c
More file actions
50 lines (44 loc) · 1.55 KB
/
ft_lstclear_bonus.c
File metadata and controls
50 lines (44 loc) · 1.55 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_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lcosta-g <lcosta-g@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/09 13:19:16 by lcosta-g #+# #+# */
/* Updated: 2024/10/26 14:10:45 by lcosta-g ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *temp;
if (!lst || !*lst || !del)
return ;
while (*lst)
{
temp = (*lst)->next;
ft_lstdelone(*lst, del);
*lst = temp;
}
}
/*
static void del_tester(void *content)
{
ft_bzero(content, ft_strlen((char *)content));
}
#include <stdio.h>
int main(void)
{
t_list *lst;
t_list *node;
char s1[] = "node 1";
char s2[] = "node 2";
lst = ft_lstnew(s1);
node = ft_lstnew(s2);
ft_lstadd_back(&lst, node);
printf("Before clear: %s, %s\n", (char *)lst->content, (char *)node->content);
ft_lstclear(&lst, del_tester);
printf("After clear: %s, %s\n", (char *)lst->content, (char *)node->content);
}
*/