-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
28 lines (25 loc) · 1.12 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alaparic <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/18 16:48:21 by alaparic #+# #+# */
/* Updated: 2022/09/29 18:54:13 by alaparic ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
void *ptr;
size_t aux;
aux = count * size;
if (aux == 1 && count != 1)
return (NULL);
ptr = malloc(aux);
if (!ptr)
return (NULL);
ft_bzero(ptr, count * size);
return (ptr);
}