free lst et string

This commit is contained in:
hugodu69
2019-12-16 00:21:50 +01:00
parent 8f396aa7bd
commit 9f576ff28f

View File

@@ -121,6 +121,7 @@ void free_lst(t_gnlist **lst, const int fd)
tmp = *lst;
while ((*lst)->next && (*lst)->next->lfd != fd)
(*lst) = (*lst)->next;
free(tmp->string);
free(tmp);
(*lst)->next = (*lst)->next->next;
}
@@ -148,16 +149,6 @@ int get_next_line(const int fd, char **line)
return (-1);
if (*(lst->string) && ++ret == 1)
(lst->string)[0] = '\0';
// free(lst);
// lst = lst->next;
// while (lst->next->lfd != fd)
// lst = lst->next;
// lst->next = lst->next->next;
// free(lst->next);
// while (lst->next && lst->next->lfd != fd)
// lst = lst->next;
// free(lst->next);
// lst->next = lst->next->next;
free_lst(&lst, fd);
return (ret);
}