-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
28 lines (25 loc) · 1.21 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: mbartos <mbartos@student.42prague.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/24 09:21:32 by mbartos #+# #+# */
/* Updated: 2023/10/27 11:57:15 by mbartos ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
unsigned char *memory;
unsigned int max_int;
max_int = 2147483647;
if (count > max_int && size > max_int)
return (NULL);
memory = (unsigned char *) malloc(count * size);
if (memory == NULL)
return (NULL);
ft_bzero(memory, count * size);
return ((void *) memory);
}