32 lines
1.2 KiB
C
32 lines
1.2 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_realloc.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2023/01/05 18:58:48 by cchauvet #+# #+# */
|
||
|
/* Updated: 2023/01/20 16:22:50 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "extra.h"
|
||
|
|
||
|
void *ft_realloc(void *tab, size_t size, size_t new_size, int bytes)
|
||
|
{
|
||
|
char *new;
|
||
|
size_t i;
|
||
|
|
||
|
new = ft_calloc(new_size, bytes);
|
||
|
if (new == NULL)
|
||
|
return (NULL);
|
||
|
i = 0;
|
||
|
while (i < size * bytes && tab != NULL)
|
||
|
{
|
||
|
new[i] = ((char *) tab)[i];
|
||
|
i++;
|
||
|
}
|
||
|
free(tab);
|
||
|
return (new);
|
||
|
}
|