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