aboutsummaryrefslogtreecommitdiff
path: root/ft_lstclear_bonus.c
diff options
context:
space:
mode:
Diffstat (limited to 'ft_lstclear_bonus.c')
-rw-r--r--ft_lstclear_bonus.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/ft_lstclear_bonus.c b/ft_lstclear_bonus.c
new file mode 100644
index 0000000..933b6d5
--- /dev/null
+++ b/ft_lstclear_bonus.c
@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_lstclear_bonus.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/10/09 09:02:39 by cacharle #+# #+# */
+/* Updated: 2019/10/09 09:08:22 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+#include "libft_bonus.h"
+
+void ft_lstclear(t_list **lst, void (*del)(void *))
+{
+ t_list *tmp;
+
+ while (*lst != NULL)
+ {
+ tmp = (*lst)->next;
+ (*del)((*lst)->content);
+ free(*lst);
+ *lst = tmp;
+ }
+}