aboutsummaryrefslogtreecommitdiff
path: root/src/game/CreatureGroups.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/CreatureGroups.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/CreatureGroups.cpp')
-rw-r--r--src/game/CreatureGroups.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/game/CreatureGroups.cpp b/src/game/CreatureGroups.cpp
index afaca9cf714..6b497129fe8 100644
--- a/src/game/CreatureGroups.cpp
+++ b/src/game/CreatureGroups.cpp
@@ -78,14 +78,13 @@ void CreatureGroupManager::LoadCreatureFormations()
CreatureGroupMap.clear();
//Check Integrity of the table
- QueryResult *result = WorldDatabase.PQuery("SELECT MAX(leaderGUID) FROM creature_formations");
+ QueryResult_AutoPtr result = WorldDatabase.PQuery("SELECT MAX(leaderGUID) FROM creature_formations");
if(!result)
{
sLog.outErrorDb(" ...an error occured while loading the table creature_formations ( maybe it doesn't exist ?)\n");
return;
}
- delete result;
//Get group data
result = WorldDatabase.PQuery("SELECT leaderGUID, memberGUID, dist, angle, groupAI FROM creature_formations ORDER BY leaderGUID");
@@ -126,14 +125,13 @@ void CreatureGroupManager::LoadCreatureFormations()
// check data correctness
{
- QueryResult* result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE guid = %u", group_member->leaderGUID);
+ QueryResult_AutoPtr result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE guid = %u", group_member->leaderGUID);
if(!result)
{
sLog.outErrorDb("creature_formations table leader guid %u incorrect (not exist)", group_member->leaderGUID);
delete group_member;
continue;
}
- delete result;
result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE guid = %u", memberGUID);
if(!result)
@@ -142,7 +140,6 @@ void CreatureGroupManager::LoadCreatureFormations()
delete group_member;
continue;
}
- delete result;
}
CreatureGroupMap[memberGUID] = group_member;
@@ -152,8 +149,6 @@ void CreatureGroupManager::LoadCreatureFormations()
sLog.outString();
sLog.outString( ">> Loaded %u creatures in formations", total_records );
sLog.outString();
- //Free some heap
- delete result;
}
void CreatureGroup::AddMember(Creature *member)