aboutsummaryrefslogtreecommitdiff
path: root/src/game/AuctionHouseMgr.cpp
diff options
context:
space:
mode:
authorAnubisss <none@none>2010-01-23 14:45:58 +0100
committerAnubisss <none@none>2010-01-23 14:45:58 +0100
commitd9cb0702158fd045285f2c0a904cb31a45a3864a (patch)
treecdc6a7c6a83c6eea603ae296a653fb9f04945aad /src/game/AuctionHouseMgr.cpp
parentc784110d87666579f18620a98e1e57118db4a9cf (diff)
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
Diffstat (limited to 'src/game/AuctionHouseMgr.cpp')
-rw-r--r--src/game/AuctionHouseMgr.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp
index b2b5d250b28..f2531811205 100644
--- a/src/game/AuctionHouseMgr.cpp
+++ b/src/game/AuctionHouseMgr.cpp
@@ -267,7 +267,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry * auction)
void AuctionHouseMgr::LoadAuctionItems()
{
// data needs to be at first place for Item::LoadFromDB
- QueryResult *result = CharacterDatabase.Query("SELECT data,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid");
+ QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT data,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid");
if (!result)
{
@@ -310,7 +310,6 @@ void AuctionHouseMgr::LoadAuctionItems()
++count;
} while (result->NextRow());
- delete result;
sLog.outString();
sLog.outString(">> Loaded %u auction items", count);
@@ -318,7 +317,7 @@ void AuctionHouseMgr::LoadAuctionItems()
void AuctionHouseMgr::LoadAuctions()
{
- QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse");
+ QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse");
if (!result)
{
barGoLink bar(1);
@@ -330,7 +329,6 @@ void AuctionHouseMgr::LoadAuctions()
Field *fields = result->Fetch();
uint32 AuctionCount=fields[0].GetUInt32();
- delete result;
if (!AuctionCount)
{
@@ -415,7 +413,6 @@ void AuctionHouseMgr::LoadAuctions()
GetAuctionsMap(auctioneerInfo->faction_A)->AddAuction(aItem);
} while (result->NextRow());
- delete result;
sLog.outString();
sLog.outString(">> Loaded %u auctions", AuctionCount);
@@ -506,19 +503,13 @@ void AuctionHouseObject::Update()
if (AuctionsMap.empty())
return;
- QueryResult* result = CharacterDatabase.PQuery("SELECT id FROM auctionhouse WHERE time <= %u ORDER BY TIME ASC", (uint32)curTime+60);
+ QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT id FROM auctionhouse WHERE time <= %u ORDER BY TIME ASC", (uint32)curTime+60);
if (!result)
- {
- delete result;
return;
- }
if (result->GetRowCount() == 0)
- {
- delete result;
return;
- }
vector<uint32> expiredAuctions;
@@ -527,7 +518,6 @@ void AuctionHouseObject::Update()
uint32 tmpdata = result->Fetch()->GetUInt32();
expiredAuctions.push_back(tmpdata);
} while (result->NextRow());
- delete result;
while (!expiredAuctions.empty())
{