diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-10-11 15:52:52 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-10-11 15:52:52 +0200 |
| commit | c98de126d2252fe47dc2a9094a5f9a8fa6b4b60a (patch) | |
| tree | 12f1c827ee063ed3e7038f6a704014e611e4f388 /libft/src/vec/ft_vecswallow.c | |
| parent | a4ceb5974d1b7dcdd12cc81b7eb07893ea16c8ad (diff) | |
| download | minishell-c98de126d2252fe47dc2a9094a5f9a8fa6b4b60a.tar.gz minishell-c98de126d2252fe47dc2a9094a5f9a8fa6b4b60a.tar.bz2 minishell-c98de126d2252fe47dc2a9094a5f9a8fa6b4b60a.zip | |
Removing libft/minishell_test submodules, Removing subject/README/etc
Diffstat (limited to 'libft/src/vec/ft_vecswallow.c')
| -rw-r--r-- | libft/src/vec/ft_vecswallow.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libft/src/vec/ft_vecswallow.c b/libft/src/vec/ft_vecswallow.c new file mode 100644 index 0000000..614022d --- /dev/null +++ b/libft/src/vec/ft_vecswallow.c @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_vecswallow.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/07/15 17:17:00 by charles #+# #+# */ +/* Updated: 2020/07/15 18:30:37 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft_vec.h" + +/* +** \brief Insert all element of a vector in an other vector +** and free the swallowed vector +** \param vec Vector where the element will be inserted +** \param index Index of the insertion +** \param swallowed Vector to swallow +** \return Destination vector or NULL on error +*/ + +t_ftvec *ft_vecswallow_at(t_ftvec *vec, size_t index, t_ftvec *swallowed) +{ + size_t i; + + if (ft_vecreserve(vec, vec->size + swallowed->size) == NULL) + return (NULL); + i = -1; + while (++i < swallowed->size) + ft_vecinsert(vec, index, swallowed->data[i]); + ft_vecdestroy(swallowed, NULL); + return (vec); +} |
