-
Notifications
You must be signed in to change notification settings - Fork 2
/
ft_calloc.c
29 lines (25 loc) · 1.3 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adiaz-lo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/20 12:33:07 by adiaz-lo #+# #+# */
/* Updated: 2020/01/13 09:29:39 by adiaz-lo ### ########.fr */
/* */
/* ************************************************************************** */
/*
** This function allocates memory for an array of count elements of size bytes
** each and returns a pointer to the allocated memory.
** For further information, please check for Standard C Library function
** 'calloc(size_t count, size_t size)'.
*/
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
void *array;
if (!(array = (char *)malloc(size * count)))
return (NULL);
return (ft_memset(array, 0, size * count));
}