-
Notifications
You must be signed in to change notification settings - Fork 1
/
byte_array_resize.c
30 lines (27 loc) · 1.24 KB
/
byte_array_resize.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
28
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* byte_array_resize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oadhesiv <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/12 17:30:40 by oadhesiv #+# #+# */
/* Updated: 2021/01/06 18:00:00 by oadhesiv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "array.h"
t_byte_array *byte_array_resize(t_byte_array *arr, size_t len)
{
t_byte_array *ret;
if (!arr)
return ((void *)0);
len = len + sizeof(long) - len % sizeof(long);
ret = byte_array_new(len);
if (!ret)
return ((void *)0);
ft_memcpy(ret->data, arr->data, arr->used);
ret->used = arr->used;
ft_memdel((void **)&arr);
return (ret);
}