Correcteed destroy function

This commit is contained in:
Anton Dolozin 2025-11-08 18:31:48 +01:00
parent ff659f8685
commit fcda739883

View File

@ -16,6 +16,17 @@ struct station* create_station(){
}
/// funkcia pre uvolnenie pamati
void destroy_station(struct station* station){
/// prechadzanie a uvolnenie jednotlyvich linked listov a ich prvkov
for(int i = 0; i<station->track_count; i++){
struct car* tmp = station->tracks[i];
while(tmp){
struct car* toFree = tmp;
tmp = tmp->next;
free(toFree);
}
}
// Mozeme uvolnit' array jednoducho, pretoze allokovali sme ho ako jeden 'kus'
free(station->tracks);
// uvolnenie stanice