-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_calloc.c
More file actions
36 lines (32 loc) · 1.32 KB
/
ft_calloc.c
File metadata and controls
36 lines (32 loc) · 1.32 KB
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: bhielsch <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 11:31:22 by bhielsch #+# #+# */
/* Updated: 2022/10/13 17:33:29 by bhielsch ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include <stdio.h>
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
void *ptr;
if (nmemb > 4294967295 || size > 4294967295)
return (0);
ptr = (void *)malloc(nmemb * size);
if (!ptr)
return (NULL);
ft_bzero(ptr, size * nmemb);
return (ptr);
}
// int main()
// {
// int nmemb = 3;
// int size = 4;
// printf("Mine: %p\n", ft_calloc(nmemb, size));
// printf("OG: %p\n", calloc(nmemb, size));
// }