aboutsummaryrefslogtreecommitdiff
path: root/libft/src/vec/ft_vecpush_safe.c
diff options
context:
space:
mode:
Diffstat (limited to 'libft/src/vec/ft_vecpush_safe.c')
-rw-r--r--libft/src/vec/ft_vecpush_safe.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libft/src/vec/ft_vecpush_safe.c b/libft/src/vec/ft_vecpush_safe.c
new file mode 100644
index 0000000..8e5a8d4
--- /dev/null
+++ b/libft/src/vec/ft_vecpush_safe.c
@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_vecpush_safe.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/04 13:29:48 by charles #+# #+# */
+/* Updated: 2020/04/04 14:24:19 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_vec.h"
+
+/*
+** \brief Wrapper around ft_vecpush which reject null element
+** \param vec Pushed vector
+** \param pushed Element pushed which can't be NULL
+** \return NULL if pushed is NULL, whatever ft_vecpush returns otherwise
+*/
+
+t_ftvec *ft_vecpush_safe(t_ftvec *vec, void *pushed)
+{
+ if (pushed == NULL)
+ return (NULL);
+ return (ft_vecpush(vec, pushed));
+}