42_cube3D/libftx/extra/ft_tabrealloc.c

32 lines
1.2 KiB
C
Raw Permalink Normal View History

2023-04-26 07:02:44 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tabrealloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/05 18:58:48 by cchauvet #+# #+# */
/* Updated: 2023/01/10 18:30:21 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);
}