From ffed014ccd5370a5073594d55dd0dc88080e0b3d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 18 Jan 2015 18:55:32 +0000 Subject: contacts cache details to be completely hidden from the outside world git-svn-id: http://svn.miranda-ng.org/main/trunk@11873 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/database/database.h | 3 ++- src/modules/database/dbintf.cpp | 2 +- src/modules/database/mdatabasecache.cpp | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/modules/database/database.h b/src/modules/database/database.h index ebc5a6cdd4..c0acab5c48 100644 --- a/src/modules/database/database.h +++ b/src/modules/database/database.h @@ -25,6 +25,7 @@ class MDatabaseCache : public MIDatabaseCache { HANDLE m_hCacheHeap; char* m_lastSetting; + size_t m_contactSize; DBCachedContact *m_lastVL; mir_cs m_cs; @@ -35,7 +36,7 @@ class MDatabaseCache : public MIDatabaseCache void FreeCachedVariant(DBVARIANT* V); public: - MDatabaseCache(); + MDatabaseCache(size_t); ~MDatabaseCache(); protected: diff --git a/src/modules/database/dbintf.cpp b/src/modules/database/dbintf.cpp index 62b7db18a3..fed80cd528 100644 --- a/src/modules/database/dbintf.cpp +++ b/src/modules/database/dbintf.cpp @@ -123,7 +123,7 @@ static INT_PTR srvInitInstance(WPARAM wParam, LPARAM lParam) { MIDatabase* pDb = (MIDatabase*)lParam; if (pDb != NULL) - pDb->m_cache = new MDatabaseCache(); + pDb->m_cache = new MDatabaseCache(pDb->GetContactSize()); return 0; } diff --git a/src/modules/database/mdatabasecache.cpp b/src/modules/database/mdatabasecache.cpp index 3cc8be5972..27283ebb8d 100644 --- a/src/modules/database/mdatabasecache.cpp +++ b/src/modules/database/mdatabasecache.cpp @@ -34,7 +34,8 @@ static int compareGlobals(const DBCachedGlobalValue *p1, const DBCachedGlobalVal return strcmp(p1->name, p2->name); } -MDatabaseCache::MDatabaseCache() : +MDatabaseCache::MDatabaseCache(size_t _size) : + m_contactSize(_size), m_lSettings(100, stringCompare), m_lContacts(50, NumericKeySortT), m_lGlobalSettings(50, compareGlobals) @@ -60,7 +61,7 @@ DBCachedContact* MDatabaseCache::AddContactToCache(MCONTACT contactID) if (index != -1) return m_lContacts[index]; - DBCachedContact *cc = (DBCachedContact*)HeapAlloc(m_hCacheHeap, HEAP_ZERO_MEMORY, sizeof(DBCachedContact)); + DBCachedContact *cc = (DBCachedContact*)HeapAlloc(m_hCacheHeap, HEAP_ZERO_MEMORY, m_contactSize); cc->contactID = contactID; cc->nSubs = -1; m_lContacts.insert(cc); -- cgit v1.2.3