summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-21 18:30:20 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-21 18:40:13 +0300
commit95ce21d8512af00a4c5f607091a459b789f79b79 (patch)
treea2ac7c7c7887b4c8c80e6a59ad9cc24ce4758e91
parent9ceaf3659acce44d579c2db5b29d4b48dfe893f2 (diff)
mmap: C++'11 iterators
-rw-r--r--plugins/Db3x_mmap/src/dbcache.cpp3
-rw-r--r--plugins/Db3x_mmap/src/dbcontacts.cpp5
-rw-r--r--plugins/Db3x_mmap/src/dbcrypt.cpp19
-rw-r--r--plugins/Db3x_mmap/src/dbmodulechain.cpp3
4 files changed, 12 insertions, 18 deletions
diff --git a/plugins/Db3x_mmap/src/dbcache.cpp b/plugins/Db3x_mmap/src/dbcache.cpp
index abfe6a099d..1196d4bceb 100644
--- a/plugins/Db3x_mmap/src/dbcache.cpp
+++ b/plugins/Db3x_mmap/src/dbcache.cpp
@@ -123,8 +123,7 @@ void CDb3Mmap::DBFill(DWORD ofs, int bytes)
static VOID CALLBACK DoBufferFlushTimerProc(HWND, UINT, UINT_PTR idEvent, DWORD)
{
- for (int i = 0; i < g_Dbs.getCount(); i++) {
- CDb3Mmap *db = g_Dbs[i];
+ for (auto &db : g_Dbs) {
if (db->m_flushBuffersTimerId != idEvent)
continue;
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp
index 4ff87d4efe..f7f913368d 100644
--- a/plugins/Db3x_mmap/src/dbcontacts.cpp
+++ b/plugins/Db3x_mmap/src/dbcontacts.cpp
@@ -420,9 +420,8 @@ void CDb3Mmap::FillContacts()
DeleteContactSetting(hh, META_PROTO, "MetaLink");
}
- for (int i = 0; i < arMetas.getCount(); i++) {
- COldMeta &p = arMetas[i];
- DBCachedContact *ccMeta = p.cc;
+ for (auto &p : arMetas) {
+ DBCachedContact *ccMeta = p->cc;
MCONTACT hContact = ccMeta->contactID;
// we don't need it anymore
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp
index e04cc9b7be..777baae06e 100644
--- a/plugins/Db3x_mmap/src/dbcrypt.cpp
+++ b/plugins/Db3x_mmap/src/dbcrypt.cpp
@@ -91,13 +91,11 @@ void sttContactEnum(MCONTACT contactID, const char *szModule, CDb3Mmap *db)
SettingUgraderParam param = { db, szModule, contactID, &arSettings };
db->EnumContactSettings(0, sttSettingUgrader, szModule, &param);
- for (int i = 0; i < arSettings.getCount(); i++) {
- VarDescr &p = arSettings[i];
-
+ for (auto &p : arSettings) {
size_t len;
- BYTE *pResult = db->m_crypto->encodeString(p.szValue, &len);
+ BYTE *pResult = db->m_crypto->encodeString(p->szValue, &len);
if (pResult != nullptr) {
- DBCONTACTWRITESETTING dbcws = { szModule, p.szVar };
+ DBCONTACTWRITESETTING dbcws = { szModule, p->szVar };
dbcws.value.type = DBVT_ENCRYPTED;
dbcws.value.pbVal = pResult;
dbcws.value.cpbVal = (WORD)len;
@@ -340,13 +338,12 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID)
NeedBytes(1);
}
- for (int i = 0; i < arSettings.getCount(); i++) {
- VarDescr &p = arSettings[i];
+ for (auto &p : arSettings) {
if (!m_bEncrypted) {
size_t encodedLen;
- BYTE *pResult = m_crypto->encodeString(p.szValue, &encodedLen);
+ BYTE *pResult = m_crypto->encodeString(p->szValue, &encodedLen);
if (pResult != nullptr) {
- DBCONTACTWRITESETTING dbcws = { szModule, p.szVar };
+ DBCONTACTWRITESETTING dbcws = { szModule, p->szVar };
dbcws.value.type = DBVT_ENCRYPTED;
dbcws.value.pbVal = pResult;
dbcws.value.cpbVal = (WORD)encodedLen;
@@ -357,9 +354,9 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID)
}
else {
size_t realLen;
- ptrA decoded(m_crypto->decodeString((PBYTE)(char*)p.szValue, p.iLen, &realLen));
+ ptrA decoded(m_crypto->decodeString((PBYTE)(char*)p->szValue, p->iLen, &realLen));
if (decoded != nullptr) {
- DBCONTACTWRITESETTING dbcws = { szModule, p.szVar };
+ DBCONTACTWRITESETTING dbcws = { szModule, p->szVar };
dbcws.value.type = DBVT_UNENCRYPTED;
dbcws.value.pszVal = decoded;
dbcws.value.cchVal = (WORD)realLen;
diff --git a/plugins/Db3x_mmap/src/dbmodulechain.cpp b/plugins/Db3x_mmap/src/dbmodulechain.cpp
index 6b43ba3c82..fe8735e044 100644
--- a/plugins/Db3x_mmap/src/dbmodulechain.cpp
+++ b/plugins/Db3x_mmap/src/dbmodulechain.cpp
@@ -129,8 +129,7 @@ char* CDb3Mmap::GetModuleNameByOfs(DWORD ofs)
STDMETHODIMP_(BOOL) CDb3Mmap::EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam)
{
- for (int i = 0; i < m_lMods.getCount(); i++) {
- ModuleName *pmn = m_lMods[i];
+ for (auto &pmn : m_lMods) {
int ret = pFunc(pmn->name, pParam);
if (ret)
return ret;