From 90b4d09356a49c0f1c9f4ca0dc1cbc27f11fc2ae Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 15 Nov 2012 18:43:55 +0000 Subject: no more offline contacts git-svn-id: http://svn.miranda-ng.org/main/trunk@2319 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/database/mdatabasecache.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/modules') diff --git a/src/modules/database/mdatabasecache.cpp b/src/modules/database/mdatabasecache.cpp index 91c95ee656..b5b103461b 100644 --- a/src/modules/database/mdatabasecache.cpp +++ b/src/modules/database/mdatabasecache.cpp @@ -52,10 +52,16 @@ MDatabaseCache::~MDatabaseCache() DBCachedContact* MDatabaseCache::AddContactToCache(HANDLE hContact) { - DBCachedContact* VL = (DBCachedContact*)HeapAlloc(m_hCacheHeap, HEAP_ZERO_MEMORY, sizeof(DBCachedContact)); - VL->hContact = hContact; - m_lContacts.insert(VL); - return VL; + DBCachedContact VLtemp = { hContact }; + int index = m_lContacts.getIndex(&VLtemp); + if (index == -1) { + DBCachedContact* VL = (DBCachedContact*)HeapAlloc(m_hCacheHeap, HEAP_ZERO_MEMORY, sizeof(DBCachedContact)); + VL->hContact = hContact; + m_lContacts.insert(VL); + return VL; + } + + return m_lContacts[ index ]; } DBCachedContact* MDatabaseCache::GetCachedContact(HANDLE hContact) -- cgit v1.2.3