diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-15 14:11:34 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-15 14:11:34 +0000 |
commit | 3abf318a0815ee223cc04e06f0e281c81d9531f1 (patch) | |
tree | 15a33fc703b264d3ad72eadf5adcc5aa5ab6032e /src | |
parent | 21a1bd3567e3c894b8e9de69cd1f52898c5b5c92 (diff) |
fix for the zombi contacts creation (bug imported from Miranda IM CVS, so it existed before October 27th, 2004 :)
git-svn-id: http://svn.miranda-ng.org/main/trunk@9806 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/database/mdatabasecache.cpp | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/src/modules/database/mdatabasecache.cpp b/src/modules/database/mdatabasecache.cpp index 7944a6bc86..9c86b64472 100644 --- a/src/modules/database/mdatabasecache.cpp +++ b/src/modules/database/mdatabasecache.cpp @@ -56,7 +56,7 @@ DBCachedContact* MDatabaseCache::AddContactToCache(MCONTACT contactID) int index = m_lContacts.getIndex((DBCachedContact*)&contactID);
if (index != -1)
return m_lContacts[index];
-
+
DBCachedContact *cc = (DBCachedContact*)HeapAlloc(m_hCacheHeap, HEAP_ZERO_MEMORY, sizeof(DBCachedContact));
cc->contactID = contactID;
cc->nSubs = -1;
@@ -198,54 +198,49 @@ STDMETHODIMP_(DBVARIANT*) MDatabaseCache::GetCachedValuePtr(MCONTACT contactID, // a contact setting
DBCachedContactValue *V, *V1;
- DBCachedContact VLtemp,*VL;
-
- VLtemp.contactID = contactID;
+ DBCachedContact ccTemp, *cc;
- int index = m_lContacts.getIndex(&VLtemp);
- if (index == -1) {
- if ( bAllocate != 1 )
- return NULL;
+ ccTemp.contactID = contactID;
- VL = AddContactToCache(contactID);
- }
- else VL = m_lContacts[index];
+ int index = m_lContacts.getIndex(&ccTemp);
+ if (index == -1)
+ return NULL;
- m_lastVL = VL;
+ m_lastVL = cc = m_lContacts[index];
- for ( V = VL->first; V != NULL; V = V->next)
+ for (V = cc->first; V != NULL; V = V->next)
if (V->name == szSetting)
break;
- if ( V == NULL ) {
- if ( bAllocate != 1 )
+ if (V == NULL) {
+ if (bAllocate != 1)
return NULL;
V = (DBCachedContactValue *)HeapAlloc(m_hCacheHeap, HEAP_ZERO_MEMORY, sizeof(DBCachedContactValue));
- if (VL->last)
- VL->last->next = V;
+ if (cc->last)
+ cc->last->next = V;
else
- VL->first = V;
- VL->last = V;
+ cc->first = V;
+ cc->last = V;
V->name = szSetting;
}
- else if ( bAllocate == -1 ) {
+ else if (bAllocate == -1) {
m_lastVL = NULL;
FreeCachedVariant(&V->value);
- if ( VL->first == V ) {
- VL->first = V->next;
- if (VL->last == V)
- VL->last = V->next; // NULL
+ if (cc->first == V) {
+ cc->first = V->next;
+ if (cc->last == V)
+ cc->last = V->next; // NULL
}
else
- for ( V1 = VL->first; V1 != NULL; V1 = V1->next )
- if ( V1->next == V ) {
+ for (V1 = cc->first; V1 != NULL; V1 = V1->next)
+ if (V1->next == V) {
V1->next = V->next;
- if (VL->last == V)
- VL->last = V1;
+ if (cc->last == V)
+ cc->last = V1;
break;
}
- HeapFree(m_hCacheHeap,0,V);
+ HeapFree(m_hCacheHeap, 0, V);
return NULL;
}
|