-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbyte_array_new.c
31 lines (28 loc) · 1.27 KB
/
byte_array_new.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
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* byte_array_new.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oadhesiv <oadhesiv@student.21-school.ru> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/12 17:21:38 by oadhesiv #+# #+# */
/* Updated: 2021/01/06 18:00:00 by oadhesiv ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
#include "array.h"
t_byte_array *byte_array_new(size_t len)
{
t_byte_array *ret;
len = len + sizeof(long) - len % sizeof(long);
ret = (t_byte_array *)malloc(sizeof(t_byte_array));
if (!ret)
return ((void *)0);
ret->size = len;
ret->used = 0;
ret->data = (t_byte *)malloc(sizeof(t_byte) * len);
if (!ret->data)
ft_memdel((void **)&ret);
return (ret);
}