From 30f8df1bfda39333988817e9f5312e71905dbc34 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Fri, 19 Sep 2025 08:03:00 +0200 Subject: [PATCH] Fix ft_vec_copy to also copy empty vectors --- ft_arr/ft_vec_copy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ft_arr/ft_vec_copy.c b/ft_arr/ft_vec_copy.c index 73f6c97..691aa79 100644 --- a/ft_arr/ft_vec_copy.c +++ b/ft_arr/ft_vec_copy.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/28 12:02:22 by ljiriste #+# #+# */ -/* Updated: 2024/07/05 10:26:54 by ljiriste ### ########.fr */ +/* Updated: 2025/09/19 08:02:44 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,11 +20,12 @@ static t_arr_stat prepare_for_copy(t_vec *dest, const t_vec *src) res = ft_vec_init(dest, src->el_size); if (res != success) return (res); - res = ft_vec_reserve(dest, src->capacity); + if (src->capacity > 0) + res = ft_vec_reserve(dest, src->capacity); return (res); } -// This function the exact current state of src to dest. +// This function copies the exact current state of src to dest. // copy_el function enables deep copy // free_el function enbales cleaning after itself in a case of error t_arr_stat ft_vec_copy(t_vec *dest, const t_vec *src, -- 2.30.2