From 3caa2bbe731a5c86c5629a5fe3a1e73eb0e5ba5b Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Mon, 2 Nov 2020 14:27:52 +0100 Subject: [PATCH] add --- cv5/a_train.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index ef92ddc..ceb0ce9 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -43,12 +43,12 @@ void cancel_train(struct car* first) { if(first == NULL){ return; } - if(first->next == NULL){ - free(first); + if(first->next != NULL){ + cancel_train(first->next); + first->next = NULL; } - else if(first->next != NULL){ - cancel_train(first->next); - first->next = NULL; + if(first->next == NULL){ + free(first); } }