42_cub3d/Libft/ft_calloc.c
2024-10-09 03:35:09 +02:00

29 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: grobledo <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/08 19:35:13 by grobledo #+# #+# */
/* Updated: 2023/02/08 19:35:23 by grobledo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
void *str;
size_t tmp;
tmp = size * count;
if (size == 0 || count == 0)
return (malloc(0));
if (tmp / count != size)
return (NULL);
str = malloc(size * count);
if (str == NULL)
return (NULL);
ft_bzero (str, size * count);
return (str);
}