-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
28 lines (25 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: isalayan <isalayan@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/15 15:25:46 by isalayan #+# #+# */
/* Updated: 2024/06/18 16:03:38 by isalayan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
void *s;
if (nmemb == 0 || size == 0)
return (malloc(0));
if (nmemb > 2147483647 / size)
return (NULL);
s = (void *)malloc(nmemb * size);
if (!s)
return (NULL);
ft_bzero(s, nmemb * size);
return (s);
}