-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv_copy.c
27 lines (24 loc) · 1.28 KB
/
v_copy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* v_copy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: glegendr <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/02/09 03:20:25 by glegendr #+# #+# */
/* Updated: 2018/05/29 23:26:43 by glegendr ### ########.fr */
/* */
/* ************************************************************************** */
#include "vector.h"
t_vec v_copy(t_vec *vec)
{
t_vec cpy;
cpy.private_content = malloc(sizeof(vec->private_elem_size)
* vec->private_elem_cap);
cpy.private_elem_nb = vec->private_elem_nb;
cpy.private_elem_size = vec->private_elem_size;
cpy.private_elem_cap = vec->private_elem_cap;
v_memcpy(cpy.private_content, vec->private_content,
vec->private_elem_nb * vec->private_elem_size);
return (cpy);
}