From 477a6ea70d0bb1b1dfe9cbd9a15b6dad0284ddeb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 21 Feb 2018 18:40:03 +0300 Subject: all another C++'11 iterators --- plugins/SecureIM/src/crypt_icons.cpp | 10 +++++----- plugins/SecureIM/src/crypt_lists.cpp | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'plugins/SecureIM') diff --git a/plugins/SecureIM/src/crypt_icons.cpp b/plugins/SecureIM/src/crypt_icons.cpp index 59e0059773..2c7eb2fd75 100644 --- a/plugins/SecureIM/src/crypt_icons.cpp +++ b/plugins/SecureIM/src/crypt_icons.cpp @@ -19,9 +19,9 @@ static ICON_CACHE& getCacheItem(int mode, int type) int m = mode & 0x0f, s = (mode & SECURED) >> 4, i; // разобрали на части - режим и состояние HICON icon; - for (i = 0; i < arIcoList.getCount(); i++) - if (arIcoList[i].mode == ((type << 8) | mode)) - return arIcoList[i]; + for (auto &it : arIcoList) + if (it->mode == ((type << 8) | mode)) + return *it; i = s; switch (type) { @@ -106,8 +106,8 @@ void ShowStatusIconNotify(MCONTACT hContact) void RefreshContactListIcons(void) { - for (int i = 0; i < arIcoList.getCount(); i++) - arIcoList[i].hCLIcon = nullptr; + for (auto &it : arIcoList) + it->hCLIcon = nullptr; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) if (isSecureProtocol(hContact)) diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp index bb97d160f0..be5f6a5e0a 100644 --- a/plugins/SecureIM/src/crypt_lists.cpp +++ b/plugins/SecureIM/src/crypt_lists.cpp @@ -56,9 +56,9 @@ void loadSupportedProtocols() void freeSupportedProtocols() { - for (int j = 0; j < arProto.getCount(); j++) { - mir_free(arProto[j]->name); - mir_free(arProto[j]); + for (auto &it : arProto) { + mir_free(it->name); + mir_free(it); } arProto.destroy(); @@ -66,9 +66,9 @@ void freeSupportedProtocols() pSupPro getSupPro(MCONTACT hContact) { - for (int j = 0; j < arProto.getCount(); j++) - if (Proto_IsProtoOnContact(hContact, arProto[j]->name)) - return arProto[j]; + for (auto &it : arProto) + if (Proto_IsProtoOnContact(hContact, it->name)) + return it; return nullptr; } @@ -127,8 +127,7 @@ void loadContactList() // free list of secureIM users void freeContactList() { - for (int j = 0; j < arClist.getCount(); j++) { - pUinKey p = arClist[j]; + for (auto &p : arClist) { cpp_delete_context(p->cntx); p->cntx = nullptr; mir_free(p->tmp); mir_free(p->msgSplitted); @@ -153,9 +152,9 @@ pUinKey getUinKey(MCONTACT hContact) pUinKey getUinCtx(HANDLE cntx) { - for (int j = 0; j < arClist.getCount(); j++) - if (arClist[j]->cntx == cntx) - return arClist[j]; + for (auto &it : arClist) + if (it->cntx == cntx) + return it; return nullptr; } -- cgit v1.2.3