correction de split pour retour valeur de null
This commit is contained in:
@@ -88,21 +88,25 @@ void *ft_free(char **array, int w)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char **empty_s(char **empty)
|
||||
{
|
||||
if (!(empty = (char **)malloc(sizeof(char *) * 1)))
|
||||
return (NULL);
|
||||
empty[0] = NULL;
|
||||
return (empty);
|
||||
}
|
||||
|
||||
char **ft_split(char const *s, char c)
|
||||
{
|
||||
char **array;
|
||||
int w;
|
||||
int len;
|
||||
|
||||
w = 0;
|
||||
// if (!s)
|
||||
// {
|
||||
// array = malloc(sizeof(char*));
|
||||
// array[0] = 0;
|
||||
// return (array);
|
||||
// }
|
||||
if (!s || !(array = (char **)malloc(sizeof(char *) * (count(s, c) + 1))))
|
||||
if (!s)
|
||||
return (empty_s(NULL));
|
||||
if (!(array = (char **)malloc(sizeof(char *) * (count(s, c) + 1))))
|
||||
return (NULL);
|
||||
w = 0;
|
||||
while (*s != '\0')
|
||||
{
|
||||
len = 0;
|
||||
|
||||
Reference in New Issue
Block a user