-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstdelone_bonus.c
More file actions
51 lines (45 loc) · 1.68 KB
/
Copy pathft_lstdelone_bonus.c
File metadata and controls
51 lines (45 loc) · 1.68 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdelone_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: simarcha <simarcha@student.42barcel> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/21 15:32:42 by simarcha #+# #+# */
/* Updated: 2024/10/05 23:04:55 by simarcha ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*void del(void *content)
{
free(content);
content = NULL;
}*/
void ft_lstdelone(t_list *lst, void (*del)(void *))
{
if (!lst || !del)
return ;
(*del)(lst->content);
free(lst);
lst = NULL;
}
/*#include <stdio.h>
int main(void)
{
t_list **node1;
char *content;
node1 = NULL;
content = ft_strdup("a");
*node1 = ft_lstnew(content);
printf("content %p\n", content);
printf("node1->content %p\n", (*node1)->content);
printf("node1 %p\n", *node1);
printf("%s\n", (char *)(*node1)->content);
printf("calling ft_lstdelone\n");
ft_lstdelone(*node1, del);
printf("it will give us segfault because now the ppointer is freed");
// printf("node1 %p\n", *node1);
// printf("node1->content %p\n", (*node1)->content);
printf("%s\n", (char *)node1->content);
return (0);
}*/