From d9cb0702158fd045285f2c0a904cb31a45a3864a Mon Sep 17 00:00:00 2001 From: Anubisss Date: Sat, 23 Jan 2010 14:45:58 +0100 Subject: 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 --- src/shared/Database/DBCStore.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/shared/Database/DBCStore.h') diff --git a/src/shared/Database/DBCStore.h b/src/shared/Database/DBCStore.h index ea4ce109e27..4344b6e6450 100644 --- a/src/shared/Database/DBCStore.h +++ b/src/shared/Database/DBCStore.h @@ -83,7 +83,7 @@ class DBCStorage uint32 sqlRecordCount = 0; uint32 sqlHighestIndex = 0; Field *fields = NULL; - QueryResult *result = NULL; + QueryResult_AutoPtr result = QueryResult_AutoPtr(NULL); // Load data from sql if (sql) { @@ -188,7 +188,6 @@ class DBCStorage break; case FT_STRING: sLog.outError("Unsupported data type in table '%s' at char %d", sql->sqlTableName.c_str(), columnNumber); - delete result; return false; case FT_SORT: break; @@ -201,14 +200,12 @@ class DBCStorage else { sLog.outError("Incorrect sql format string '%s' at char %d", sql->sqlTableName.c_str(), columnNumber); - delete result; return false; } } if (sqlColumnNumber != (result->GetFieldCount()-1)) { sLog.outError("SQL and DBC format strings are not matching for table: '%s'", sql->sqlTableName.c_str()); - delete result; return false; } @@ -216,7 +213,6 @@ class DBCStorage ++rowIndex; }while (result->NextRow()); } - delete result; } // error in dbc file at loading if NULL -- cgit v1.2.3