philosopher/philo/utils/ft_calloc.c
Etienne Rey-bethbeder 3f0ec62059 corrigé mixed up
2023-04-06 14:02:19 +02:00

29 lines
1.2 KiB
C

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