30 lines
1.2 KiB
C
Executable file
30 lines
1.2 KiB
C
Executable file
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_calloc.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/10/14 19:42:05 by thrieg #+# #+# */
|
|
/* Updated: 2025/02/16 19:03:37 by thrieg ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
void *ft_calloc(size_t nmemb, size_t size)
|
|
{
|
|
void *ret;
|
|
|
|
if ((size == 0) || (nmemb == 0))
|
|
{
|
|
return (malloc(0));
|
|
}
|
|
if (nmemb > __SIZE_MAX__ / size)
|
|
return (NULL);
|
|
ret = malloc(nmemb * size);
|
|
if (!ret)
|
|
return (NULL);
|
|
ft_bzero(ret, (nmemb * size));
|
|
return (ret);
|
|
}
|