Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
libft/ft_calloc.c
2023-11-11 11:56:43 +01:00

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);
}