From 7a34b3d412f5022d4ce25d84ec7fb4002b1fb5db Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Sat, 21 Feb 2026 17:33:28 +0100 Subject: Implement libft Part 3 (linked lists) with tests Add t_list struct and 9 linked list functions: ft_lstnew, ft_lstadd_front, ft_lstsize, ft_lstlast, ft_lstadd_back, ft_lstdelone, ft_lstclear, ft_lstiter, ft_lstmap. --- src/ft_lstclear.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/ft_lstclear.c (limited to 'src/ft_lstclear.c') diff --git a/src/ft_lstclear.c b/src/ft_lstclear.c new file mode 100644 index 0000000..4c738b7 --- /dev/null +++ b/src/ft_lstclear.c @@ -0,0 +1,19 @@ +#include "libft.h" +#include + +void +ft_lstclear (t_list **lst, void (*del) (void *)) +{ + t_list *cur; + t_list *next; + + cur = *lst; + while (cur) + { + next = cur->next; + del (cur->content); + free (cur); + cur = next; + } + *lst = NULL; +} -- cgit v1.2.3