-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
28 lines (25 loc) · 1.14 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: lpires-n <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/04 18:21:52 by lpires-n #+# #+# */
/* Updated: 2022/06/04 22:24:59 by lpires-n ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
size_t *ptr;
int space;
space = nmemb * size;
if (nmemb != 0 && space / size != nmemb)
return (NULL);
ptr = malloc(space);
if (ptr == NULL)
return (NULL);
ft_bzero(ptr, space);
return (ptr);
}