42_solong/libftx/extra/ft_tabrealloc.c
Camille Chauvet 195f7bc66a ca marche
2023-01-09 20:41:06 +01:00

34 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tabrealloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/05 18:58:48 by cchauvet #+# #+# */
/* Updated: 2023/01/09 17:45:44 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size)
{
char **new;
size_t i;
new = ft_calloc(new_size, sizeof(char *));
if (new == NULL)
return (NULL);
i = 0;
while (i < current_size)
{
new[i] = tab[i];
i++;
}
free(tab);
return (new);
}