mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-26 03:42:37 +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:
@@ -537,7 +537,7 @@ void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data )
|
||||
CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack, GetAccountId(), friendNote, "SELECT guid, race, account FROM characters WHERE name = '%s'", friendName.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote)
|
||||
void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult_AutoPtr result, uint32 accountId, std::string friendNote)
|
||||
{
|
||||
uint64 friendGuid;
|
||||
uint64 friendAcctid;
|
||||
@@ -558,8 +558,6 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc
|
||||
team = Player::TeamForRace((*result)[1].GetUInt8());
|
||||
friendAcctid = (*result)[2].GetUInt32();
|
||||
|
||||
delete result;
|
||||
|
||||
if ( session->GetSecurity() >= SEC_MODERATOR || sWorld.getConfig(CONFIG_ALLOW_GM_FRIEND) || accmgr.GetSecurity(friendAcctid) < SEC_MODERATOR)
|
||||
{
|
||||
if(friendGuid)
|
||||
@@ -627,7 +625,7 @@ void WorldSession::HandleAddIgnoreOpcode( WorldPacket & recv_data )
|
||||
CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddIgnoreOpcodeCallBack, GetAccountId(), "SELECT guid FROM characters WHERE name = '%s'", IgnoreName.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId)
|
||||
void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult_AutoPtr result, uint32 accountId)
|
||||
{
|
||||
uint64 IgnoreGuid;
|
||||
FriendsResult ignoreResult;
|
||||
@@ -644,8 +642,6 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 acc
|
||||
{
|
||||
IgnoreGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
|
||||
delete result;
|
||||
|
||||
if(IgnoreGuid)
|
||||
{
|
||||
if(IgnoreGuid==session->GetPlayer()->GetGUID()) //not add yourself
|
||||
@@ -1306,7 +1302,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
|
||||
|
||||
uint32 accid = plr->GetSession()->GetAccountId();
|
||||
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid);
|
||||
QueryResult_AutoPtr result = loginDatabase.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid);
|
||||
if(!result)
|
||||
{
|
||||
SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND, charname.c_str());
|
||||
@@ -1330,8 +1326,6 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
|
||||
data << msg;
|
||||
_player->GetSession()->SendPacket(&data);
|
||||
|
||||
delete result;
|
||||
|
||||
sLog.outDebug("Received whois command from player %s for character %s", GetPlayer()->GetName(), charname.c_str());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user