diff options
author | jackpoz <giacomopoz@gmail.com> | 2014-01-13 22:52:35 +0100 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2014-01-13 22:52:35 +0100 |
commit | d78e69cdc6be1d762dcaaafc489c027896790fa3 (patch) | |
tree | 7f5c5561732e8ebe696f65b314cdd75fffad05b3 /src | |
parent | 88ecc9533a2d132d15f222b7b05eeb0f96930e21 (diff) |
Core/Instances: Fix memory leak in InstanceSaveMgr
Fix memory leak in InstanceSaveMgr added in 1f170c99efec6c89b9a454a3aa17511341f61659 .
Make InstanceSave::SetToDelete() private since it's not supposed to be used by anything other than InstanceSave or its friend class InstanceSaveMgr .
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Instances/InstanceSaveMgr.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Instances/InstanceSaveMgr.h | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index e37e6847bdd..c46d9002604 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -164,7 +164,11 @@ void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId) void InstanceSaveManager::UnloadInstanceSave(uint32 InstanceId) { if (InstanceSave* save = GetInstanceSave(InstanceId)) + { save->UnloadIfEmpty(); + if (save->m_toDelete) + delete save; + } } InstanceSave::InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset) diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h index 7a89e6488f0..1d753ebaa48 100644 --- a/src/server/game/Instances/InstanceSaveMgr.h +++ b/src/server/game/Instances/InstanceSaveMgr.h @@ -115,16 +115,16 @@ class InstanceSave but that would depend on a lot of things that can easily change in future */ Difficulty GetDifficulty() const { return m_difficulty; } + typedef std::list<Player*> PlayerListType; + typedef std::list<Group*> GroupListType; + private: + bool UnloadIfEmpty(); /* used to flag the InstanceSave as to be deleted, so the caller can delete it */ void SetToDelete(bool toDelete) { m_toDelete = toDelete; } - typedef std::list<Player*> PlayerListType; - typedef std::list<Group*> GroupListType; - private: - bool UnloadIfEmpty(); /* the only reason the instSave-object links are kept is because the object-instSave links need to be broken at reset time */ /// @todo: Check if maybe it's enough to just store the number of players/groups |