diff --git a/du6/a_station.c b/du6/a_station.c index 48ac21d..885f50b 100644 --- a/du6/a_station.c +++ b/du6/a_station.c @@ -9,7 +9,25 @@ struct station* create_station(){ return station; } -void destroy_station(struct station* station){ +void destroy_station(struct station* station) +{ + if (station == NULL) + { + return; + } + struct car* currentTracks = station->tracks; + + for (int i = 0; i < STATION_SIZE, i++) + { + while (currentTracks->next != NULL) + { + struct car* tempTrack = currentTracks; + currentTracks = currentTracks->next; + free(tempTrack); + } + } + + } int select_track(struct station* station, const char* target){