diff options
author | George Hazan <george.hazan@gmail.com> | 2014-02-25 21:19:01 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-02-25 21:19:01 +0000 |
commit | 831890a8024a9519cdf725c5a098898734e54e93 (patch) | |
tree | 2a124d40ecb90fd74b331230ce966dee374719c5 /src | |
parent | d84c40216b5e60224eb365f633b5f142d459fc9e (diff) |
metacontacts in the database cache
git-svn-id: http://svn.miranda-ng.org/main/trunk@8276 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/database/mdatabasecache.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/modules/database/mdatabasecache.cpp b/src/modules/database/mdatabasecache.cpp index 1dcd29861e..2a2812515d 100644 --- a/src/modules/database/mdatabasecache.cpp +++ b/src/modules/database/mdatabasecache.cpp @@ -24,12 +24,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h"
#include "database.h"
-static int stringCompare(const char* p1, const char* p2)
+static int stringCompare(const char *p1, const char *p2)
{
return strcmp(p1, p2);
}
-static int compareGlobals(const DBCachedGlobalValue* p1, const DBCachedGlobalValue* p2)
+static int compareGlobals(const DBCachedGlobalValue *p1, const DBCachedGlobalValue *p2)
{
return strcmp(p1->name, p2->name);
}
@@ -56,14 +56,14 @@ DBCachedContact* MDatabaseCache::AddContactToCache(MCONTACT contactID) mir_cslock lck(m_cs);
int index = m_lContacts.getIndex((DBCachedContact*)&contactID);
- if (index == -1) {
- DBCachedContact* VL = (DBCachedContact*)HeapAlloc(m_hCacheHeap, HEAP_ZERO_MEMORY, sizeof(DBCachedContact));
- VL->contactID = contactID;
- m_lContacts.insert(VL);
- return VL;
- }
-
- return m_lContacts[index];
+ if (index != -1)
+ return m_lContacts[index];
+
+ DBCachedContact *cc = (DBCachedContact*)HeapAlloc(m_hCacheHeap, HEAP_ZERO_MEMORY, sizeof(DBCachedContact));
+ cc->contactID = contactID;
+ cc->nSubs = -1;
+ m_lContacts.insert(cc);
+ return cc;
}
DBCachedContact* MDatabaseCache::GetCachedContact(MCONTACT contactID)
@@ -96,15 +96,17 @@ void MDatabaseCache::FreeCachedContact(MCONTACT contactID) if (index == -1)
return;
- DBCachedContact* VL = m_lContacts[index];
- DBCachedContactValue* V = VL->first;
+ DBCachedContact *cc = m_lContacts[index];
+ DBCachedContactValue* V = cc->first;
while (V != NULL) {
DBCachedContactValue* V1 = V->next;
FreeCachedVariant(&V->value);
HeapFree(m_hCacheHeap, 0, V);
V = V1;
}
- HeapFree(m_hCacheHeap, 0, VL);
+
+ free(cc->pSubs);
+ HeapFree(m_hCacheHeap, 0, cc);
m_lContacts.remove(index);
}
|