aboutsummaryrefslogtreecommitdiff
path: root/libft/src/vec/ft_vecdestroy.c
diff options
context:
space:
mode:
Diffstat (limited to 'libft/src/vec/ft_vecdestroy.c')
-rw-r--r--libft/src/vec/ft_vecdestroy.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libft/src/vec/ft_vecdestroy.c b/libft/src/vec/ft_vecdestroy.c
new file mode 100644
index 0000000..0021573
--- /dev/null
+++ b/libft/src/vec/ft_vecdestroy.c
@@ -0,0 +1,31 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_vecdestroy.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 19:06:22 by charles #+# #+# */
+/* Updated: 2020/08/19 17:49:30 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_vec.h"
+
+/*
+** \brief Destroy a vector
+** \param vec Vector to destroy
+** \param del Delete function applied to each element of the vector
+** \return NULL
+*/
+
+void *ft_vecdestroy(t_ftvec *vec, void (*del)(void *elem))
+{
+ if (vec == NULL)
+ return (NULL);
+ if (del != NULL)
+ ft_veciter(vec, del);
+ free(vec->data);
+ free(vec);
+ return (NULL);
+}