diff options
author | George Hazan <george.hazan@gmail.com> | 2015-01-14 14:29:52 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-01-14 14:29:52 +0000 |
commit | e37f12dec252a78cdf94d31ccc87ce37c1436a1f (patch) | |
tree | 09d50f93a1f260e054908c775264819e82a0db48 /plugins/Dbx_mdb/src/dbsettings.cpp | |
parent | 5f4a6f00c20468e6adc3a7bf691eccef55d2324c (diff) |
txn_ptr & cursor_ptr classes
git-svn-id: http://svn.miranda-ng.org/main/trunk@11853 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb/src/dbsettings.cpp')
-rw-r--r-- | plugins/Dbx_mdb/src/dbsettings.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/plugins/Dbx_mdb/src/dbsettings.cpp b/plugins/Dbx_mdb/src/dbsettings.cpp index c345c42174..375b973c7e 100644 --- a/plugins/Dbx_mdb/src/dbsettings.cpp +++ b/plugins/Dbx_mdb/src/dbsettings.cpp @@ -119,7 +119,7 @@ LBL_Seek: DBCachedContact *cc = (contactID) ? m_cache->GetCachedContact(contactID) : NULL;
- txn_lock trnlck(m_pMdbEnv); + txn_ptr trnlck(m_pMdbEnv); //mdb_open(trnlck, "settings", 0, &m_dbSettings); DBSettingKey keySearch;
@@ -495,7 +495,7 @@ STDMETHODIMP_(BOOL) CDbxMdb::WriteContactSetting(MCONTACT contactID, DBCONTACTWR }
for (;; Remap()) {
- txn_lock trnlck(m_pMdbEnv); + txn_ptr trnlck(m_pMdbEnv); if (mdb_put(trnlck, m_dbSettings, &key, &data, MDB_RESERVE) != 0)
return 1;
@@ -564,7 +564,7 @@ STDMETHODIMP_(BOOL) CDbxMdb::DeleteContactSetting(MCONTACT contactID, LPCSTR szM MDB_val key = { 2 * sizeof(DWORD) + settingNameLen, &keySearch }, data;
for (;; Remap()) {
- txn_lock trnlck(m_pMdbEnv); + txn_ptr trnlck(m_pMdbEnv); if (mdb_del(trnlck, m_dbSettings, &key, &data))
return 1; @@ -599,24 +599,24 @@ STDMETHODIMP_(BOOL) CDbxMdb::EnumContactSettings(MCONTACT contactID, DBCONTACTEN memset(keySearch.szSettingName, 0, SIZEOF(keySearch.szSettingName));
LIST<char> arSettings(50);
-
- txn_lock trnlck(m_pMdbEnv); - MDB_cursor *cursor; - mdb_cursor_open(trnlck, m_dbSettings, &cursor); -
- MDB_val key = { sizeof(keySearch), &keySearch }, data; - mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE); - do { - DBSettingKey *pKey = (DBSettingKey*)key.mv_data; - if (pKey->dwContactID != contactID || pKey->dwOfsModule != keySearch.dwOfsModule) - break; + {
+ txn_ptr trnlck(m_pMdbEnv, true); + cursor_ptr cursor(trnlck, m_dbSettings); +
+ MDB_val key = { sizeof(keySearch), &keySearch }, data; + if (mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE) == MDB_SUCCESS) { + do { + DBSettingKey *pKey = (DBSettingKey*)key.mv_data; + if (pKey->dwContactID != contactID || pKey->dwOfsModule != keySearch.dwOfsModule) + break; - char szSetting[256];
- strncpy_s(szSetting, pKey->szSettingName, key.mv_size - sizeof(DWORD)*2);
- arSettings.insert(mir_strdup(szSetting));
+ char szSetting[256];
+ strncpy_s(szSetting, pKey->szSettingName, key.mv_size - sizeof(DWORD) * 2);
+ arSettings.insert(mir_strdup(szSetting));
+ } + while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS); + } } - while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0); - mdb_cursor_close(cursor); for (int i = 0; i < arSettings.getCount(); i++) { result = (dbces->pfnEnumProc)(arSettings[i], dbces->lParam);
|