projects
/
Libft.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7ea0e5e
)
Fix ft_vec_copy to also copy empty vectors
no_crash
author
Lukáš Jiřiště
<gymnazium.jiriste@gmail.com>
Fri, 19 Sep 2025 06:03:00 +0000
(08:03 +0200)
committer
Lukáš Jiřiště
<gymnazium.jiriste@gmail.com>
Fri, 19 Sep 2025 06:03:00 +0000
(08:03 +0200)
ft_arr/ft_vec_copy.c
patch
|
blob
|
history
diff --git
a/ft_arr/ft_vec_copy.c
b/ft_arr/ft_vec_copy.c
index 73f6c9771bf12baef6a4ada9b664ee1d17e7a1fb..691aa79526611ce42e338f44a0f3ed47226285a1 100644
(file)
--- a/
ft_arr/ft_vec_copy.c
+++ b/
ft_arr/ft_vec_copy.c
@@
-6,7
+6,7
@@
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/28 12:02:22 by ljiriste #+# #+# */
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/28 12:02:22 by ljiriste #+# #+# */
-/* Updated: 202
4/07/05 10:26:5
4 by ljiriste ### ########.fr */
+/* Updated: 202
5/09/19 08:02:4
4 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_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);
}
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,
// 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,