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:
1 parent
c784110d87
commit
d9cb070215
76 files changed
+458
-1108
No files matched your search
+1
-6
@@ -125,7 +125,7 @@ bool Group::Create(const uint64 &guid, const char * name)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Group::LoadGroupFromDB(const uint64 &leaderGuid, QueryResult *result, bool loadMembers)
|
||||
bool Group::LoadGroupFromDB(const uint64 &leaderGuid, QueryResult_AutoPtr result, bool loadMembers)
|
||||
{
|
||||
if(isBGGroup())
|
||||
return false;
|
||||
@@ -144,10 +144,7 @@ bool Group::LoadGroupFromDB(const uint64 &leaderGuid, QueryResult *result, bool
|
||||
|
||||
// group leader not exist
|
||||
if(!objmgr.GetPlayerNameByGUID(m_leaderGuid, m_leaderName))
|
||||
{
|
||||
if(!external) delete result;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_groupType = (*result)[13].GetBool() ? GROUPTYPE_RAID : GROUPTYPE_NORMAL;
|
||||
|
||||
@@ -172,7 +169,6 @@ bool Group::LoadGroupFromDB(const uint64 &leaderGuid, QueryResult *result, bool
|
||||
|
||||
for (int i=0; i<TARGETICONCOUNT; ++i)
|
||||
m_targetIcons[i] = (*result)[5+i].GetUInt64();
|
||||
if(!external) delete result;
|
||||
|
||||
if(loadMembers)
|
||||
{
|
||||
@@ -184,7 +180,6 @@ bool Group::LoadGroupFromDB(const uint64 &leaderGuid, QueryResult *result, bool
|
||||
{
|
||||
LoadMemberFromDB((*result)[0].GetUInt32(), (*result)[2].GetUInt8(), (*result)[1].GetBool());
|
||||
} while( result->NextRow() );
|
||||
delete result;
|
||||
// group too small
|
||||
if(GetMembersCount() < 2)
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user