-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_calloc.c
26 lines (23 loc) · 1.16 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: coder <coder@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/23 23:09:54 by rde-noro #+# #+# */
/* Updated: 2022/09/24 18:19:21 by rde-noro ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
void *str;
if (nmemb == 0 || size == 0)
return (NULL);
if (nmemb > 2147483647 || size > 2147483647 || size * nmemb > 2147483647)
return (NULL);
str = malloc(nmemb * size);
ft_bzero(str, nmemb * size);
return (str);
}