summaryrefslogtreecommitdiff
path: root/ft_lstclear_bonus.c
diff options
context:
space:
mode:
authorDominik Kaiser2024-03-10 19:10:22 +0100
committerDominik Kaiser2024-03-10 19:10:22 +0100
commitbd89cee6a4fa8ca6c212632a48d1647e44a9e46c (patch)
tree0a44e91843491aa31645bcdc160754711b4eeff0 /ft_lstclear_bonus.c
parentb356e8552cad748418163bf3ad1da95e88937a38 (diff)
downloadlibft-bd89cee6a4fa8ca6c212632a48d1647e44a9e46c.tar.gz
libft-bd89cee6a4fa8ca6c212632a48d1647e44a9e46c.zip
Bonus
Diffstat (limited to 'ft_lstclear_bonus.c')
-rw-r--r--ft_lstclear_bonus.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/ft_lstclear_bonus.c b/ft_lstclear_bonus.c
new file mode 100644
index 0000000..9af095e
--- /dev/null
+++ b/ft_lstclear_bonus.c
@@ -0,0 +1,32 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_lstclear_bonus.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/03/10 16:26:23 by dkaiser #+# #+# */
+/* Updated: 2024/03/10 16:35:46 by dkaiser ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void ft_lstclear(t_list **lst, void (*del)(void *))
+{
+ t_list *current;
+ t_list *next;
+
+ if (*lst)
+ {
+ current = *lst;
+ while (current->next)
+ {
+ next = current->next;
+ ft_lstdelone(current, del);
+ current = next;
+ }
+ ft_lstdelone(current, del);
+ }
+ *lst = NULL;
+}