diff options
author | George Hazan <george.hazan@gmail.com> | 2015-01-18 18:55:32 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-01-18 18:55:32 +0000 |
commit | ffed014ccd5370a5073594d55dd0dc88080e0b3d (patch) | |
tree | 6d8c5c00d7d5e22607e55aa5ce73c1e2b8139044 | |
parent | cdad72e9512d163ed15bc89bd0a93e7da2ee4c50 (diff) |
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
-rw-r--r-- | include/delphi/m_db_int.inc | 4 | ||||
-rw-r--r-- | include/m_db_int.h | 22 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcontacts.cpp | 27 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbevents.cpp | 12 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 8 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/dbcontacts.cpp | 15 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/dbevents.cpp | 6 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/dbintf.h | 14 | ||||
-rw-r--r-- | plugins/TabSRMM/src/contactcache.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.cpp | 4 | ||||
-rw-r--r-- | src/modules/database/database.h | 3 | ||||
-rw-r--r-- | src/modules/database/dbintf.cpp | 2 | ||||
-rw-r--r-- | src/modules/database/mdatabasecache.cpp | 5 |
13 files changed, 81 insertions, 43 deletions
diff --git a/include/delphi/m_db_int.inc b/include/delphi/m_db_int.inc index 61d8d66fc5..753c4ea5ec 100644 --- a/include/delphi/m_db_int.inc +++ b/include/delphi/m_db_int.inc @@ -42,7 +42,6 @@ type PDBCachedContact = ^TDBCachedContact;
TDBCachedContact = record
contactID:TMCONTACT;
- dwDriverData:dword;
szProto:PAnsiChar;
first :PDBCachedContactValue;
last :PDBCachedContactValue;
@@ -81,6 +80,7 @@ type DeleteContact:function(contactID:TMCONTACT):long; stdcall;
AddContact:function():TMCONTACT; stdcall;
IsDbContact:function(contactID:TMCONTACT):bool; stdcall;
+ GetContactSize:function():long; stdcall;
GetEventCount:function(contactID:TMCONTACT):long; stdcall;
AddEvent:function(contactID:TMCONTACT; dbe:PDBEVENTINFO):HDBEVENT; stdcall;
@@ -162,7 +162,7 @@ const EGROKPRF_UNKHEADER = 2; // header not supported, not a supported profile
EGROKPRF_VERNEWER = 3; // header correct, version in profile newer than reader/writer
EGROKPRF_DAMAGED = 4; // header/version fine, other internal data missing, damaged.
- EGROKPRF_OBSOLETE = 5; // obsolete database version detected, requiring conversion
+ EGROKPRF_OBSOLETE = 5; // obsolete database version detected, requiring conversion
// makeDatabase() error codes
EMKPRF_CREATEFAILED = 1; // for some reason CreateFile() didnt like something
diff --git a/include/m_db_int.h b/include/m_db_int.h index 326103199d..a38c07f140 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -44,10 +44,9 @@ struct DBCachedContactValue DBCachedContactValue *next;
};
-struct DBCachedContact
+struct DBCachedContactBase
{
MCONTACT contactID;
- DWORD dwDriverData;
char *szProto;
DBCachedContactValue *first, *last;
@@ -61,18 +60,24 @@ struct DBCachedContact __forceinline bool IsSub() const { return parentID != 0; }
};
+#ifndef OWN_CACHED_CONTACT
+struct DBCachedContact : public DBCachedContactBase {};
+#else
+struct DBCachedContact;
+#endif
+
interface MIDatabaseCache : public MZeroedObject
{
- STDMETHOD_(DBCachedContact*,AddContactToCache)(MCONTACT contactID) PURE;
+ STDMETHOD_(DBCachedContact*, AddContactToCache)(MCONTACT contactID) PURE;
STDMETHOD_(DBCachedContact*, GetCachedContact)(MCONTACT contactID) PURE;
STDMETHOD_(DBCachedContact*, GetFirstContact)(void) PURE;
STDMETHOD_(DBCachedContact*, GetNextContact)(MCONTACT contactID) PURE;
STDMETHOD_(void, FreeCachedContact)(MCONTACT contactID) PURE;
- STDMETHOD_(char*,InsertCachedSetting)(const char *szName, int) PURE;
- STDMETHOD_(char*,GetCachedSetting)(const char *szModuleName, const char *szSettingName, int, int) PURE;
- STDMETHOD_(void,SetCachedVariant)(DBVARIANT *s, DBVARIANT *d) PURE;
- STDMETHOD_(DBVARIANT*,GetCachedValuePtr)(MCONTACT contactID, char *szSetting, int bAllocate) PURE;
+ STDMETHOD_(char*, InsertCachedSetting)(const char *szName, int) PURE;
+ STDMETHOD_(char*, GetCachedSetting)(const char *szModuleName, const char *szSettingName, int, int) PURE;
+ STDMETHOD_(void, SetCachedVariant)(DBVARIANT *s, DBVARIANT *d) PURE;
+ STDMETHOD_(DBVARIANT*, GetCachedValuePtr)(MCONTACT contactID, char *szSetting, int bAllocate) PURE;
};
interface MIDatabase
@@ -86,8 +91,9 @@ interface MIDatabase STDMETHOD_(MCONTACT, FindNextContact)(MCONTACT contactID, const char *szProto = NULL) PURE;
STDMETHOD_(LONG, DeleteContact)(MCONTACT contactID) PURE;
- STDMETHOD_(MCONTACT, AddContact)(void)PURE;
+ STDMETHOD_(MCONTACT, AddContact)(void) PURE;
STDMETHOD_(BOOL, IsDbContact)(MCONTACT contactID) PURE;
+ STDMETHOD_(LONG, GetContactSize)(void) PURE;
STDMETHOD_(LONG, GetEventCount)(MCONTACT contactID) PURE;
STDMETHOD_(MEVENT, AddEvent)(MCONTACT contactID, DBEVENTINFO *dbe) PURE;
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 9946fe2f9a..b1c842448a 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -46,6 +46,11 @@ STDMETHODIMP_(LONG) CDb3Mmap::GetContactCount(void) return m_dbHeader.contactCount;
}
+STDMETHODIMP_(LONG) CDb3Mmap::GetContactSize(void)
+{
+ return sizeof(DBCachedContact);
+}
+
STDMETHODIMP_(MCONTACT) CDb3Mmap::FindFirstContact(const char *szProto)
{
mir_cslock lck(m_csDbAccess);
@@ -175,7 +180,7 @@ STDMETHODIMP_(MCONTACT) CDb3Mmap::AddContact() }
DBCachedContact *cc = m_cache->AddContactToCache(dbc.dwContactID);
- cc->dwDriverData = ofsNew;
+ cc->dwOfsContact = ofsNew;
NotifyEventHooks(hContactAddedEvent, dbc.dwContactID, 0);
return dbc.dwContactID;
@@ -188,7 +193,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::IsDbContact(MCONTACT contactID) return FALSE;
mir_cslock lck(m_csDbAccess);
- DBContact *dbc = (DBContact*)DBRead(cc->dwDriverData, NULL);
+ DBContact *dbc = (DBContact*)DBRead(cc->dwOfsContact, NULL);
if (dbc->signature == DBCONTACT_SIGNATURE) {
m_cache->AddContactToCache(contactID);
return TRUE;
@@ -219,8 +224,8 @@ static int SortEvent(const DBEvent *p1, const DBEvent *p2) BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
{
mir_cslock lck(m_csDbAccess);
- DBContact *dbMeta = (DBContact*)DBRead(ccMeta->dwDriverData, NULL);
- DBContact *dbSub = (DBContact*)DBRead(ccSub->dwDriverData, NULL);
+ DBContact *dbMeta = (DBContact*)DBRead(ccMeta->dwOfsContact, NULL);
+ DBContact *dbSub = (DBContact*)DBRead(ccSub->dwOfsContact, NULL);
if (dbMeta->signature != DBCONTACT_SIGNATURE || dbSub->signature != DBCONTACT_SIGNATURE)
return 1;
@@ -303,8 +308,8 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
{
mir_cslock lck(m_csDbAccess);
- DBContact dbMeta = *(DBContact*)DBRead(ccMeta->dwDriverData, NULL);
- DBContact dbSub = *(DBContact*)DBRead(ccSub->dwDriverData, NULL);
+ DBContact dbMeta = *(DBContact*)DBRead(ccMeta->dwOfsContact, NULL);
+ DBContact dbSub = *(DBContact*)DBRead(ccSub->dwOfsContact, NULL);
if (dbMeta.signature != DBCONTACT_SIGNATURE || dbSub.signature != DBCONTACT_SIGNATURE)
return 1;
@@ -366,8 +371,8 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) dwOffset = dwNext;
}
- DBWrite(ccSub->dwDriverData, &dbSub, sizeof(DBContact));
- DBWrite(ccMeta->dwDriverData, &dbMeta, sizeof(DBContact));
+ DBWrite(ccSub->dwOfsContact, &dbSub, sizeof(DBContact));
+ DBWrite(ccMeta->dwOfsContact, &dbMeta, sizeof(DBContact));
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
@@ -409,7 +414,7 @@ void CDb3Mmap::FillContacts() else dwContactID = m_dwMaxContactId++;
DBCachedContact *cc = m_cache->AddContactToCache(dwContactID);
- cc->dwDriverData = dwOffset;
+ cc->dwOfsContact = dwOffset;
CheckProto(cc, "");
DBVARIANT dbv; dbv.type = DBVT_DWORD;
@@ -480,7 +485,7 @@ void CDb3Mmap::FillContacts() // we don't need it anymore
if (!GetContactSetting(hContact, META_PROTO, "MetaID", &dbv)) {
DeleteContactSetting(hContact, META_PROTO, "MetaID");
- WipeContactHistory((DBContact*)DBRead(ccMeta->dwDriverData, NULL));
+ WipeContactHistory((DBContact*)DBRead(ccMeta->dwOfsContact, NULL));
}
for (int k = 0; k < ccMeta->nSubs; k++) {
@@ -502,5 +507,5 @@ DWORD CDb3Mmap::GetContactOffset(MCONTACT contactID, DBCachedContact **pcc) DBCachedContact *cc = m_cache->GetCachedContact(contactID);
if (pcc) *pcc = cc;
- return (cc == NULL) ? 0 : cc->dwDriverData;
+ return (cc == NULL) ? 0 : cc->dwOfsContact;
}
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index ee5f449288..7a79bd4327 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -142,7 +142,7 @@ STDMETHODIMP_(MEVENT) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) else neednotify = m_safetyMode;
if (ccSub != NULL) {
- DBContact *pSub = (DBContact*)DBRead(ccSub->dwDriverData, NULL);
+ DBContact *pSub = (DBContact*)DBRead(ccSub->dwOfsContact, NULL);
pSub->eventCount++;
}
@@ -174,7 +174,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent) else cc = NULL;
mir_cslockfull lck(m_csDbAccess);
- DWORD ofsContact = (cc) ? cc->dwDriverData : m_dbHeader.ofsUser;
+ DWORD ofsContact = (cc) ? cc->dwOfsContact : m_dbHeader.ofsUser;
DBContact dbc = *(DBContact*)DBRead(ofsContact, NULL);
DBEvent dbe = *(DBEvent*)DBRead((DWORD)hDbEvent, NULL);
if (dbc.signature != DBCONTACT_SIGNATURE || dbe.signature != DBEVENT_SIGNATURE)
@@ -318,7 +318,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) else cc = NULL;
mir_cslockfull lck(m_csDbAccess);
- DWORD ofsContact = (cc) ? cc->dwDriverData : m_dbHeader.ofsUser;
+ DWORD ofsContact = (cc) ? cc->dwOfsContact : m_dbHeader.ofsUser;
DBContact dbc = *(DBContact*)DBRead(ofsContact, NULL);
DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, NULL);
if (dbe->signature != DBEVENT_SIGNATURE || dbc.signature != DBCONTACT_SIGNATURE)
@@ -376,7 +376,7 @@ STDMETHODIMP_(MEVENT) CDb3Mmap::FindFirstEvent(MCONTACT contactID) if ((cc = m_cache->GetCachedContact(cc->parentID)) == NULL)
return NULL;
- dbc = (DBContact*)DBRead(cc->dwDriverData, NULL);
+ dbc = (DBContact*)DBRead(cc->dwOfsContact, NULL);
if (dbc->signature != DBCONTACT_SIGNATURE)
return NULL;
@@ -405,7 +405,7 @@ STDMETHODIMP_(MEVENT) CDb3Mmap::FindFirstUnreadEvent(MCONTACT contactID) if ((cc = m_cache->GetCachedContact(cc->parentID)) == NULL)
return NULL;
- dbc = (DBContact*)DBRead(cc->dwDriverData, NULL);
+ dbc = (DBContact*)DBRead(cc->dwOfsContact, NULL);
if (dbc->signature != DBCONTACT_SIGNATURE)
return NULL;
@@ -434,7 +434,7 @@ STDMETHODIMP_(MEVENT) CDb3Mmap::FindLastEvent(MCONTACT contactID) if ((cc = m_cache->GetCachedContact(cc->parentID)) == NULL)
return NULL;
- dbc = (DBContact*)DBRead(cc->dwDriverData, NULL);
+ dbc = (DBContact*)DBRead(cc->dwOfsContact, NULL);
if (dbc->signature != DBCONTACT_SIGNATURE)
return NULL;
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index df3d1cd949..761c28ede9 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -21,6 +21,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#define OWN_CACHED_CONTACT
+
#include <m_db_int.h>
/* tree diagram
@@ -174,6 +176,11 @@ struct DBEvent #include <poppack.h>
+struct DBCachedContact : public DBCachedContactBase
+{
+ DWORD dwOfsContact;
+};
+
struct CDb3Mmap : public MIDatabase, public MIDatabaseChecker, public MZeroedObject
{
CDb3Mmap(const TCHAR *tszFileName, int mode);
@@ -209,6 +216,7 @@ public: STDMETHODIMP_(LONG) DeleteContact(MCONTACT contactID);
STDMETHODIMP_(MCONTACT) AddContact(void);
STDMETHODIMP_(BOOL) IsDbContact(MCONTACT contactID);
+ STDMETHODIMP_(LONG) GetContactSize(void);
STDMETHODIMP_(LONG) GetEventCount(MCONTACT contactID);
STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, DBEVENTINFO *dbe);
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp index cf13a782b9..14267ab9ff 100644 --- a/plugins/Dbx_mdb/src/dbcontacts.cpp +++ b/plugins/Dbx_mdb/src/dbcontacts.cpp @@ -46,6 +46,11 @@ STDMETHODIMP_(LONG) CDbxMdb::GetContactCount(void) return m_contactCount;
}
+STDMETHODIMP_(LONG) CDbxMdb::GetContactSize(void)
+{
+ return sizeof(DBCachedContact);
+}
+
STDMETHODIMP_(MCONTACT) CDbxMdb::FindFirstContact(const char *szProto)
{
mir_cslock lck(m_csDbAccess);
@@ -102,9 +107,8 @@ STDMETHODIMP_(MCONTACT) CDbxMdb::AddContact() {
DWORD dwContactId;
- DBContact dbc;
+ DBContact dbc = { 0 };
dbc.signature = DBCONTACT_SIGNATURE;
- dbc.eventCount = 0;
{
mir_cslock lck(m_csDbAccess);
dwContactId = m_dwMaxContactId++;
@@ -119,8 +123,7 @@ STDMETHODIMP_(MCONTACT) CDbxMdb::AddContact() break;
}
- DBCachedContact *cc = m_cache->AddContactToCache(dwContactId);
- cc->dwDriverData = 0;
+ m_cache->AddContactToCache(dwContactId);
}
NotifyEventHooks(hContactAddedEvent, dwContactId, 0);
@@ -185,7 +188,9 @@ void CDbxMdb::FillContacts() DatabaseCorruption(NULL);
DBCachedContact *cc = m_cache->AddContactToCache(*(DWORD*)key.mv_data);
- cc->dwDriverData = dbc->eventCount;
+ cc->dwEventCount = dbc->eventCount;
+ cc->dwFirstUnread = dbc->dwFirstUnread;
+ cc->tsFirstUnread = dbc->tsFirstUnread;
arContacts.insert(cc);
}
}
diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp index 5db1d6714b..720956817d 100644 --- a/plugins/Dbx_mdb/src/dbevents.cpp +++ b/plugins/Dbx_mdb/src/dbevents.cpp @@ -35,7 +35,7 @@ STDMETHODIMP_(LONG) CDbxMdb::GetEventCount(MCONTACT contactID) return m_header.eventCount;
DBCachedContact *cc = m_cache->GetCachedContact(contactID);
- return (cc == NULL) ? 0 : cc->dwDriverData;
+ return (cc == NULL) ? 0 : cc->dwEventCount;
}
STDMETHODIMP_(MEVENT) CDbxMdb::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
@@ -106,7 +106,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) return 0;
if (contactID != NULL) {
- DBContact dbc = { DBCONTACT_SIGNATURE, ++cc->dwDriverData };
+ DBContact dbc = { DBCONTACT_SIGNATURE, ++cc->dwEventCount };
MDB_val keyc = { sizeof(int), &contactID }, datac = { sizeof(DBContact), &dbc };
mdb_put(txn, m_dbContacts, &keyc, &datac, 0);
@@ -115,7 +115,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) key2.dwContactId = ccSub->contactID;
mdb_put(txn, m_dbEventsSort, &key, &data, 0);
- dbc.eventCount = ++ccSub->dwDriverData;
+ dbc.eventCount = ++ccSub->dwEventCount;
keyc.mv_data = &ccSub->contactID;
mdb_put(txn, m_dbContacts, &keyc, &datac, 0);
}
diff --git a/plugins/Dbx_mdb/src/dbintf.h b/plugins/Dbx_mdb/src/dbintf.h index cf9600eadf..ea3d2feb0f 100644 --- a/plugins/Dbx_mdb/src/dbintf.h +++ b/plugins/Dbx_mdb/src/dbintf.h @@ -21,6 +21,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#define OWN_CACHED_CONTACT
+
#include <m_db_int.h>
/* tree diagram
@@ -73,6 +75,8 @@ struct DBContact {
DWORD signature;
DWORD eventCount; // number of events in the chain for this contact
+ DWORD tsFirstUnread;
+ DWORD dwFirstUnread;
};
#define DBMODULENAME_SIGNATURE 0x4DDECADEu
@@ -102,6 +106,13 @@ struct DBEvent #include <poppack.h>
+struct DBCachedContact : public DBCachedContactBase
+{
+ DWORD dwEventCount;
+ DWORD tsFirstUnread;
+ DWORD dwFirstUnread;
+};
+
struct CDbxMdb : public MIDatabase, public MIDatabaseChecker, public MZeroedObject
{
CDbxMdb(const TCHAR *tszFileName, int mode);
@@ -126,7 +137,7 @@ struct CDbxMdb : public MIDatabase, public MIDatabaseChecker, public MZeroedObje __forceinline bool usesPassword() const { return m_bUsesPassword; }
public:
- STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
+ STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
STDMETHODIMP_(LONG) GetContactCount(void);
STDMETHODIMP_(MCONTACT) FindFirstContact(const char *szProto = NULL);
@@ -134,6 +145,7 @@ public: STDMETHODIMP_(LONG) DeleteContact(MCONTACT contactID);
STDMETHODIMP_(MCONTACT) AddContact(void);
STDMETHODIMP_(BOOL) IsDbContact(MCONTACT contactID);
+ STDMETHODIMP_(LONG) GetContactSize(void);
STDMETHODIMP_(LONG) GetEventCount(MCONTACT contactID);
STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, DBEVENTINFO *dbe);
diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp index 65e1fedcd4..f7240bbf3c 100644 --- a/plugins/TabSRMM/src/contactcache.cpp +++ b/plugins/TabSRMM/src/contactcache.cpp @@ -33,7 +33,7 @@ static OBJLIST<CContactCache> arContacts(50, NumericKeySortT); -static DBCachedContact ccInvalid = { 0 }; +static DBCachedContact ccInvalid; CContactCache::CContactCache(const MCONTACT hContact) { diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 62ab6d02e7..d0c06d7821 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -147,11 +147,11 @@ search_again: }
}
if (!clr_found) {
- size_t c_closing = colorname.find_first_of(_T("]"), 0);
+ size_t c_closing = colorname.find_first_of(_T("]"), 0);
if (c_closing == colorname.npos)
c_closing = colorname.length();
const TCHAR *wszColname = colorname.c_str();
- if (endmark != message.npos && c_closing > 2 && c_closing <= 6 && iswalnum(colorname[0]) && iswalnum(colorname[c_closing -1])) {
+ if (endmark != message.npos && c_closing > 2 && c_closing <= 6 && iswalnum(colorname[0]) && iswalnum(colorname[c_closing - 1])) {
RTF_ColorAdd(wszColname, c_closing);
if (!was_added) {
clr_was_added = was_added = true;
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);
|