-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_calloc.c
28 lines (25 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
27
28
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: togauthi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/09 10:05:25 by togauthi #+# #+# */
/* Updated: 2024/10/17 09:59:45 by togauthi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
void *alloc;
if (nmemb == 0 || size == 0)
return (malloc(0));
if (nmemb > (size_t) - 1 / size)
return (NULL);
alloc = malloc(nmemb * size);
if (!alloc)
return (NULL);
ft_bzero(alloc, nmemb * size);
return (alloc);
}