-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstclear.c
67 lines (60 loc) · 1.74 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
57
58
59
60
61
62
63
64
65
66
67
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nmattera <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/19 11:23:55 by nmattera #+# #+# */
/* Updated: 2022/05/23 11:40:35 by nmattera ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *tmp;
if (!del)
return ;
while (*lst)
{
tmp = (*lst)->next;
ft_lstdelone(*lst, del);
(*lst) = tmp;
}
lst = NULL;
}
/* #include <stdio.h>
void del(void *go)
{
free(go);
}
int main()
{
char *str;
char *stir;
char *stor;
t_list *first;
t_list *second;
t_list *third;
t_list *lecture;
int i;
str = ft_strdup("bim");
stir = ft_strdup("bam");
stor = ft_strdup("bom");
lecture = malloc(sizeof(t_list));
lecture->next = third;
first = ft_lstnew(str);
second = ft_lstnew(stir);
third = ft_lstnew(stor);
ft_lstadd_back(&first, second);
ft_lstadd_back(&first, third);
ft_lstclear(&second,&del);
i = 0;
while(first->next)
{
printf("%s", (char *)first->content);
first = first->next;
}
printf("%s", (char *)first->content);
}
*/