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.
FDF/libft/ft_calloc.c

38 lines
1.3 KiB
C
Raw Normal View History

2023-12-18 17:19:34 +01:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/01 16:02:26 by adjoly #+# #+# */
/* Updated: 2023/12/18 08:40:14 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <complex.h>
void *ft_calloc(size_t nmemb, size_t size)
{
char *str;
size_t i;
i = 0;
if (nmemb == 0 || size == 0)
return (malloc(1));
if ((int)size < 0 && (int)nmemb < 0)
return (NULL);
if ((unsigned long long)(size * nmemb) > 4294967295)
return (NULL);
str = malloc(nmemb * size);
if (!str)
return (NULL);
while (i < (nmemb * size))
{
*(unsigned char *)(str + i) = '\0';
i++;
}
return (str);
}