ft_calloc: do not memset if malloc returns NULL
This commit is contained in:
parent
afcddc5e14
commit
29f2cc104a
1 changed files with 3 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/17 10:20:05 by kcolin #+# #+# */
|
/* Created: 2024/10/17 10:20:05 by kcolin #+# #+# */
|
||||||
/* Updated: 2024/10/17 13:50:18 by kcolin ### ########.fr */
|
/* Updated: 2024/10/19 18:12:22 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -24,6 +24,7 @@ void *ft_calloc(size_t nmemb, size_t size)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out = malloc(bytes);
|
out = malloc(bytes);
|
||||||
|
if (out != NULL)
|
||||||
ft_memset(out, 0, bytes);
|
ft_memset(out, 0, bytes);
|
||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue