libft/ft_calloc.c
Etienne Rey-bethbeder 191a193cb2 origin
2022-10-11 22:51:06 +02:00

27 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/28 16:21:44 by erey-bet #+# #+# */
/* Updated: 2022/10/11 14:17:31 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nitems, size_t size)
{
size_t *tmp;
if (nitems * size < nitems)
return (NULL);
tmp = malloc(nitems * size);
if (tmp == NULL)
return (NULL);
ft_bzero(tmp, nitems * size);
return (tmp);
}