Skip to content

Instantly share code, notes, and snippets.

@lambda2
Created November 28, 2013 02:40
Show Gist options
  • Select an option

  • Save lambda2/7686494 to your computer and use it in GitHub Desktop.

Select an option

Save lambda2/7686494 to your computer and use it in GitHub Desktop.
ft_memrealloc.c
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memrealloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aaubin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/11/28 02:36:34 by aaubin #+# #+# */
/* Updated: 2013/11/28 03:35:07 by aaubin ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void * ft_memrealloc(void *buf, size_t old_size, size_t new_size)
{
char *new_buf;
char *_buf;
_buf = (char *) buf;
new_buf = ft_memalloc(new_size);
if ( new_buf )
{
new_buf = ft_memcpy((void *) new_buf, (void *) buf, old_size);
free(buf);
}
return ( (void *) new_buf );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment