lstiter reparee fonction sapplique sur content

This commit is contained in:
Hugo LAMY
2019-11-29 16:27:48 +01:00
parent ced3108518
commit aa802f51c9
4 changed files with 24 additions and 17 deletions

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:14:11 by hulamy #+# #+# */
/* Updated: 2019/11/28 17:19:34 by hulamy ### ########.fr */
/* Updated: 2019/11/29 16:23:54 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -75,13 +75,11 @@
void ft_lstiter(t_list *lst, void (*f)(void *))
{
if (lst && f)
{
while (lst)
if (!f)
return;
while (lst)
{
f(lst);
f(lst->content);
lst = lst->next;
}
{
}

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:15:42 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:34:19 by hulamy ### ########.fr */
/* Updated: 2019/11/29 16:21:26 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -102,12 +102,12 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
if (!lst)
return (NULL);
tmp = (t_list*)f(lst);
tmp = (t_list*)f(lst->content);
new = tmp;
while (lst->next)
{
lst = lst->next;
if (!(tmp->next = (t_list*)f(lst)))
if (!(tmp->next = (t_list*)f(lst->content)))
{
del(tmp->next->content);
free(tmp->next);