libft
Loading...
Searching...
No Matches
ft_calloc.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_calloc.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: tspoof <tspoof@student.hive.fi> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2022/11/03 13:10:14 by tspoof #+# #+# */
9
/* Updated: 2022/11/30 16:45:52 by tspoof ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
libft.h
"
14
15
void
*
ft_calloc
(
size_t
count,
size_t
size)
16
{
17
void
*ptr;
18
19
if
(!count || !size)
20
return
(
ft_calloc
(1, 1));
21
if
((count * size) / count != size)
22
return
(NULL);
23
ptr = malloc(count * size);
24
if
(!ptr)
25
return
(NULL);
26
ft_bzero
(ptr, count * size);
27
return
(ptr);
28
}
ft_calloc
void * ft_calloc(size_t count, size_t size)
Allocate and zero.
Definition
ft_calloc.c:15
libft.h
ft_bzero
void ft_bzero(void *s, size_t n)
Zero a byte string.
Definition
ft_bzero.c:15
src
ft_calloc.c
Generated by
1.9.7