mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Instances: Fix memory leak in InstanceSaveMgr
Fix memory leak in InstanceSaveMgr added in 1f170c99ef .
Make InstanceSave::SetToDelete() private since it's not supposed to be used by anything other than InstanceSave or its friend class InstanceSaveMgr .
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user