42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_split2.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/12/09 15:37:07 by alier #+# #+# */
|
|
/* Updated: 2025/02/16 19:04:33 by thrieg ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdlib.h>
|
|
|
|
/*
|
|
* Free all strings duplicated by split and the pointer array itself.
|
|
* Does nothing if strs is NULL.
|
|
*/
|
|
void ft_free_split(char **strs)
|
|
{
|
|
size_t i;
|
|
|
|
if (strs == NULL)
|
|
return ;
|
|
i = 0;
|
|
while (strs[i] != NULL)
|
|
{
|
|
free(strs[i]);
|
|
i++;
|
|
}
|
|
free(strs);
|
|
}
|
|
|
|
size_t ft_split_size(char **strs)
|
|
{
|
|
size_t i;
|
|
|
|
i = 0;
|
|
while (strs[i] != NULL)
|
|
i++;
|
|
return (i);
|
|
}
|