This commit is contained in:
Bohdan Kapliuk 2024-11-03 17:01:29 +02:00
parent c49dd96c13
commit 3bc100aab9

View File

@ -10,10 +10,20 @@ struct station* create_station(){
} }
void destroy_station(struct station* station){ void destroy_station(struct station* station){
void destroy_station(struct station* station) {
if (station == NULL) return;
for (int i = 0; i < station->track_count; i++) {
struct car* current = station->tracks[i];
while (current != NULL) {
struct car* temp = current;
current = current->next;
free(temp);
}
}
free(station->tracks); free(station->tracks);
free(station->track_count); free(station);
station->tracks = NULL; }
station->track_count = NULL;
} }
int select_track(struct station* station, const char* target){ int select_track(struct station* station, const char* target){