From 086aacf1ff2942eaf8e202078c3ab0990cbd4f78 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 7 Jun 2010 16:38:52 +0200 Subject: [PATCH] added cell list cleanup --- game/esm_store/reclists.hpp | 18 +++++++++++++++++- game/esm_store/store.hpp | 5 ----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/game/esm_store/reclists.hpp b/game/esm_store/reclists.hpp index bd04ad3c59..6fd6e9f728 100644 --- a/game/esm_store/reclists.hpp +++ b/game/esm_store/reclists.hpp @@ -77,9 +77,25 @@ namespace ESMS IntCells intCells; // List of exterior cells. Indexed as extCells[gridX][gridY]. - typedef std::map > ExtCells; + typedef std::map ExtCellsCol; + typedef std::map ExtCells; ExtCells extCells; + ~CellList() + { + for (IntCells::iterator it = intCells.begin(); it!=intCells.end(); ++it) + delete it->second; + + for (ExtCells::iterator it = extCells.begin(); it!=extCells.end(); ++it) + { + ExtCellsCol& col = it->second; + for (ExtCellsCol::iterator it = col.begin(); it!=col.end(); ++it) + { + delete it->second; + } + } + } + const Cell* findInt(const std::string &id) const { IntCells::const_iterator it = intCells.find(id); diff --git a/game/esm_store/store.hpp b/game/esm_store/store.hpp index db97d4357a..2271f4238a 100644 --- a/game/esm_store/store.hpp +++ b/game/esm_store/store.hpp @@ -11,11 +11,6 @@ you can replace the storage method later without touching the loading code. Cutting down dependencies also help on the general maintainability. - - TODO FIXME: Cleanup. The RecLists store pointers to new'd objects, - but these are never deleted anywhere. Right now this data is - persistant through the application lifetime so it doesn't matter, - but fix it later. */ #include "esm/records.hpp"