From e0089afd765b7c4b8e9247531f5ea951de372188 Mon Sep 17 00:00:00 2001 From: Oleksandr Hryshchenko Date: Fri, 5 Nov 2021 01:54:29 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'cv4/a=5Ftrain.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv4/a_train.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index 53f3c94..5fdfd7e 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -43,9 +43,10 @@ void cancel_train(struct car* first){ while(next != NULL){ next = temp->next; - free(temp); + temp = next; } + free(temp); first = NULL; } @@ -60,11 +61,12 @@ struct car* clear_train(struct car* first, const char* target){ while(temp != NULL){ next = temp->next; if(!strcmp(temp->value, target)) - free(temp); + temp = next; if(!first) first = temp; } + free(temp); return first; } \ No newline at end of file