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