added argument protection

This commit is contained in:
Tanguy MAZE
2018-04-10 15:12:32 +02:00
parent 45e39d4f0e
commit f6e6bf0680
17 changed files with 108 additions and 70 deletions

View File

@@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/08 19:54:31 by tmaze #+# #+# */
/* Updated: 2018/04/09 09:35:00 by tmaze ### ########.fr */
/* Updated: 2018/04/10 14:31:03 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,11 +24,14 @@ t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
t_list *new;
ret = NULL;
if (lst->next != NULL)
ret = ft_lstmap(lst->next, f);
if ((new = (*f)(lst)) == NULL)
ft_lstdel(&ret, &ft_lstdelmem);
else
ft_lstadd(&ret, new);
if (lst != NULL && f != NULL)
{
if (lst->next != NULL)
ret = ft_lstmap(lst->next, f);
if ((new = (*f)(lst)) == NULL)
ft_lstdel(&ret, &ft_lstdelmem);
else
ft_lstadd(&ret, new);
}
return (ret);
}