From 7fec01783b89fabce955273d7452cebd16dc58b0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 23 Jan 2018 21:25:36 +0300 Subject: even more strict scope --- plugins/Dbx_mdbx/src/dbsettings.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'plugins/Dbx_mdbx/src') diff --git a/plugins/Dbx_mdbx/src/dbsettings.cpp b/plugins/Dbx_mdbx/src/dbsettings.cpp index 312d4aa68e..775e69b733 100644 --- a/plugins/Dbx_mdbx/src/dbsettings.cpp +++ b/plugins/Dbx_mdbx/src/dbsettings.cpp @@ -381,23 +381,24 @@ STDMETHODIMP_(BOOL) CDbxMDBX::DeleteContactSetting(MCONTACT contactID, LPCSTR sz STDMETHODIMP_(BOOL) CDbxMDBX::EnumContactSettings(MCONTACT hContact, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, void *param) { - int result = -1; - - DBSettingKey keyVal = { hContact, GetModuleID(szModule), 0 }; - txn_ptr_ro txn(m_txn_ro); - cursor_ptr_ro cursor(m_curSettings); - LIST arKeys(100); - MDBX_val key = { &keyVal, sizeof(keyVal) }, data; + { + DBSettingKey keyVal = { hContact, GetModuleID(szModule), 0 }; + txn_ptr_ro txn(m_txn_ro); + cursor_ptr_ro cursor(m_curSettings); - for (int res = mdbx_cursor_get(cursor, &key, &data, MDBX_SET_RANGE); res == MDBX_SUCCESS; res = mdbx_cursor_get(cursor, &key, &data, MDBX_NEXT)) { - const DBSettingKey *pKey = (const DBSettingKey*)key.iov_base; - if (pKey->hContact != hContact || pKey->dwModuleId != keyVal.dwModuleId) - break; + MDBX_val key = { &keyVal, sizeof(keyVal) }, data; + + for (int res = mdbx_cursor_get(cursor, &key, &data, MDBX_SET_RANGE); res == MDBX_SUCCESS; res = mdbx_cursor_get(cursor, &key, &data, MDBX_NEXT)) { + const DBSettingKey *pKey = (const DBSettingKey*)key.iov_base; + if (pKey->hContact != hContact || pKey->dwModuleId != keyVal.dwModuleId) + break; - arKeys.insert((char*)pKey->szSettingName); + arKeys.insert((char*)pKey->szSettingName); + } } + int result = -1; for (int i=0; i < arKeys.getCount(); i++) result = pfnEnumProc(arKeys[i], param); -- cgit v1.2.3