-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstmap.c
More file actions
33 lines (30 loc) · 1.2 KB
/
ft_lstmap.c
File metadata and controls
33 lines (30 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sryou <sryou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/19 10:08:07 by sryou #+# #+# */
/* Updated: 2022/03/19 10:36:09 by sryou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
{
t_list *newlst;
t_list *temp;
newlst = 0;
while (lst)
{
temp = ft_lstnew((*f)(lst->content));
if (temp == 0)
{
ft_lstclear(&newlst, del);
return (0);
}
ft_lstadd_back(&newlst, temp);
lst = lst->next;
}
return (newlst);
}