aboutsummaryrefslogtreecommitdiff
path: root/src/vec/ft_vecpush.c
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-08-02 11:05:33 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-08-02 11:05:33 +0200
commit5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde (patch)
tree80911dc3c32e9f230750e7e1042d413dfb6efab2 /src/vec/ft_vecpush.c
parentee32953ea79616e72f5428cdf40c834714a891c9 (diff)
parentb96b82194ccad2cddbb46b77aa1962a57c47ff44 (diff)
downloadlibft-5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde.tar.gz
libft-5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde.tar.bz2
libft-5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde.zip
Merge branch 'master' into ft_ssl
Diffstat (limited to 'src/vec/ft_vecpush.c')
-rw-r--r--src/vec/ft_vecpush.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/vec/ft_vecpush.c b/src/vec/ft_vecpush.c
new file mode 100644
index 0000000..026ae3d
--- /dev/null
+++ b/src/vec/ft_vecpush.c
@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_vecpush.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 19:22:20 by charles #+# #+# */
+/* Updated: 2020/04/02 10:51:38 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_vec.h"
+
+/*
+** \brief Push element at the end of vector
+** \param vec Vector where element will be pushed
+** \param pushed Element to push
+** \return Passed vector or NULL if couldnt grow vector
+*/
+
+t_ftvec *ft_vecpush(t_ftvec *vec, void *pushed)
+{
+ if (vec->capacity <= vec->size)
+ if (ft_vecgrow(vec) == NULL)
+ return (NULL);
+ vec->data[vec->size] = pushed;
+ vec->size++;
+ return (vec);
+}