-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_calloc.c
36 lines (33 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
29
30
31
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: carlde-l <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/06 21:02:37 by carlde-l #+# #+# */
/* Updated: 2022/10/03 05:33:32 by carlde-l ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <limits.h>
#include <stdio.h>
void *ft_calloc(size_t count, size_t size)
{
void *p;
if (count == SIZE_MAX || size == SIZE_MAX)
return (0);
p = malloc(count * size);
if (!p)
return (0);
ft_bzero(p, count * size);
return (p);
}
/*
int main()
{
if (calloc(4294967296, 1))
printf("2");
if (ft_calloc(4294967295, 2))
printf("1\n");
}*/