30 lines
1.2 KiB
C
30 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_calloc.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/11/01 16:02:26 by adjoly #+# #+# */
|
|
/* Updated: 2023/11/11 01:32:30 by adjoly ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
#include <complex.h>
|
|
|
|
void *ft_calloc(size_t nmemb, size_t size)
|
|
{
|
|
void *result;
|
|
|
|
if (size != 0 && nmemb != 0 && (nmemb * size) / nmemb != size)
|
|
return (NULL);
|
|
if (nmemb == 0 || size == 0)
|
|
return (malloc(1));
|
|
result = malloc(size * nmemb);
|
|
if (result == NULL)
|
|
return (NULL);
|
|
ft_bzero(result, size * nmemb);
|
|
return (result);
|
|
}
|