diff options
author | Anubisss <none@none> | 2010-01-23 14:45:58 +0100 |
---|---|---|
committer | Anubisss <none@none> | 2010-01-23 14:45:58 +0100 |
commit | d9cb0702158fd045285f2c0a904cb31a45a3864a (patch) | |
tree | cdc6a7c6a83c6eea603ae296a653fb9f04945aad /src/game/PoolHandler.cpp | |
parent | c784110d87666579f18620a98e1e57118db4a9cf (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/PoolHandler.cpp')
-rw-r--r-- | src/game/PoolHandler.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/game/PoolHandler.cpp b/src/game/PoolHandler.cpp index c2cb8045b81..15afb656805 100644 --- a/src/game/PoolHandler.cpp +++ b/src/game/PoolHandler.cpp @@ -350,7 +350,7 @@ PoolHandler::PoolHandler() void PoolHandler::LoadFromDB() { - QueryResult *result = WorldDatabase.Query("SELECT MAX(entry) FROM pool_template"); + QueryResult_AutoPtr result = WorldDatabase.Query("SELECT MAX(entry) FROM pool_template"); if (!result) { sLog.outString(">> Table pool_template is empty."); @@ -361,7 +361,6 @@ void PoolHandler::LoadFromDB() { Field *fields = result->Fetch(); max_pool_id = fields[0].GetUInt16(); - delete result; } mPoolTemplate.resize(max_pool_id + 1); @@ -392,8 +391,6 @@ void PoolHandler::LoadFromDB() } while (result->NextRow()); - delete result; - sLog.outString(); sLog.outString( ">> Loaded %u objects pools", count ); @@ -458,7 +455,6 @@ void PoolHandler::LoadFromDB() } while (result->NextRow()); sLog.outString(); sLog.outString( ">> Loaded %u creatures in pools", count ); - delete result; } // Gameobjects @@ -530,7 +526,6 @@ void PoolHandler::LoadFromDB() } while( result->NextRow() ); sLog.outString(); sLog.outString( ">> Loaded %u gameobject in pools", count ); - delete result; } // Pool of pools @@ -619,7 +614,6 @@ void PoolHandler::LoadFromDB() } } } - delete result; sLog.outString(); sLog.outString( ">> Loaded %u pools in mother pools", count ); @@ -629,7 +623,7 @@ void PoolHandler::LoadFromDB() // The initialize method will spawn all pools not in an event and not in another pool, this is why there is 2 left joins with 2 null checks void PoolHandler::Initialize() { - QueryResult *result = WorldDatabase.Query("SELECT DISTINCT pool_template.entry FROM pool_template LEFT JOIN game_event_pool ON pool_template.entry=game_event_pool.pool_entry LEFT JOIN pool_pool ON pool_template.entry=pool_pool.pool_id WHERE game_event_pool.pool_entry IS NULL AND pool_pool.pool_id IS NULL"); + QueryResult_AutoPtr result = WorldDatabase.Query("SELECT DISTINCT pool_template.entry FROM pool_template LEFT JOIN game_event_pool ON pool_template.entry=game_event_pool.pool_entry LEFT JOIN pool_pool ON pool_template.entry=pool_pool.pool_id WHERE game_event_pool.pool_entry IS NULL AND pool_pool.pool_id IS NULL"); uint32 count=0; if (result) { @@ -647,7 +641,6 @@ void PoolHandler::Initialize() SpawnPool(pool_entry, 0, TYPEID_UNIT); count++; } while (result->NextRow()); - delete result; } sLog.outBasic("Pool handling system initialized, %u pools spawned.", count); |