-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_calloc.c
49 lines (42 loc) · 1.46 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
37
38
39
40
41
42
43
44
45
46
47
48
49
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vangirov <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/08 18:10:55 by vangirov #+# #+# */
/* Updated: 2021/12/10 16:50:02 by vangirov ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
void *ptr;
ptr = malloc(nmemb * size);
if (ptr == NULL)
return (NULL);
ft_bzero(ptr, nmemb * size);
return (ptr);
}
// #include <stdio.h>
// void printmem(const void *s, size_t n)
// {
// unsigned char *t;
// if (!s)
// printf("You've passed a null pointer!\n");
// else
// {
// t = (unsigned char *)s;
// while (n-- > 0)
// printf("%02x ", *t++);
// printf("\n");
// }
// }
// int main()
// {
// int *arr1 = ft_calloc(5, 4);
// int *arr2 = calloc(5, 4);
// printmem(arr1, 25);
// printmem(arr2, 25);
// }