malloc/subprojects/libft/ft_realloc.c

33 lines
1.2 KiB
C
Raw Normal View History

2019-04-24 20:59:37 +03:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_realloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:57:55 by gtertysh #+# #+# */
/* Updated: 2016/12/07 17:16:48 by gtertysh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_realloc(void *old, unsigned int new_size, unsigned int old_size)
{
void *new;
new = NULL;
if ((new = ft_memalloc(new_size)))
{
if (old)
{
if (old_size)
ft_memcpy(new, old, old_size);
free(old);
old = NULL;
}
return (new);
}
return (old);
}