-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
33 lines (30 loc) · 1.15 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
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: brpereir <brpereir@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/12 20:34:19 by brpereir #+# #+# */
/* Updated: 2023/04/15 06:20:30 by brpereir ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t n, size_t size)
{
size_t i;
char *arr;
unsigned int total;
total = n * size;
i = 0;
arr = (char *)malloc(n * size);
if (arr == NULL)
return (NULL);
while (total > 0)
{
arr[i] = 0;
i++;
total--;
}
return ((void *)arr);
}