-
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: yde-goes <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/08 01:23:29 by yde-goes #+# #+# */
/* Updated: 2022/06/27 15:56:00 by yde-goes ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
void *arr;
int alloc_size;
alloc_size = nmemb * size;
if (!alloc_size || alloc_size / nmemb != size)
return (NULL);
arr = malloc(alloc_size);
if (arr == NULL)
return (NULL);
ft_bzero(arr, alloc_size);
return (arr);
}