-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_calloc.c
35 lines (30 loc) · 1.29 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abertran <abertran@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 18:02:01 by abertran #+# #+# */
/* Updated: 2022/10/18 17:25:57 by abertran ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/* asigna memoria y la inicializa y rellena con zero */
void *ft_calloc(size_t count, size_t size)
/*cantidad de elementos y tamaño */
{
char *ptr;
if (count && ((SIZE_MAX / count) < size))
return (NULL);
ptr = malloc (count * size);
if (!ptr)
return (NULL);
else
ft_bzero(ptr, count * size);
return (ptr);
}
/*int main(void)
33 {
34 printf("cadena: %p\n", ft_calloc(0, 1));
35 }*/