If a malloc ocurs before **ptr malloc, to search size of elements, the test crash. If I change the ptr malloc before str malloc, the test pass, but I need to know the correct size of elements.
code =>
if (!s)
return (NULL);
str = ft_strsubsep(ft_strdup(s), c, c);
size = ft_strelem(str, c) + 1;
ptr = (char *)malloc(sizeof(char ) * size);
if (!ptr)
return (NULL);
code passing =>
ptr = (char *)malloc(sizeof(char ) * 6);
if (!ptr)
return (NULL);
if (!s)
return (NULL);
str = ft_strsubsep(ft_strdup(s), c, c);
size = ft_strelem(str, c) + 1;
ft_strsubsep is a functions thats trim multiples ocorrences of a character and uses malloc and free. If u need the entire code reply me.
If a malloc ocurs before **ptr malloc, to search size of elements, the test crash. If I change the ptr malloc before str malloc, the test pass, but I need to know the correct size of elements.
code => if (!s) return (NULL); str = ft_strsubsep(ft_strdup(s), c, c); size = ft_strelem(str, c) + 1; ptr = (char *)malloc(sizeof(char ) * size); if (!ptr) return (NULL);
code passing => ptr = (char *)malloc(sizeof(char ) * 6); if (!ptr) return (NULL); if (!s) return (NULL); str = ft_strsubsep(ft_strdup(s), c, c); size = ft_strelem(str, c) + 1;
ft_strsubsep is a functions thats trim multiples ocorrences of a character and uses malloc and free. If u need the entire code reply me.