-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
28 lines (25 loc) · 1.15 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: javellis <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 12:11:27 by javellis #+# #+# */
/* Updated: 2022/10/05 12:11:30 by javellis ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
#include <stddef.h>
void *ft_calloc(unsigned int nmemb, unsigned int size)
{
void *ptr;
if (nmemb == 0 || size == 0)
return (NULL);
ptr = malloc(nmemb * size);
if (ptr == 0)
return (NULL);
ft_bzero(ptr, nmemb * size);
return (ptr);
}