aboutsummaryrefslogtreecommitdiff
path: root/src/shared/Database/SQLStorageImpl.h
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/shared/Database/SQLStorageImpl.h
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/shared/Database/SQLStorageImpl.h')
-rw-r--r--src/shared/Database/SQLStorageImpl.h7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/shared/Database/SQLStorageImpl.h b/src/shared/Database/SQLStorageImpl.h
index 5ad8a66679a..c74be48c34c 100644
--- a/src/shared/Database/SQLStorageImpl.h
+++ b/src/shared/Database/SQLStorageImpl.h
@@ -122,7 +122,7 @@ void SQLStorageLoaderBase<T>::Load(SQLStorage &store)
{
uint32 maxi;
Field *fields;
- QueryResult *result = WorldDatabase.PQuery("SELECT MAX(%s) FROM %s", store.entry_field, store.table);
+ QueryResult_AutoPtr result = WorldDatabase.PQuery("SELECT MAX(%s) FROM %s", store.entry_field, store.table);
if(!result)
{
sLog.outError("Error loading %s table (not exist?)\n", store.table);
@@ -130,14 +130,12 @@ void SQLStorageLoaderBase<T>::Load(SQLStorage &store)
}
maxi = (*result)[0].GetUInt32()+1;
- delete result;
result = WorldDatabase.PQuery("SELECT COUNT(*) FROM %s", store.table);
if(result)
{
fields = result->Fetch();
store.RecordCount = fields[0].GetUInt32();
- delete result;
}
else
store.RecordCount = 0;
@@ -158,7 +156,6 @@ void SQLStorageLoaderBase<T>::Load(SQLStorage &store)
{
store.RecordCount = 0;
sLog.outError("Error in %s table, probably sql file format was updated (there should be %d fields in sql).\n", store.table, store.iNumFields);
- delete result;
exit(1); // Stop server at loading broken or non-compatible table.
}
@@ -206,8 +203,6 @@ void SQLStorageLoaderBase<T>::Load(SQLStorage &store)
++count;
}while( result->NextRow() );
- delete result;
-
store.pIndex = newIndex;
store.MaxEntry = maxi;
store.data = _data;