aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_lstclear.c
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-21 17:33:28 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-21 17:33:28 +0100
commit7a34b3d412f5022d4ce25d84ec7fb4002b1fb5db (patch)
tree9546a74914e750e747adb2d9adcd7b67f96adf24 /src/ft_lstclear.c
parent9bb8e5cd549eca189ce183f40f771c2a614ea8f6 (diff)
downloadLibft-7a34b3d412f5022d4ce25d84ec7fb4002b1fb5db.tar.gz
Libft-7a34b3d412f5022d4ce25d84ec7fb4002b1fb5db.zip
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.
Diffstat (limited to 'src/ft_lstclear.c')
-rw-r--r--src/ft_lstclear.c19
1 files changed, 19 insertions, 0 deletions
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 <stdlib.h>
+
+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;
+}