-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
32 lines (29 loc) · 1.17 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nopereir <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/14 14:38:30 by nopereir #+# #+# */
/* Updated: 2022/06/29 15:58:02 by nopereir ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
size_t buff_size;
void *buff;
buff_size = nmemb * size;
if (buff_size == 0 || !(buff_size / nmemb))
{
return (NULL);
}
buff = malloc(buff_size);
if (!buff)
{
return (NULL);
}
ft_memset(buff, 0, buff_size);
return (buff);
}