summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-01-12 21:16:52 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-01-12 21:16:52 +0000
commit3f5208b9147b32ddcf259ec8bb3fb280192928f8 (patch)
tree18556c5846701e85403843f4bc66422dcdb3bf6a /plugins
parent0eab78fa8138134301a4887d292f5c2e4c260a34 (diff)
fix for reading
git-svn-id: http://svn.miranda-ng.org/main/trunk@11846 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Dbx_mdb/src/dbcontacts.cpp11
-rw-r--r--plugins/Dbx_mdb/src/dbintf.cpp6
-rw-r--r--plugins/Dbx_mdb/src/dbmodulechain.cpp12
3 files changed, 10 insertions, 19 deletions
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp
index 88a31f58d7..fbb3c89276 100644
--- a/plugins/Dbx_mdb/src/dbcontacts.cpp
+++ b/plugins/Dbx_mdb/src/dbcontacts.cpp
@@ -165,21 +165,18 @@ void CDbxMdb::FillContacts()
MDB_txn *txn;
mdb_txn_begin(m_pMdbEnv, NULL, MDB_RDONLY, &txn);
+ mdb_open(txn, "contacts", MDB_CREATE | MDB_INTEGERKEY, &m_dbContacts);
MDB_cursor *cursor;
mdb_cursor_open(txn, m_dbContacts, &cursor);
- DWORD dwContactId;
- DBContact value;
-
MDB_val key, data;
- key.mv_size = sizeof(DWORD); key.mv_data = &dwContactId;
- data.mv_size = sizeof(DBContact); data.mv_data = &value;
-
while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
- if (value.signature != DBCONTACT_SIGNATURE)
+ DBContact *dbc = (DBContact*)data.mv_data;
+ if (dbc->signature != DBCONTACT_SIGNATURE)
DatabaseCorruption(NULL);
+ DWORD dwContactId = *(DWORD*)key.mv_data;
DBCachedContact *cc = m_cache->AddContactToCache(dwContactId);
cc->dwDriverData = 0;
CheckProto(cc, "");
diff --git a/plugins/Dbx_mdb/src/dbintf.cpp b/plugins/Dbx_mdb/src/dbintf.cpp
index 43a15b6457..f646273100 100644
--- a/plugins/Dbx_mdb/src/dbintf.cpp
+++ b/plugins/Dbx_mdb/src/dbintf.cpp
@@ -95,12 +95,6 @@ int CDbxMdb::Load(bool bSkipInit)
return EGROKPRF_CANTREAD;
if (!bSkipInit) {
- MDB_txn *txn;
- mdb_txn_begin(m_pMdbEnv, NULL, 0, &txn);
- mdb_open(txn, "contacts", MDB_CREATE | MDB_INTEGERKEY, &m_dbContacts);
- mdb_open(txn, "events", MDB_CREATE | MDB_INTEGERKEY, &m_dbEvents);
- mdb_txn_commit(txn);
-
if (InitModuleNames()) return EGROKPRF_CANTREAD;
if (InitCrypt()) return EGROKPRF_CANTREAD;
diff --git a/plugins/Dbx_mdb/src/dbmodulechain.cpp b/plugins/Dbx_mdb/src/dbmodulechain.cpp
index 70e843111a..59b2b8d509 100644
--- a/plugins/Dbx_mdb/src/dbmodulechain.cpp
+++ b/plugins/Dbx_mdb/src/dbmodulechain.cpp
@@ -43,18 +43,17 @@ int CDbxMdb::InitModuleNames(void)
m_maxModuleID = 0;
MDB_txn *txn;
- mdb_txn_begin(m_pMdbEnv, NULL, MDB_RDONLY, &txn);
+ mdb_txn_begin(m_pMdbEnv, NULL, 0, &txn);
mdb_open(txn, "modules", MDB_CREATE | MDB_INTEGERKEY, &m_dbModules);
+ mdb_open(txn, "events", MDB_CREATE | MDB_INTEGERKEY, &m_dbEvents);
MDB_cursor *cursor;
mdb_cursor_open(txn, m_dbModules, &cursor);
- int rc, moduleId;
- char valueBuf[100];
- MDB_val key = { sizeof(int), &moduleId }, data = { sizeof(valueBuf), valueBuf };
+ MDB_val key, data;
- while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
- DBModuleName *pmod = (DBModuleName*)valueBuf;
+ while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
+ DBModuleName *pmod = (DBModuleName*)data.mv_data;
if (pmod->signature != DBMODULENAME_SIGNATURE)
DatabaseCorruption(NULL);
@@ -62,6 +61,7 @@ int CDbxMdb::InitModuleNames(void)
memcpy(pVal, pmod->name, pmod->cbName);
pVal[pmod->cbName] = 0;
+ int moduleId = *(int*)key.mv_data;
AddToList(pVal, moduleId);
if (moduleId > m_maxModuleID)