42_minitalk/libftx/libft/ft_calloc.c

27 lines
1.1 KiB
C
Raw Normal View History

2023-01-23 07:22:30 -05:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/27 16:09:01 by cchauvet #+# #+# */
/* Updated: 2022/10/28 17:31:12 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
void *tab;
if (nmemb != 0 && (size_t)(nmemb * size) / nmemb != size)
return (NULL);
tab = malloc(nmemb * size);
if (tab == NULL)
return (NULL);
ft_bzero(tab, nmemb * size);
return (tab);
}