-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_calloc.c
More file actions
27 lines (24 loc) · 1.15 KB
/
ft_calloc.c
File metadata and controls
27 lines (24 loc) · 1.15 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpalacio <lpalacio@student.42madrid> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/03 20:28:29 by lpalacio #+# #+# */
/* Updated: 2022/10/03 21:41:28 by lpalacio ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
void *ptr;
size_t max_size_t;
max_size_t = (size_t) - 1;
if (size > 0 && count > max_size_t / size)
return (NULL);
ptr = malloc (count * size);
if (ptr != NULL)
ft_bzero (ptr, count * size);
return (ptr);
}