Started from buttom go to the sky
This commit is contained in:
parent
96215449bd
commit
f811e55dea
4781 changed files with 10121 additions and 1743 deletions
31
libft/ft_calloc.c
Normal file
31
libft/ft_calloc.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_calloc.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:47:17 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 22:32:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
void *ft_calloc(t_usize nmemb, t_usize size)
|
||||
{
|
||||
t_usize total;
|
||||
t_str to_return;
|
||||
|
||||
if (nmemb == 0 || size == 0)
|
||||
return ((void *)malloc(1));
|
||||
total = nmemb * size;
|
||||
if (total / nmemb != size && total / size != nmemb)
|
||||
return (NULL);
|
||||
to_return = (char *)malloc(total);
|
||||
if (to_return == NULL)
|
||||
to_return = NULL;
|
||||
else
|
||||
ft_bzero(to_return, total);
|
||||
return (to_return);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue