-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_calloc.c
33 lines (30 loc) · 1.35 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: rdragan <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/04 18:22:42 by rdragan #+# #+# */
/* Updated: 2022/11/11 23:12:43 by rdragan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
Allocates enought space for count objects that are size bytes each
and returns a pointer to the allocated memory. The allocated memory is
filled with bytes of value 0.
@param count: amount of data types to store.
@param size: size in bytes of each data type.
*/
void *ft_calloc(size_t count, size_t size)
{
void *ptr;
if ((count * size) > INT_MAX)
return (NULL);
ptr = malloc(count * size);
if (!ptr)
return (NULL);
ft_bzero(ptr, count * size);
return (ptr);
}