59 lines
1.4 KiB
C
59 lines
1.4 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_freer.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2023/01/08 15:01:40 by cchauvet #+# #+# */
|
||
|
/* Updated: 2023/01/09 17:57:52 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "extra.h"
|
||
|
|
||
|
void ft_freer_ultimate(size_t len, ...)
|
||
|
{
|
||
|
va_list va;
|
||
|
size_t i;
|
||
|
|
||
|
i = 0;
|
||
|
va_start(va, len);
|
||
|
while (i < len)
|
||
|
{
|
||
|
free(va_arg(va, char *));
|
||
|
i++;
|
||
|
}
|
||
|
va_end(va);
|
||
|
}
|
||
|
|
||
|
void ft_freer_tab(char **tab)
|
||
|
{
|
||
|
size_t i;
|
||
|
|
||
|
if (tab == NULL)
|
||
|
return ;
|
||
|
i = 0;
|
||
|
while (tab[i] != NULL)
|
||
|
{
|
||
|
free(tab[i]);
|
||
|
i++;
|
||
|
}
|
||
|
free(tab);
|
||
|
}
|
||
|
|
||
|
void ft_freer_tab_ultimate(size_t len, ...)
|
||
|
{
|
||
|
va_list va;
|
||
|
size_t i;
|
||
|
|
||
|
i = 0;
|
||
|
va_start(va, len);
|
||
|
while (i < len)
|
||
|
{
|
||
|
ft_freer_tab(va_arg(va, char **));
|
||
|
i++;
|
||
|
}
|
||
|
va_end(va);
|
||
|
}
|