14-04-2026
28 lines
1.2 kB
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_calloc.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: mleitao <mleitao@student.42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2026/03/12 20:15:18 by mleitao #+# #+# */
9/* Updated: 2026/04/14 19:14:29 by mleitao ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14#include <stdint.h>
15#include <stdlib.h>
16
17void *ft_calloc(size_t nmeb, size_t size)
18{
19 void *p;
20
21 if (nmeb && size > SIZE_MAX / nmeb)
22 return (NULL);
23 p = malloc(nmeb * size);
24 if (!p)
25 return (NULL);
26 ft_bzero(p, nmeb * size);
27 return (p);
28}