minitalk/libft/src/memory/ft_calloc.c
2024-12-04 13:40:09 +01:00

29 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: o_ :::::: ::: */
/* ft_calloc.c :+: / :+::+: :+: */
/* +:+ > +:++:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
/* +#+ +#+#+ +#++#+ +#+ \o/ */
/* Created: 2024/10/10 17:00:14 by whaffman #+#+# #+#+# #+# #+# | */
/* Updated: 2024/10/10 17:00:14 by whaffman ### ### ### ### / \ */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
void *ptr;
if (nmemb && size > (size_t) -1 / nmemb)
{
return (0);
}
ptr = malloc(nmemb * size);
if (ptr)
ft_bzero(ptr, nmemb * size);
return (ptr);
}