This commit is contained in:
Alexandre POMMIER 2020-12-13 22:39:40 +01:00
parent 463d8fb108
commit 4d27efe1f8
2 changed files with 6 additions and 3 deletions

View File

@ -6,7 +6,7 @@
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/11 00:10:12 by apommier #+# #+# */ /* Created: 2020/12/11 00:10:12 by apommier #+# #+# */
/* Updated: 2020/12/11 17:49:18 by apommier ### ########.fr */ /* Updated: 2020/12/13 22:37:30 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,6 +17,7 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
t_list *new; t_list *new;
t_list *begin; t_list *begin;
begin = 0;
while (lst) while (lst)
{ {
new = ft_lstnew(f(lst->content)); new = ft_lstnew(f(lst->content));

View File

@ -6,7 +6,7 @@
/* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <alexpomms@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/07 00:54:12 by apommier #+# #+# */ /* Created: 2020/12/07 00:54:12 by apommier #+# #+# */
/* Updated: 2020/12/13 22:12:26 by apommier ### ########.fr */ /* Updated: 2020/12/13 22:35:54 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -61,6 +61,8 @@ char **ft_split(char const *s, char c)
i = 0; i = 0;
if (!s) if (!s)
return (0); return (0);
while (s[i] == c && s[i])
i++;
while (s[i]) while (s[i])
{ {
while (s[i] != c && s[i]) while (s[i] != c && s[i])
@ -69,7 +71,7 @@ char **ft_split(char const *s, char c)
while (s[i] == c && s[i]) while (s[i] == c && s[i])
i++; i++;
} }
if (!(dest = (char**)malloc(sizeof(char*) * j)))) if (!(dest = (char**)malloc(sizeof(char*) * (i + j))))
return (0); return (0);
dest[j] = 0; dest[j] = 0;
call((char*)s, c, dest, j); call((char*)s, c, dest, j);