resolu calloc pour taille zero

This commit is contained in:
Hugo LAMY
2019-11-28 16:01:08 +01:00
parent 5da3edd07e
commit 365e8abb42
3 changed files with 34 additions and 27 deletions

View File

@@ -1,15 +1,3 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 13:54:53 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:28:35 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** exemple allocation for 5 integers with malloc then calloc :
** a = (int *)malloc(5 * sizeof(int)); //5*4bytes = 20 bytes
@@ -26,7 +14,7 @@ void *ft_calloc(size_t count, size_t size)
{
void *tmp;
if (!count || !size || !(tmp = malloc(count * size)))
if (!(tmp = malloc(count * size)))
return (NULL);
ft_bzero(tmp, count * size);
return (tmp);