/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstmap.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/14 21:11:20 by hulamy #+# #+# */ /* Updated: 2018/11/16 14:01:23 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem)) { t_list *new; t_list *tmp; if (!lst) return (NULL); tmp = f(lst); new = tmp; while (lst->next) { lst = lst->next; if (!(tmp->next = f(lst))) { free(tmp->next); return (NULL); } tmp = tmp->next; } return (new); }