/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstmap_bonus.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/22 14:54:31 by narnaud #+# #+# */ /* Updated: 2022/03/24 09:22:49 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "../libft.h" t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) { t_list *new_lst; if (!lst || !f) return (NULL); new_lst = ft_lstnew((*f)(lst->content)); if (!new_lst) { ft_lstclear(&new_lst, del); return (NULL); } new_lst->next = ft_lstmap(lst->next, f, del); return (new_lst); }