-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
28 lines (26 loc) · 1.16 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: vfedorov <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/27 20:36:43 by vfedorov #+# #+# */
/* Updated: 2023/01/29 13:47:47 by vfedorov ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
void *sra;
if (count && size)
{
if (((count * size) < count) || ((count * size) < size))
return (NULL);
}
sra = malloc (count * size);
if (sra == NULL)
return (NULL);
ft_memset(sra, 0, (size * count));
return (sra);
}