tjr erreur free

This commit is contained in:
Hugo LAMY
2019-12-30 20:44:05 +01:00
parent 5ad7f13d93
commit 9d6a33242f

View File

@@ -29,7 +29,7 @@
{
if ((ret = get_next_line(fd[i], &line)) > 0)
{
printf("[fd%i-%i] %s\n", fd[i], ret, line);
printf(" [fd%i-%i] \n", fd[i], ret );
free(line);
j = 0;
}
@@ -40,10 +40,10 @@
j++;
}
else if (*line != '\0')
printf("[fd%i-%i] %s\n", fd[i], ret, line);
printf(" [fd%i-%i] \n", fd[i], ret);
else
{
printf("[fd%i-%i]*FINI*(%s)\n", fd[i], ret, line);
printf("[fd%i-%i]*FINI*\n", fd[i], ret);
free(line);
j++;
}
@@ -60,21 +60,27 @@
int free_lst(t_gnlist **lst, int ret)
{
t_gnlist *tmp;
int count;
tmp = *lst;
while (tmp != NULL && tmp->next != *lst && tmp->str == '\0')
tmp = tmp->next;
if (ret == -1 || tmp->str == '\0')
count = 0;
while (tmp != NULL && tmp->next != *lst && tmp->str[0] == '\0')
{
while (tmp != NULL)
{
tmp = (*lst)->next;
free((*lst)->str);
free(*lst);
*lst = NULL;
*lst = tmp;
}
count++;
tmp = tmp->next;
}
printf("%i", count);
// if (ret == -1 || tmp->str == '\0')
// {
// while (tmp != NULL)
// {
// tmp = (*lst)->next;
// free((*lst)->str);
// free(*lst);
// *lst = NULL;
// *lst = tmp;
// }
// }
return (ret);
}