-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstdelone.c
49 lines (42 loc) · 1.53 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdelone.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sizerese <sizerese@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/08 19:53:21 by sizerese #+# #+# */
/* Updated: 2023/08/18 18:23:59 by sizerese ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstdelone(t_list *lst, void (*del)(void *))
{
t_list *ptr;
if (!lst || !del)
return ;
ptr = lst;
del(ptr->content);
free(lst);
}
// /*main*/
// void ft_del(void *ptr)
// {
// free(ptr);
// }
// int main(void)
// {
// t_list *head;
// t_list *node;
// head = ft_lstnew(ft_strdup("hello"));
// head->next = NULL;
// node = ft_lstnew(ft_strdup("what"));
// node->next = NULL;
// head->next = node;
// node = ft_lstnew(ft_strdup("there"));
// node->next = NULL;
// head->next->next = node;
// printf("before: %s\n", head->next->content);
// ft_lstdelone(head->next, ft_del);
// printf("After: %s\n", head->next->content);
// }