-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_calloc.c
30 lines (27 loc) · 1.13 KB
/
ft_calloc.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tedison <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/04/02 13:38:23 by tedison #+# #+# */
/* Updated: 2021/04/03 17:43:12 by tedison ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
size_t i;
void *to_malloc;
i = 0;
to_malloc = malloc(count * size);
if (!to_malloc)
return (NULL);
while (i < count * size)
{
((char *)to_malloc)[i] = 0;
i++;
}
return (to_malloc);
}