diff options
-rw-r--r-- | level.c | 31 |
1 files changed, 21 insertions, 10 deletions
@@ -627,35 +627,46 @@ void FreeLevel(LEVEL *level) { if(level) { if(level->info) { - free(level->info->name); - free(level->info->desc); + if(level->info->name) + free(level->info->name); + + if(level->info->desc) + free(level->info->desc); + free(level->info); } - if(level->nRooms) { + if(level->rooms) { for(i = 0; i < level->nRooms; i++) { - if(level->rooms[i].nWalls) free(level->rooms[i].walls); + if(level->rooms[i].walls) + free(level->rooms[i].walls); /*if(level->rooms[i].nThings) free(level->rooms[i].things); if(level->rooms[i].nGates) { free(level->rooms[i].gates); free(level->rooms[i].gateinfo); }*/ - free(level->rooms[i].id); + if(level->rooms[i].id) + free(level->rooms[i].id); } + free(level->rooms); } - if(level->nGates) { + if(level->gates) { for(i = 0; i < level->nGates; i++) { - if(level->gates[i].nWalls) free(level->gates[i].walls); + if(level->gates[i].walls) + free(level->gates[i].walls); } + free(level->gates); } - if(level->nTextures) { - for(i = 0; i < level->nTextures; i++) - free(level->textures[i].name); + if(level->textures) { + for(i = 0; i < level->nTextures; i++) { + if(level->textures[i].name) + free(level->textures[i].name); + } free(level->textures); } |