forked from BBFayz/Libft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_realloc.c
27 lines (24 loc) · 1.13 KB
/
ft_realloc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_realloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: azybert <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/17 21:46:31 by azybert #+# #+# */
/* Updated: 2017/08/20 21:18:06 by azybert ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_realloc(void *to_realloc, size_t old_size, size_t new_size)
{
void *new;
if (!(new = malloc(new_size)))
return (NULL);
if (to_realloc != NULL)
{
ft_memcpy(new, to_realloc, old_size);
free(to_realloc);
}
return (new);
}