-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_calloc.c
More file actions
28 lines (25 loc) · 1.14 KB
/
ft_calloc.c
File metadata and controls
28 lines (25 loc) · 1.14 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
28
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: metaskin <metaskin@student.42istanbul.c +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/31 12:12:42 by metaskin #+# #+# */
/* Updated: 2026/01/20 14:57:21 by metaskin ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
void *mem;
size_t total;
if (size != 0 && count > (size_t)-1 / size)
return (NULL);
total = count * size;
mem = malloc(total);
if (!mem)
return (NULL);
ft_memset(mem, 0, total);
return (mem);
}