-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
33 lines (28 loc) · 1.31 KB
/
ft_calloc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: anarodri <anarodri@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/09/27 10:44:52 by anarodri #+# #+# */
/* Updated: 2022/12/15 12:51:09 by anarodri ### ########.fr */
/* */
/* ************************************************************************** */
/*
Contiguously allocates memory that is filled with bytes of value zero.
To avoid a memory leak, the returned pointer must be deallocated with:
free() or realloc().
Returns: Pointer to the beginning of newly allocated memory,
NULL if there is an error.
*/
#include "../libft.h"
void *ft_calloc(size_t num, size_t size)
{
void *ptr;
ptr = malloc(num * size);
if (ptr == NULL)
return (NULL);
ft_bzero(ptr, (num * size));
return (ptr);
}