/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_nrealloc.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: joelecle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:06:43 by joelecle #+# #+# */ /* Updated: 2020/02/14 17:06:43 by joelecle ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include void *ft_nrealloc(void *ptr, size_t oldsize, size_t newsize) { void *nptr; if (!ptr) { if (!(ptr = malloc(newsize))) return (NULL); return (ptr); } else if (!newsize) { free(ptr); return (NULL); } if (!(nptr = malloc(newsize))) return (ptr); ft_memcpy(nptr, ptr, oldsize); free(ptr); return (nptr); }