Correcteed destroy function
This commit is contained in:
parent
ff659f8685
commit
fcda739883
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user