-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
28 lines (25 loc) · 1.24 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: gpuscedd <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/05 18:05:37 by gpuscedd #+# #+# */
/* Updated: 2024/01/19 19:48:26 by gpuscedd ### ########.fr */
/* */
/* ************************************************************************** */
/* from stdlib.h | is used to dynamically allocate memory for an array
* and initialize all its elements to zero. */
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
void *out;
if (count && size && count > (UINT_MAX / size))
return (NULL);
out = malloc(count * size);
if (out == NULL)
return (out);
ft_bzero(out, count * size);
return (out);
}