diff --git a/cv5/a_train.c b/cv5/a_train.c index 2d9a33d..9774063 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -31,19 +31,19 @@ void print_train(struct car* first) { } } -void cancel_train(struct car* first) { - struct car* this; +void cancel_train(struct car* first, int val) { if(first == NULL){ exit(0); } - else{ + else if(first->next == NULL){ + struct car* this; this = first; first = this->next; free(this); - cancel_train(first->next); - free(first); - } + cancel_train(first->next); + free(first); + } diff --git a/cv5/a_train.h b/cv5/a_train.h index 0297dfa..4088b1d 100644 --- a/cv5/a_train.h +++ b/cv5/a_train.h @@ -40,7 +40,7 @@ void print_train(struct car* first); * Zrusenie vsetkych voznov vo vlaku. * @arg smernik na prvy vozen */ -void cancel_train(struct car* first); +void cancel_train(struct car* first, int val); /** * Vyradenie vsetkych voznov, ktorych cielova stanica je target