From 9d6a33242f7109a19f4b6d13c0901289c1d7f3ee Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Mon, 30 Dec 2019 20:44:05 +0100 Subject: [PATCH] tjr erreur free --- get_next_line.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/get_next_line.c b/get_next_line.c index fffae83..43f338e 100644 --- a/get_next_line.c +++ b/get_next_line.c @@ -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); }