diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 9d97b1eca..ed1a1e808 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -10,7 +10,6 @@ SET(common_sources database.cpp dbasync.cpp dbcore.cpp - DBMemLeak.cpp debug.cpp emu_opcodes.cpp EmuTCPConnection.cpp @@ -103,7 +102,6 @@ SET(common_headers database.h dbasync.h dbcore.h - DBMemLeak.h debug.h deity.h emu_opcodes.h diff --git a/common/DBMemLeak.cpp b/common/DBMemLeak.cpp deleted file mode 100644 index 2b457b1ad..000000000 --- a/common/DBMemLeak.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifdef _EQDEBUG -#include "../common/debug.h" -#include -#include -#include -#include "../common/Mutex.h" -#include "DBMemLeak.h" - -#include - -#ifdef _WINDOWS -#define snprintf _snprintf -#define strncasecmp _strnicmp -#define strcasecmp _stricmp -#endif - -DBMemLeak dbmemleak; -LinkedList* list = 0; -Mutex MDBMemLeak; - -DBMemLeak::DBMemLeak() { - list = new LinkedList; -} - -DBMemLeak::~DBMemLeak() { - LinkedListIterator iterator(*list); - iterator.Reset(); - while (iterator.MoreElements()) { - char tmp[200]; - snprintf(tmp, sizeof(tmp) - 3, "DB Mem Leak: Block=%6d, Query=%s", iterator.GetData()->memblock, iterator.GetData()->query); - snprintf(tmp, sizeof(tmp), "%s\n", tmp); - OutputDebugString(tmp); - iterator.Advance(); - } - safe_delete(list); -} - -void DBMemLeak::Alloc(const void* result, const char* query) { - LockMutex lock(&MDBMemLeak); - long requestNumber; - uint8* tmp2 = new uint8; - _CrtIsMemoryBlock( tmp2, 1, &requestNumber, 0, 0 ); - safe_delete(tmp2); - DBMemLeakStruct* tmp = (DBMemLeakStruct*) new uchar[sizeof(DBMemLeakStruct) + strlen(query) + 1]; - tmp->result = result; - tmp->memblock = requestNumber; - strcpy(tmp->query, query); - list->Append(tmp); -} - -void DBMemLeak::Free(const void* result) { - LockMutex lock(&MDBMemLeak); - LinkedListIterator iterator(*list); - iterator.Reset(); - while (iterator.MoreElements()) { - if (result == iterator.GetData()->result) - iterator.RemoveCurrent(); - else - iterator.Advance(); - } -} -#endif diff --git a/common/DBMemLeak.h b/common/DBMemLeak.h deleted file mode 100644 index 48f3f7374..000000000 --- a/common/DBMemLeak.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifdef _EQDEBUG -#ifndef DBMemLeak_H -#define DBMemLeak_H -#include "../common/types.h" -#include "../common/linked_list.h" - -#define mysql_free_result(r) { DBMemLeak::Free(r); mysql_free_result(r); } - -struct DBMemLeakStruct { - const void* result; - uint32 memblock; - char query[0]; -}; - -class DBMemLeak { -public: - DBMemLeak(); - ~DBMemLeak(); - - static void Alloc(const void* result, const char* query); - static void Free(const void* result); -}; - -#endif -#endif diff --git a/common/dbcore.h b/common/dbcore.h index b43752c1f..ed5e62133 100644 --- a/common/dbcore.h +++ b/common/dbcore.h @@ -7,7 +7,6 @@ //#include #endif #include -#include "../common/DBMemLeak.h" #include "../common/types.h" #include "../common/Mutex.h" #include "../common/linked_list.h" diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 98699fd99..b78218b8b 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -1,7 +1,9 @@ -#include "shareddb.h" #include #include #include + +#include "shareddb.h" +#include "mysql.h" #include "Item.h" #include "classes.h" #include "rulesys.h"