From 68533f05b3df86702d54c4e546e2b9245866be98 Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Fri, 15 Mar 2019 16:00:20 +0100 Subject: [PATCH] Remove memory leaks from map destruction --- src/map.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/map.c b/src/map.c index 4f48093..f757c34 100644 --- a/src/map.c +++ b/src/map.c @@ -99,8 +99,6 @@ map_tile_destroy(MapTile *tile) static void switch_tile(Map *map, Position *tile_pos, MapTile *tile, MapTile **oldTile) { - const Position *cr = &map->currentRoom; - // Set the decoration sprites position to match tile pos tile->sprite->pos = POS(tile_pos->x * TILE_DIMENSION + (map->currentRoom.x * GAME_VIEW_WIDTH), tile_pos->y * TILE_DIMENSION + (map->currentRoom.y * GAME_VIEW_HEIGHT)); @@ -425,6 +423,12 @@ void map_room_destroy(Room *room) if (room->tiles[i][j]) { map_tile_destroy(room->tiles[i][j]); } + if (room->doors[i][j]) { + map_tile_destroy(room->doors[i][j]); + } + if (room->walls[i][j]) { + map_tile_destroy(room->walls[i][j]); + } if (room->decorations[i][j]) { map_tile_destroy(room->decorations[i][j]); }