copy on git
This commit is contained in:
commit
42653de246
205 changed files with 7459 additions and 0 deletions
30
libft/ft_calloc.c
Executable file
30
libft/ft_calloc.c
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_calloc.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/14 19:42:05 by thrieg #+# #+# */
|
||||
/* Updated: 2025/02/16 19:03:37 by thrieg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void *ft_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
if ((size == 0) || (nmemb == 0))
|
||||
{
|
||||
return (malloc(0));
|
||||
}
|
||||
if (nmemb > __SIZE_MAX__ / size)
|
||||
return (NULL);
|
||||
ret = malloc(nmemb * size);
|
||||
if (!ret)
|
||||
return (NULL);
|
||||
ft_bzero(ret, (nmemb * size));
|
||||
return (ret);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue