-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_calloc.c
31 lines (28 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
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: schetty <schetty@student.42kl.edu.my> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/07 21:42:09 by schetty #+# #+# */
/* Updated: 2021/11/11 18:14:39 by schetty ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nitems, size_t size)
{
size_t len;
char *ret;
if (nitems == 0 || size == 0)
len = 1;
else
len = nitems * size;
ret = malloc(sizeof(char) * len);
if (ret)
{
while (len--)
ret[len] = 0;
}
return (ret);
}