mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-28 21:02:14 +01:00
Implement QueryResult_AutoPtr type which is ACE's reference counted auto_ptr(ACE_Refcounted_Auto_Ptr) for QueryResult pointers.
Use this auto_ptr for every DB queries(except QueryNamedResult yet). This patch guarantees NO memory leaks from QueryResult pointers. Thanks to raczman for the idea and for the helping to make this patch. --HG-- branch : trunk
This commit is contained in:
@@ -566,7 +566,7 @@ void WorldSession::LoadGlobalAccountData()
|
||||
);
|
||||
}
|
||||
|
||||
void WorldSession::LoadAccountData(QueryResult* result, uint32 mask)
|
||||
void WorldSession::LoadAccountData(QueryResult_AutoPtr result, uint32 mask)
|
||||
{
|
||||
for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
|
||||
if (mask & (1 << i))
|
||||
@@ -598,8 +598,6 @@ void WorldSession::LoadAccountData(QueryResult* result, uint32 mask)
|
||||
m_accountData[type].Data = fields[2].GetCppString();
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::string data)
|
||||
@@ -648,7 +646,7 @@ void WorldSession::LoadTutorialsData()
|
||||
for (int aX = 0 ; aX < 8 ; ++aX )
|
||||
m_Tutorials[ aX ] = 0;
|
||||
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7 FROM character_tutorial WHERE account = '%u'", GetAccountId());
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7 FROM character_tutorial WHERE account = '%u'", GetAccountId());
|
||||
|
||||
if(result)
|
||||
{
|
||||
@@ -660,10 +658,7 @@ void WorldSession::LoadTutorialsData()
|
||||
m_Tutorials[iI] = fields[iI].GetUInt32();
|
||||
}
|
||||
while( result->NextRow() );
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
m_TutorialsChanged = false;
|
||||
}
|
||||
|
||||
@@ -682,12 +677,9 @@ void WorldSession::SaveTutorialsData()
|
||||
|
||||
uint32 Rows=0;
|
||||
// it's better than rebuilding indexes multiple times
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT count(*) AS r FROM character_tutorial WHERE account = '%u'", GetAccountId());
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT count(*) AS r FROM character_tutorial WHERE account = '%u'", GetAccountId());
|
||||
if(result)
|
||||
{
|
||||
Rows = result->Fetch()[0].GetUInt32();
|
||||
delete result;
|
||||
}
|
||||
|
||||
if (Rows)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user