30 lines
1.1 KiB
C
30 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_calloc.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: rzy <ry@student.42angouleme.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2026/08/24 01:03:26 by rzy #+# #+# */
|
|
/* Updated: 2026/08/24 01:03:38 by rzy ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
#include "libft.h"
|
|
|
|
void *ft_calloc(size_t n, size_t size)
|
|
{
|
|
unsigned char *ptr;
|
|
size_t i;
|
|
|
|
ptr = (unsigned char *)malloc(n * size);
|
|
if (ptr == NULL)
|
|
return (NULL);
|
|
i = 0;
|
|
while (i < (n * size))
|
|
{
|
|
ptr[i] = 0;
|
|
++i;
|
|
}
|
|
return (ptr);
|
|
}
|