diff --git a/du6/a_station.c b/du6/a_station.c index bff0be8..99ef39a 100644 --- a/du6/a_station.c +++ b/du6/a_station.c @@ -15,10 +15,11 @@ void destroy_station(struct station* station) { return; } - struct car* currentTracks = station->tracks; - for (int i = 0; i < STATION_SIZE, i++) + //preiteruje cez kazdy jeden 'track/carar' v poli 'tracks' a pre kazdy jeden track + for (int i = 0; i < station->track_count, i++) { + struct car* currentTracks = station->tracks; while (currentTracks->next != NULL) { struct car* tempTrack = currentTracks; @@ -26,9 +27,16 @@ void destroy_station(struct station* station) free(tempTrack); } } + free(station->tracks); + free(station); } -int select_track(struct station* station, const char* target){ +int select_track(struct station* station, const char* target) +{ + if (station == NULL) + { + station = (struct station*)calloc(1, sizeof(station)); + } return 0; }