summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_system_cpp.h31
-rw-r--r--plugins/AVS/src/poll.cpp12
-rw-r--r--plugins/Clist_modern/src/modern_aniavatars.cpp7
-rw-r--r--plugins/FavContacts/src/contact_cache.cpp13
-rw-r--r--plugins/HistorySweeperLight/src/historysweeperlight.cpp6
-rw-r--r--plugins/HistorySweeperLight/src/main.cpp2
-rw-r--r--plugins/Import/src/import.cpp8
-rw-r--r--plugins/NewXstatusNotify/src/main.cpp6
-rw-r--r--plugins/NewXstatusNotify/src/xstatus.cpp36
-rw-r--r--plugins/SmileyAdd/src/SmileyBase.cpp6
-rw-r--r--plugins/SmileyAdd/src/imagecache.cpp4
-rw-r--r--plugins/SmileyAdd/src/richcall.cpp12
-rw-r--r--plugins/StartupSilence/src/main.cpp4
-rw-r--r--plugins/TabSRMM/src/chat_main.cpp3
-rw-r--r--plugins/TabSRMM/src/eventpopups.cpp5
-rw-r--r--plugins/TopToolBar/src/toolbar.cpp6
-rw-r--r--plugins/UserInfoEx/src/mir_contactqueue.cpp19
-rw-r--r--protocols/Discord/src/dispatch.cpp10
-rw-r--r--protocols/IcqOscarJ/src/cookies.cpp6
-rw-r--r--src/core/stdmsg/src/cmdlist.cpp10
-rw-r--r--src/mir_app/src/FontService.cpp18
-rw-r--r--src/mir_app/src/MDatabaseCommon.cpp6
-rw-r--r--src/mir_app/src/chat_manager.cpp5
-rw-r--r--src/mir_app/src/clistsettings.cpp9
-rw-r--r--src/mir_app/src/hotkey_opts.cpp6
-rw-r--r--src/mir_app/src/hotkeys.cpp18
-rw-r--r--src/mir_app/src/icolib.cpp34
-rw-r--r--src/mir_app/src/newplugins.cpp31
-rw-r--r--src/mir_app/src/proto_accs.cpp7
-rw-r--r--src/mir_app/src/sounds.cpp34
-rw-r--r--src/mir_app/src/srmm_statusicon.cpp21
-rw-r--r--src/mir_app/src/srmm_toolbar.cpp30
-rw-r--r--src/mir_app/src/usedIcons.cpp9
-rw-r--r--src/mir_core/src/modules.cpp50
-rw-r--r--src/mir_core/src/subclass.cpp13
-rw-r--r--src/mir_core/src/threads.cpp17
-rw-r--r--src/mir_core/src/windowlist.cpp8
37 files changed, 242 insertions, 280 deletions
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h
index c6bd65a25d..10acdebde4 100644
--- a/include/m_system_cpp.h
+++ b/include/m_system_cpp.h
@@ -196,6 +196,35 @@ template<class T> struct LIST
return (!List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx;
}
+ class reverse_iterator
+ {
+ int index;
+ T **base;
+
+ public:
+ reverse_iterator(const LIST &_lst) :
+ index(_lst.getCount()),
+ base(_lst.getArray())
+ {
+ if (index > 0)
+ index--;
+ }
+
+ class iterator
+ {
+ T** ptr;
+
+ public:
+ iterator(T **_p) : ptr(_p) {}
+ iterator operator++() { --ptr; return *this; }
+ bool operator!=(const iterator &p) { return ptr != p.ptr; }
+ operator T**() const { return ptr; }
+ };
+
+ __inline iterator begin() const { return iterator(base + index); }
+ __inline iterator end() const { return iterator(base); }
+ };
+
__inline void destroy(void) { List_Destroy((SortedList*)this); }
__inline T* find(T *p) const { return (T*)List_Find((SortedList*)this, p); }
__inline int indexOf(T *p) const { return List_IndexOf((SortedList*)this, p); }
@@ -210,6 +239,8 @@ template<class T> struct LIST
__inline T** begin() const { return items; }
__inline T** end() const { return items + count; }
+ __inline reverse_iterator rev_iter() const { return reverse_iterator(*this); }
+
protected:
T** items;
int count, limit, increment;
diff --git a/plugins/AVS/src/poll.cpp b/plugins/AVS/src/poll.cpp
index 1c567c815b..3ba1bf90a0 100644
--- a/plugins/AVS/src/poll.cpp
+++ b/plugins/AVS/src/poll.cpp
@@ -104,11 +104,9 @@ static void QueueRemove(MCONTACT hContact)
{
mir_cslock lck(cs);
- for (int i = queue.getCount() - 1; i >= 0; i--) {
- QueueItem& item = queue[i];
- if (item.hContact == hContact)
- queue.remove(i);
- }
+ for (auto &it : queue.rev_iter())
+ if (it->hContact == hContact)
+ queue.remove(it);
}
// Add an contact to a queue
@@ -120,8 +118,8 @@ void QueueAdd(MCONTACT hContact, int waitTime)
mir_cslock lck(cs);
// Only add if not exists yet
- for (int i = queue.getCount() - 1; i >= 0; i--)
- if (queue[i].hContact == hContact)
+ for (auto &it : queue)
+ if (it->hContact == hContact)
return;
QueueItem *item = new QueueItem;
diff --git a/plugins/Clist_modern/src/modern_aniavatars.cpp b/plugins/Clist_modern/src/modern_aniavatars.cpp
index 2e3686782f..bc72629674 100644
--- a/plugins/Clist_modern/src/modern_aniavatars.cpp
+++ b/plugins/Clist_modern/src/modern_aniavatars.cpp
@@ -265,11 +265,10 @@ static void _AniAva_ResumePainting()
static void _AniAva_ReduceAvatarImages(int startY, int dY, BOOL bDestroyWindow)
{
- for (int i = s_Objects.getCount() - 1; i >= 0; i--) {
- ANIAVA_OBJECT &pai = s_Objects[i];
- int res = SendMessage(pai.hWindow, AAM_REMOVEAVATAR, (WPARAM)startY, (LPARAM)dY);
+ for (auto &it : s_Objects.rev_iter()) {
+ int res = SendMessage(it->hWindow, AAM_REMOVEAVATAR, (WPARAM)startY, (LPARAM)dY);
if (res == 0xDEAD && bDestroyWindow)
- s_Objects.remove(i);
+ s_Objects.remove(it);
}
}
diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp
index d60cd00d84..5ebd3f1c71 100644
--- a/plugins/FavContacts/src/contact_cache.cpp
+++ b/plugins/FavContacts/src/contact_cache.cpp
@@ -38,13 +38,12 @@ int __cdecl CContactCache::OnDbEventAdded(WPARAM hContact, LPARAM hEvent)
TContactInfo *pFound = nullptr;
mir_cslock lck(m_cs);
- for (int i = m_cache.getCount()-1; i >= 0; i--) {
- TContactInfo *p = m_cache[i];
- p->rate *= q;
- if (p->hContact == hContact) {
- p->rate += weight;
- pFound = p;
- m_cache.remove(i); // reinsert to maintain the sort order
+ for (auto &it : m_cache.rev_iter()) {
+ it->rate *= q;
+ if (it->hContact == hContact) {
+ it->rate += weight;
+ pFound = it;
+ m_cache.remove(it); // reinsert to maintain the sort order
}
}
diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp
index ad73c5d46c..65c37b0196 100644
--- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp
+++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp
@@ -224,9 +224,9 @@ int OnWindowEvent(WPARAM, LPARAM lParam)
SweepHistoryFromContact(msgEvData->hContact, Criteria, TRUE);
}
- for (int i = g_hWindows.getCount() - 1; i >= 0; i--)
- if (g_hWindows[i] == PVOID(msgEvData->hContact))
- g_hWindows.remove(i);
+ for (auto &it : g_hWindows.rev_iter())
+ if (it == PVOID(msgEvData->hContact))
+ g_hWindows.remove(it);
break;
}
diff --git a/plugins/HistorySweeperLight/src/main.cpp b/plugins/HistorySweeperLight/src/main.cpp
index 0c1fdc4aac..e0fee84c71 100644
--- a/plugins/HistorySweeperLight/src/main.cpp
+++ b/plugins/HistorySweeperLight/src/main.cpp
@@ -25,7 +25,7 @@ HINSTANCE hInst;
int hLangpack;
-LIST<void> g_hWindows(5);
+LIST<void> g_hWindows(5, PtrKeySortT);
static PLUGININFOEX pluginInfoEx =
{
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index 590bce6a5a..7a133ae62b 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -165,11 +165,11 @@ void CopySettings(MCONTACT srcID, const char *szSrcModule, MCONTACT dstID, const
LIST<char> arSettings(50);
srcDb->EnumContactSettings(srcID, CopySettingsEnum, szSrcModule, &arSettings);
- for (int i = arSettings.getCount() - 1; i >= 0; i--) {
+ for (auto &it : arSettings.rev_iter()) {
DBVARIANT dbv = { 0 };
- if (!srcDb->GetContactSetting(srcID, szSrcModule, arSettings[i], &dbv))
- db_set(dstID, szDstModule, arSettings[i], &dbv);
- mir_free(arSettings[i]);
+ if (!srcDb->GetContactSetting(srcID, szSrcModule, it, &dbv))
+ db_set(dstID, szDstModule, it, &dbv);
+ mir_free(it);
}
}
diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp
index 70a7303963..7345ebb3e0 100644
--- a/plugins/NewXstatusNotify/src/main.cpp
+++ b/plugins/NewXstatusNotify/src/main.cpp
@@ -25,9 +25,9 @@ CLIST_INTERFACE *pcli;
HINSTANCE hInst;
-LIST<DBEVENT> eventListXStatus(10);
-LIST<DBEVENT> eventListStatus(10);
-LIST<DBEVENT> eventListSMsg(10);
+LIST<DBEVENT> eventListXStatus(10, PtrKeySortT);
+LIST<DBEVENT> eventListStatus(10, PtrKeySortT);
+LIST<DBEVENT> eventListSMsg(10, PtrKeySortT);
HANDLE hStatusModeChange, hHookContactStatusChanged, hToolbarButton;
HGENMENU hEnableDisableMenu;
diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp
index a3cacaecb0..a582c8e5c7 100644
--- a/plugins/NewXstatusNotify/src/xstatus.cpp
+++ b/plugins/NewXstatusNotify/src/xstatus.cpp
@@ -42,38 +42,32 @@ void FreeXSC(XSTATUSCHANGE *xsc)
void RemoveLoggedEventsXStatus(MCONTACT hContact)
{
- for (int i = eventListXStatus.getCount() - 1; i >= 0; i--) {
- DBEVENT *dbevent = eventListXStatus[i];
- if (dbevent->hContact == hContact) {
- db_event_delete(dbevent->hContact, dbevent->hDBEvent);
- eventListXStatus.remove(i);
- mir_free(dbevent);
+ for (auto &it : eventListXStatus.rev_iter())
+ if (it->hContact == hContact) {
+ db_event_delete(it->hContact, it->hDBEvent);
+ eventListXStatus.remove(it);
+ mir_free(it);
}
- }
}
void RemoveLoggedEventsStatus(MCONTACT hContact)
{
- for (int i = eventListStatus.getCount() - 1; i >= 0; i--) {
- DBEVENT *dbevent = eventListStatus[i];
- if (dbevent->hContact == hContact) {
- db_event_delete(dbevent->hContact, dbevent->hDBEvent);
- eventListStatus.remove(i);
- mir_free(dbevent);
+ for (auto &it : eventListStatus.rev_iter())
+ if (it->hContact == hContact) {
+ db_event_delete(it->hContact, it->hDBEvent);
+ eventListStatus.remove(it);
+ mir_free(it);
}
- }
}
void RemoveLoggedEventsSMsg(MCONTACT hContact)
{
- for (int i = eventListSMsg.getCount() - 1; i >= 0; i--) {
- DBEVENT *dbevent = eventListSMsg[i];
- if (dbevent->hContact == hContact) {
- db_event_delete(dbevent->hContact, dbevent->hDBEvent);
- eventListSMsg.remove(i);
- mir_free(dbevent);
+ for (auto &it : eventListSMsg.rev_iter())
+ if (it->hContact == hContact) {
+ db_event_delete(it->hContact, it->hDBEvent);
+ eventListSMsg.remove(it);
+ mir_free(it);
}
- }
}
wchar_t* GetStatusTypeAsString(int type, wchar_t *buff)
diff --git a/plugins/SmileyAdd/src/SmileyBase.cpp b/plugins/SmileyAdd/src/SmileyBase.cpp
index 3ecc9e7a10..e9ef6722d8 100644
--- a/plugins/SmileyAdd/src/SmileyBase.cpp
+++ b/plugins/SmileyAdd/src/SmileyBase.cpp
@@ -368,9 +368,9 @@ HRESULT ISmileyBase::GetTooltip(BSTR *bstrHint)
void CloseSmileys(void)
{
- for (int i = regSmileys.getCount() - 1; i >= 0; i--) {
- regSmileys[i]->OnClose();
- regSmileys[i]->Close(OLECLOSE_NOSAVE);
+ for (auto &it : regSmileys.rev_iter()) {
+ it->OnClose();
+ it->Close(OLECLOSE_NOSAVE);
}
}
diff --git a/plugins/SmileyAdd/src/imagecache.cpp b/plugins/SmileyAdd/src/imagecache.cpp
index 87043a9e26..cbf5c69a39 100644
--- a/plugins/SmileyAdd/src/imagecache.cpp
+++ b/plugins/SmileyAdd/src/imagecache.cpp
@@ -36,8 +36,8 @@ static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
lastdllname.Empty();
}
- for (int i = g_imagecache.getCount() - 1; i >= 0; i--)
- g_imagecache[i].ProcessTimerTick(ts);
+ for (auto &it : g_imagecache.rev_iter())
+ it->ProcessTimerTick(ts);
if (g_imagecache.getCount() == 0) {
g_imagecache.destroy();
diff --git a/plugins/SmileyAdd/src/richcall.cpp b/plugins/SmileyAdd/src/richcall.cpp
index 67ab0a5c98..a5a81e12cb 100644
--- a/plugins/SmileyAdd/src/richcall.cpp
+++ b/plugins/SmileyAdd/src/richcall.cpp
@@ -421,8 +421,7 @@ void CloseRichOwnerCallback(HWND hwnd)
void ProcessAllInputAreas(bool restoreText)
{
- for (int i = g_RichEditList.getCount() - 1; i >= 0; i--) {
- RichEditData *rdt = g_RichEditList[i];
+ for (auto &rdt : g_RichEditList.rev_iter())
if (rdt->inputarea) {
if (restoreText) {
CHARRANGE sel = allsel;
@@ -430,16 +429,15 @@ void ProcessAllInputAreas(bool restoreText)
}
else ReplaceContactSmileys(rdt, allsel, false, false);
}
- }
}
void RichEditData_Destroy(void)
{
- for (int i = g_RichEditList.getCount() - 1; i >= 0; i--)
- CloseRichCallback(g_RichEditList[i]->hwnd);
+ for (auto &it : g_RichEditList.rev_iter())
+ CloseRichCallback(it->hwnd);
g_RichEditList.destroy();
- for (int i = g_RichEditOwnerList.getCount() - 1; i >= 0; i--)
- CloseRichOwnerCallback(g_RichEditOwnerList[i]->hwnd);
+ for (auto &it : g_RichEditOwnerList.rev_iter())
+ CloseRichOwnerCallback(it->hwnd);
g_RichEditOwnerList.destroy();
}
diff --git a/plugins/StartupSilence/src/main.cpp b/plugins/StartupSilence/src/main.cpp
index af56a5e6c9..4c525f867d 100644
--- a/plugins/StartupSilence/src/main.cpp
+++ b/plugins/StartupSilence/src/main.cpp
@@ -332,8 +332,8 @@ static int CreateTTButtons(WPARAM, LPARAM)
void RemoveTTButtons()
{
- for (int i=ttbButtons.getCount()-1; i >= 0; i--)
- CallService(MS_TTB_REMOVEBUTTON, (WPARAM)ttbButtons[i], 0);
+ for (auto &it : ttbButtons.rev_iter())
+ CallService(MS_TTB_REMOVEBUTTON, (WPARAM)it, 0);
ttbButtons.destroy();
}
diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp
index c3fe689df4..0f03ecf541 100644
--- a/plugins/TabSRMM/src/chat_main.cpp
+++ b/plugins/TabSRMM/src/chat_main.cpp
@@ -174,8 +174,7 @@ static void CheckUpdate()
db_enum_settings(0, CopyChatSetting, CHAT_OLDFONTMODULE, &szSettings);
DBVARIANT dbv;
- for (int i = szSettings.getCount() - 1; i >= 0; i--) {
- char *p = szSettings[i];
+ for (auto &p : szSettings.rev_iter()) {
db_get(0, CHAT_OLDFONTMODULE, p, &dbv);
db_set(0, CHATFONT_MODULE, p, &dbv);
db_free(&dbv);
diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp
index 3f642787b9..4b022070db 100644
--- a/plugins/TabSRMM/src/eventpopups.cpp
+++ b/plugins/TabSRMM/src/eventpopups.cpp
@@ -54,14 +54,13 @@ static PLUGIN_DATAT* PU_GetByContact(const MCONTACT hContact)
*/
static void PU_CleanUp()
{
- for (int i = arPopupList.getCount() - 1; i >= 0; i--) {
- PLUGIN_DATAT *p = arPopupList[i];
+ for (auto &p : arPopupList.rev_iter()) {
if (p->hContact != 0)
continue;
mir_free(p->eventData);
mir_free(p);
- arPopupList.remove(i);
+ arPopupList.remove(p);
}
}
diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp
index de6755c5d8..380daf02dd 100644
--- a/plugins/TopToolBar/src/toolbar.cpp
+++ b/plugins/TopToolBar/src/toolbar.cpp
@@ -550,9 +550,9 @@ int OnPluginUnload(WPARAM, LPARAM lParam)
bool bNeedUpdate = false;
mir_cslock lck(csButtonsHook);
- for (int i = Buttons.getCount() - 1; i >= 0; i--)
- if (Buttons[i]->hLangpack == lang) {
- TTBRemoveButton(Buttons[i]->id, 0);
+ for (auto &it : Buttons.rev_iter())
+ if (it->hLangpack == lang) {
+ TTBRemoveButton(it->id, 0);
bNeedUpdate = true;
}
diff --git a/plugins/UserInfoEx/src/mir_contactqueue.cpp b/plugins/UserInfoEx/src/mir_contactqueue.cpp
index 9a734ba968..752a9fbbc5 100644
--- a/plugins/UserInfoEx/src/mir_contactqueue.cpp
+++ b/plugins/UserInfoEx/src/mir_contactqueue.cpp
@@ -71,8 +71,8 @@ void CContactQueue::RemoveAll()
{
mir_cslock lck(_cs);
- for (int i = _queue.getCount() - 1; i >= 0; --i)
- mir_free(_queue[i]);
+ for (auto &it : _queue)
+ mir_free(it);
_queue.destroy();
}
@@ -83,10 +83,9 @@ void CContactQueue::RemoveAll(MCONTACT hContact)
{
mir_cslock lck(_cs);
- for (int i = _queue.getCount() - 1; i >= 0; --i) {
- CQueueItem *qi = _queue[i];
+ for (auto &qi : _queue.rev_iter()) {
if (qi->hContact == hContact) {
- _queue.remove(i);
+ _queue.remove(qi);
mir_free(qi);
}
}
@@ -99,13 +98,11 @@ void CContactQueue::RemoveAllConsiderParam(MCONTACT hContact, PVOID param)
{
mir_cslock lck(_cs);
- for (int i = _queue.getCount() - 1; i >= 0; --i) {
- CQueueItem *qi = _queue[i];
+ for (auto &qi : _queue.rev_iter())
if (qi->hContact == hContact && qi->param == param) {
- _queue.remove(i);
+ _queue.remove(qi);
mir_free(qi);
}
- }
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -125,8 +122,8 @@ BOOL CContactQueue::AddIfDontHave(int waitTime, MCONTACT hContact, PVOID param)
{
mir_cslock lck(_cs);
- for (int i = _queue.getCount() - 1; i >= 0; --i)
- if (_queue[i]->hContact == hContact)
+ for (auto &qi : _queue.rev_iter())
+ if (qi->hContact == hContact)
return FALSE;
return InternalAdd(waitTime, hContact, param);
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp
index e1aba4e28e..be99ebf054 100644
--- a/protocols/Discord/src/dispatch.cpp
+++ b/protocols/Discord/src/dispatch.cpp
@@ -194,13 +194,11 @@ void CDiscordProto::OnCommandGuildDeleted(const JSONNode &pRoot)
if (pGuild == nullptr)
return;
- for (int i = arUsers.getCount()-1; i >= 0; i--) {
- CDiscordUser &pUser = arUsers[i];
- if (pUser.guildId == pGuild->id) {
- Chat_Terminate(m_szModuleName, pUser.wszUsername, true);
- arUsers.remove(i);
+ for (auto &it : arUsers.rev_iter())
+ if (it->guildId == pGuild->id) {
+ Chat_Terminate(m_szModuleName, it->wszUsername, true);
+ arUsers.remove(it);
}
- }
Chat_Terminate(m_szModuleName, pRoot["name"].as_mstring(), true);
diff --git a/protocols/IcqOscarJ/src/cookies.cpp b/protocols/IcqOscarJ/src/cookies.cpp
index 51004e0915..de73d58e03 100644
--- a/protocols/IcqOscarJ/src/cookies.cpp
+++ b/protocols/IcqOscarJ/src/cookies.cpp
@@ -33,9 +33,9 @@ void CIcqProto::RemoveExpiredCookies()
{
time_t tNow = time(nullptr);
- for (int i = cookies.getCount() - 1; i >= 0; i--)
- if ((cookies[i].dwTime + COOKIE_TIMEOUT) < tNow)
- cookies.remove(i);
+ for (auto &it : cookies.rev_iter())
+ if (it->dwTime + COOKIE_TIMEOUT < tNow)
+ cookies.remove(it);
}
// Generate and allocate cookie
diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp
index 3b44e921c9..23c6fbe20b 100644
--- a/src/core/stdmsg/src/cmdlist.cpp
+++ b/src/core/stdmsg/src/cmdlist.cpp
@@ -32,13 +32,11 @@ static VOID CALLBACK MsgTimer(HWND, UINT, UINT_PTR, DWORD dwTime)
LIST<TMsgQueue> arTimedOut(1);
{
mir_cslock lck(csMsgQueue);
- for (int i = msgQueue.getCount() - 1; i >= 0; i--) {
- TMsgQueue *item = msgQueue[i];
- if (dwTime - item->ts > g_dat.msgTimeout) {
- arTimedOut.insert(item);
- msgQueue.remove(i);
+ for (auto &it : msgQueue.rev_iter())
+ if (dwTime - it->ts > g_dat.msgTimeout) {
+ arTimedOut.insert(it);
+ msgQueue.remove(it);
}
- }
}
for (auto &it : arTimedOut)
diff --git a/src/mir_app/src/FontService.cpp b/src/mir_app/src/FontService.cpp
index b30cfa7344..58e3caede1 100644
--- a/src/mir_app/src/FontService.cpp
+++ b/src/mir_app/src/FontService.cpp
@@ -326,9 +326,9 @@ static INT_PTR ReloadFonts(WPARAM, LPARAM)
MIR_APP_DLL(void) KillModuleFonts(int _hLang)
{
- for (int i = font_id_list.getCount() - 1; i >= 0; i--)
- if (font_id_list[i].hLangpack == _hLang)
- font_id_list.remove(i);
+ for (auto &it : font_id_list.rev_iter())
+ if (it->hLangpack == _hLang)
+ font_id_list.remove(it);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -401,9 +401,9 @@ static INT_PTR ReloadColours(WPARAM, LPARAM)
MIR_APP_DLL(void) KillModuleColours(int _hLang)
{
- for (int i = colour_id_list.getCount() - 1; i >= 0; i--)
- if (colour_id_list[i].hLangpack == _hLang)
- colour_id_list.remove(i);
+ for (auto &it : colour_id_list.rev_iter())
+ if (it->hLangpack == _hLang)
+ colour_id_list.remove(it);
}
//////////////////////////////////////////////////////////////////////////
@@ -484,9 +484,9 @@ MIR_APP_DLL(int) Effect_Get(const char *szGroup, const char *szName, FONTEFFECT
MIR_APP_DLL(void) KillModuleEffects(int _hLang)
{
- for (int i = effect_id_list.getCount() - 1; i >= 0; i--)
- if (effect_id_list[i].hLangpack == _hLang)
- effect_id_list.remove(i);
+ for (auto &it : effect_id_list.rev_iter())
+ if (it->hLangpack == _hLang)
+ effect_id_list.remove(it);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/MDatabaseCommon.cpp b/src/mir_app/src/MDatabaseCommon.cpp
index c909a57e77..dd3034a00e 100644
--- a/src/mir_app/src/MDatabaseCommon.cpp
+++ b/src/mir_app/src/MDatabaseCommon.cpp
@@ -75,9 +75,9 @@ BOOL MDatabaseCommon::DeleteModule(MCONTACT hContact, LPCSTR szModule)
LIST<char> vars(20);
EnumContactSettings(hContact, sttEnumVars, szModule, &vars);
- for (int i = vars.getCount() - 1; i >= 0; i--) {
- DeleteContactSetting(hContact, szModule, vars[i]);
- mir_free(vars[i]);
+ for (auto &it : vars.rev_iter()) {
+ DeleteContactSetting(hContact, szModule, it);
+ mir_free(it);
}
return 0;
}
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index 17a34ec221..bf97ad42b1 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -136,11 +136,10 @@ int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, bool removeCon
return TRUE;
}
- for (int i = g_arSessions.getCount() - 1; i >= 0; i--) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions.rev_iter()) {
if (si->iType != GCW_SERVER && !mir_strcmpi(si->pszModule, pszModule)) {
SM_FreeSession(si, removeContact);
- g_arSessions.remove(i);
+ g_arSessions.remove(si);
}
}
return TRUE;
diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp
index 975321c410..c2272920f8 100644
--- a/src/mir_app/src/clistsettings.cpp
+++ b/src/mir_app/src/clistsettings.cpp
@@ -147,11 +147,10 @@ int ContactDeleted(WPARAM hContact, LPARAM)
}
// remove events for a contact
- for (int i = g_cliEvents.getCount() - 1; i >= 0; i--) {
- CListEvent &e = g_cliEvents[i];
- if (e.hContact == hContact)
- cli.pfnRemoveEvent(hContact, e.hDbEvent);
- }
+ for (auto &it : g_cliEvents.rev_iter())
+ if (it->hContact == hContact)
+ cli.pfnRemoveEvent(hContact, it->hDbEvent);
+
return 0;
}
diff --git a/src/mir_app/src/hotkey_opts.cpp b/src/mir_app/src/hotkey_opts.cpp
index 28b852993d..b09a7e0944 100644
--- a/src/mir_app/src/hotkey_opts.cpp
+++ b/src/mir_app/src/hotkey_opts.cpp
@@ -755,13 +755,11 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
UnregisterHotkeys();
- for (int i = hotkeys.getCount()-1; i--;) {
- THotkeyItem *p = hotkeys[i];
+ for (auto &p : hotkeys.rev_iter())
if (p->OptNew && p->OptDeleted || p->rootHotkey && !p->OptHotkey || (lpnmhdr->code == PSN_APPLY) && p->OptDeleted || (lpnmhdr->code == PSN_RESET) && p->OptNew) {
+ hotkeys.remove(p);
FreeHotkey(p);
- hotkeys.remove(i);
}
- }
if (lpnmhdr->code == PSN_APPLY) {
LVITEM lvi = { 0 };
diff --git a/src/mir_app/src/hotkeys.cpp b/src/mir_app/src/hotkeys.cpp
index 6443955168..36016bdd59 100644
--- a/src/mir_app/src/hotkeys.cpp
+++ b/src/mir_app/src/hotkeys.cpp
@@ -220,10 +220,10 @@ MIR_APP_DLL(int) Hotkey_Unregister(const char *pszName)
if (g_hwndHkOptions)
SendMessage(g_hwndHkOptions, WM_HOTKEYUNREGISTERED, 0, 0);
- for (int i = hotkeys.getCount()-1; i >= 0; i--)
- if (hotkeys[i]->UnregisterHotkey) {
- FreeHotkey(hotkeys[i]);
- hotkeys.remove(i);
+ for (auto &it : hotkeys.rev_iter())
+ if (it->UnregisterHotkey) {
+ hotkeys.remove(it);
+ FreeHotkey(it);
}
return 0;
@@ -287,13 +287,11 @@ void RegisterHotkeys()
MIR_APP_DLL(void) KillModuleHotkeys(int _hLang)
{
- for (int i = hotkeys.getCount()-1; i >= 0; i--) {
- THotkeyItem *p = hotkeys[i];
- if (p->hLangpack == _hLang) {
- FreeHotkey(p);
- hotkeys.remove(i);
+ for (auto &it : hotkeys.rev_iter())
+ if (it->hLangpack == _hLang) {
+ hotkeys.remove(it);
+ FreeHotkey(it);
}
- }
}
void UnregisterHotkeys()
diff --git a/src/mir_app/src/icolib.cpp b/src/mir_app/src/icolib.cpp
index b3e212f3f3..27d49a1dc6 100644
--- a/src/mir_app/src/icolib.cpp
+++ b/src/mir_app/src/icolib.cpp
@@ -570,20 +570,15 @@ MIR_APP_DLL(int) IcoLib_Release(const char *szIconName, bool big)
/////////////////////////////////////////////////////////////////////////////////////////
// IcoLib_RemoveIcon
-__inline void IcoLib_RemoveIcon_Internal(int i)
-{
- IcolibItem *item = iconList[i];
- iconList.remove(i);
- delete item;
-}
-
MIR_APP_DLL(void) IcoLib_RemoveIcon(const char *pszIconName)
{
mir_cslock lck(csIconList);
int i = iconList.indexOf((IcolibItem*)&pszIconName);
- if (i != -1)
- IcoLib_RemoveIcon_Internal(i);
+ if (i != -1) {
+ iconList.remove(i);
+ delete iconList[i];
+ }
}
MIR_APP_DLL(void) IcoLib_RemoveIconByHandle(HANDLE hIcoLib)
@@ -591,8 +586,10 @@ MIR_APP_DLL(void) IcoLib_RemoveIconByHandle(HANDLE hIcoLib)
mir_cslock lck(csIconList);
int i = iconList.getIndex((IcolibItem*)hIcoLib);
- if (i != -1)
- IcoLib_RemoveIcon_Internal(i);
+ if (i != -1) {
+ iconList.remove(i);
+ delete iconList[i];
+ }
}
MIR_APP_DLL(void) KillModuleIcons(int _hLang)
@@ -601,11 +598,11 @@ MIR_APP_DLL(void) KillModuleIcons(int _hLang)
return;
mir_cslock lck(csIconList);
- for (int i = iconList.getCount() - 1; i >= 0; i--) {
- IcolibItem *item = iconList[i];
- if (item->hLangpack == _hLang)
- IcoLib_RemoveIcon_Internal(i);
- }
+ for (auto &it : iconList.rev_iter())
+ if (it->hLangpack == _hLang) {
+ iconList.remove(it);
+ delete it;
+ }
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -804,8 +801,9 @@ void UnloadIcoLibModule(void)
DestroyHookableEvent(hIconsChangedEvent);
DestroyHookableEvent(hIcons2ChangedEvent);
- while (iconList.getCount() > 0)
- IcoLib_RemoveIcon_Internal(0);
+ for (auto &p : iconList)
+ delete p;
+ iconList.destroy();
for (auto &p : iconSourceList)
delete p;
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp
index b8a3d4bba2..b9ea1e7080 100644
--- a/src/mir_app/src/newplugins.cpp
+++ b/src/mir_app/src/newplugins.cpp
@@ -653,11 +653,10 @@ static pluginEntry* getCListModule(wchar_t *exe)
int UnloadPlugin(wchar_t* buf, int bufLen)
{
- for (int i = pluginList.getCount() - 1; i >= 0; i--) {
- pluginEntry *p = pluginList[i];
- if (!mir_wstrcmpi(p->pluginname, buf)) {
- GetModuleFileName(p->bpi.hInst, buf, bufLen);
- Plugin_Uninit(p);
+ for (auto &it : pluginList.rev_iter()) {
+ if (!mir_wstrcmpi(it->pluginname, buf)) {
+ GetModuleFileName(it->bpi.hInst, buf, bufLen);
+ Plugin_Uninit(it);
return TRUE;
}
}
@@ -767,11 +766,9 @@ int LoadSslModule(void)
void UnloadNewPlugins(void)
{
// unload everything but the special db/clist plugins
- for (int i = pluginList.getCount() - 1; i >= 0; i--) {
- pluginEntry *p = pluginList[i];
- if (!(p->pclass & PCLASS_LAST) && (p->pclass & PCLASS_OK))
- Plugin_Uninit(p);
- }
+ for (auto &it : pluginList.rev_iter())
+ if (!(it->pclass & PCLASS_LAST) && (it->pclass & PCLASS_OK))
+ Plugin_Uninit(it);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -885,21 +882,17 @@ void UnloadNewPluginsModule(void)
UnloadPluginOptions();
// unload everything but the DB
- for (int i = pluginList.getCount() - 1; i >= 0; i--) {
- pluginEntry *p = pluginList[i];
- if (!(p->pclass & (PCLASS_DB | PCLASS_CRYPT)) && p != plugin_crshdmp)
- Plugin_Uninit(p);
- }
+ for (auto &it : pluginList.rev_iter())
+ if (!(it->pclass & (PCLASS_DB | PCLASS_CRYPT)) && it != plugin_crshdmp)
+ Plugin_Uninit(it);
if (plugin_crshdmp)
Plugin_Uninit(plugin_crshdmp);
UnloadDatabase();
- for (int k = pluginList.getCount() - 1; k >= 0; k--) {
- pluginEntry *p = pluginList[k];
- Plugin_Uninit(p);
- }
+ for (auto &it : pluginList.rev_iter())
+ Plugin_Uninit(it);
if (hPluginListHeap)
HeapDestroy(hPluginListHeap);
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp
index 3a701e1188..ad1896e29d 100644
--- a/src/mir_app/src/proto_accs.cpp
+++ b/src/mir_app/src/proto_accs.cpp
@@ -402,10 +402,9 @@ void UnloadAccountsModule()
{
if (!bModuleInitialized) return;
- for (int i = accounts.getCount() - 1; i >= 0; i--) {
- PROTOACCOUNT *pa = accounts[i];
- UnloadAccount(pa, false, false);
- accounts.remove(i);
+ for (auto &it : accounts.rev_iter()) {
+ accounts.remove(it);
+ UnloadAccount(it, false, false);
}
accounts.destroy();
diff --git a/src/mir_app/src/sounds.cpp b/src/mir_app/src/sounds.cpp
index 11d66ef688..27128138cf 100644
--- a/src/mir_app/src/sounds.cpp
+++ b/src/mir_app/src/sounds.cpp
@@ -28,22 +28,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct SoundItem
{
- char* name;
- wchar_t* pwszSection;
- wchar_t* pwszDescription;
- wchar_t* ptszTempFile;
- int hLangpack;
+ ptrA name;
+ ptrW pwszSection;
+ ptrW pwszDescription;
+ ptrW ptszTempFile;
+ int hLangpack;
__inline wchar_t* getSection() const { return TranslateW_LP(pwszSection, hLangpack); }
__inline wchar_t* getDescr() const { return TranslateW_LP(pwszDescription, hLangpack); }
-
- __inline void clear(void)
- {
- mir_free(name);
- mir_free(pwszSection);
- mir_free(pwszDescription);
- mir_free(ptszTempFile);
- }
};
static int CompareSounds(const SoundItem* p1, const SoundItem* p2)
@@ -57,13 +49,9 @@ static OBJLIST<SoundItem> arSounds(10, CompareSounds);
MIR_APP_DLL(void) KillModuleSounds(int _hLang)
{
- for (int i = arSounds.getCount() - 1; i >= 0; i--) {
- SoundItem &p = arSounds[i];
- if (p.hLangpack == _hLang) {
- p.clear();
- arSounds.remove(i);
- }
- }
+ for (auto &it : arSounds.rev_iter())
+ if (it->hLangpack == _hLang)
+ arSounds.remove(it);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -118,8 +106,7 @@ MIR_APP_DLL(int) Skin_PlaySound(const char *pszSoundName)
if (pszSoundName == nullptr)
return 1;
- SoundItem tmp = { (char*)pszSoundName };
- int idx = arSounds.getIndex(&tmp);
+ int idx = arSounds.getIndex((SoundItem*)&pszSoundName);
if (idx == -1)
return 1;
@@ -472,6 +459,5 @@ int LoadSkinSounds(void)
void UnloadSkinSounds(void)
{
- for (auto &p : arSounds)
- p->clear();
+ arSounds.destroy();
}
diff --git a/src/mir_app/src/srmm_statusicon.cpp b/src/mir_app/src/srmm_statusicon.cpp
index 97637bd3ef..c30d3d3ec0 100644
--- a/src/mir_app/src/srmm_statusicon.cpp
+++ b/src/mir_app/src/srmm_statusicon.cpp
@@ -163,19 +163,18 @@ MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int index)
{
static StatusIconData res;
- for (int i=arIcons.getCount()-1, nVis = 0; i >= 0; i--) {
- StatusIconMain &p = arIcons[i];
-
- StatusIconChild *pc = p.arChildren.find((StatusIconChild*)&hContact);
+ int nVis = 0;
+ for (auto &it : arIcons.rev_iter()) {
+ StatusIconChild *pc = it->arChildren.find((StatusIconChild*)&hContact);
if (pc) {
if (pc->flags & MBF_HIDDEN)
continue;
}
- else if (p.sid.flags & MBF_HIDDEN)
+ else if (it->sid.flags & MBF_HIDDEN)
continue;
if (nVis == index) {
- memcpy(&res, &p, sizeof(res));
+ memcpy(&res, it, sizeof(res));
if (pc) {
if (pc->hIcon) res.hIcon = pc->hIcon;
if (pc->hIconDisabled)
@@ -185,7 +184,7 @@ MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int index)
if (pc->tszTooltip) res.tszTooltip = pc->tszTooltip;
res.flags = pc->flags;
}
- res.tszTooltip = TranslateW_LP(res.tszTooltip, p.hLangpack);
+ res.tszTooltip = TranslateW_LP(res.tszTooltip, it->hLangpack);
return &res;
}
nVis++;
@@ -198,11 +197,9 @@ MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int index)
void KillModuleSrmmIcons(int _hLang)
{
- for (int i = arIcons.getCount()-1; i >= 0; i--) {
- StatusIconMain &p = arIcons[i];
- if (p.hLangpack == _hLang)
- arIcons.remove(i);
- }
+ for (auto &it : arIcons.rev_iter())
+ if (it->hLangpack == _hLang)
+ arIcons.remove(it);
}
int LoadSrmmModule()
diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp
index 8069a1c42c..d3b0d7c278 100644
--- a/src/mir_app/src/srmm_toolbar.cpp
+++ b/src/mir_app/src/srmm_toolbar.cpp
@@ -52,14 +52,6 @@ int dwSepCount = 0;
static mir_cs csToolBar;
static HANDLE hHookToolBarLoadedEvt, hHookButtonPressedEvt;
-static void wipeList(LIST<CustomButtonData> &list)
-{
- for (int i = list.getCount() - 1; i >= 0; i--) {
- delete list[i];
- list.remove(i);
- }
-}
-
static int sstSortButtons(const void *p1, const void *p2)
{
return SortButtons(*(CustomButtonData**)p1, *(CustomButtonData**)p2);
@@ -228,13 +220,11 @@ MIR_APP_DLL(int) Srmm_RemoveButton(BBButton *bbdi)
{
mir_cslock lck(csToolBar);
- for (int i = arButtonsList.getCount() - 1; i >= 0; i--) {
- CustomButtonData *cbd = arButtonsList[i];
+ for (auto &cbd : arButtonsList.rev_iter())
if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && cbd->m_dwButtonID == bbdi->dwButtonID) {
pFound = cbd;
- arButtonsList.remove(i);
+ arButtonsList.remove(cbd);
}
- }
}
if (pFound) {
@@ -432,14 +422,12 @@ MIR_APP_DLL(void) Srmm_RedrawToolbarIcons(HWND hwndDlg)
static void CB_ReInitCustomButtons()
{
- for (int i = arButtonsList.getCount() - 1; i >= 0; i--) {
- CustomButtonData *cbd = arButtonsList[i];
-
+ for (auto &cbd : arButtonsList.rev_iter()) {
if (cbd->m_opFlags & (BBSF_NTBSWAPED | BBSF_NTBDESTRUCT)) {
cbd->m_opFlags ^= BBSF_NTBSWAPED;
if (cbd->m_opFlags & BBSF_NTBDESTRUCT)
- arButtonsList.remove(i);
+ arButtonsList.remove(cbd);
}
}
qsort(arButtonsList.getArray(), arButtonsList.getCount(), sizeof(void*), sstSortButtons);
@@ -793,13 +781,11 @@ static int SrmmOptionsInit(WPARAM wParam, LPARAM)
void KillModuleToolbarIcons(int _hLang)
{
- for (int i = arButtonsList.getCount() - 1; i >= 0; i--) {
- CustomButtonData *cbd = arButtonsList[i];
+ for (auto &cbd : arButtonsList.rev_iter())
if (cbd->m_hLangpack == _hLang) {
- arButtonsList.remove(i);
+ arButtonsList.remove(cbd);
delete cbd;
}
- }
}
static INT_PTR BroadcastMessage(WPARAM, LPARAM lParam)
@@ -860,5 +846,7 @@ void UnloadSrmmToolbarModule()
{
DestroyHookableEvent(hHookButtonPressedEvt);
- wipeList(arButtonsList);
+ for (auto &it : arButtonsList)
+ delete it;
+ arButtonsList.destroy();
}
diff --git a/src/mir_app/src/usedIcons.cpp b/src/mir_app/src/usedIcons.cpp
index 093429144b..f0eb7645e5 100644
--- a/src/mir_app/src/usedIcons.cpp
+++ b/src/mir_app/src/usedIcons.cpp
@@ -84,11 +84,10 @@ void RemoveIcon(const char *icolibName)
void ResetIcons()
{
- for (int i = usedIcons.getCount()-1; i >= 0; i--) {
- Icon &p = usedIcons[i];
- if (p.refCount <= 0)
- usedIcons.remove(i);
+ for (auto &it : usedIcons.rev_iter()) {
+ if (it->refCount <= 0)
+ usedIcons.remove(it);
else
- p.hImage = INVALID_HANDLE_VALUE;
+ it->hImage = INVALID_HANDLE_VALUE;
}
}
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp
index c410084c65..b78c204aff 100644
--- a/src/mir_core/src/modules.cpp
+++ b/src/mir_core/src/modules.cpp
@@ -413,18 +413,18 @@ MIR_CORE_DLL(void) KillModuleEventHooks(HINSTANCE hInst)
{
mir_cslock lck(csHooks);
- for (int i = hooks.getCount() - 1; i >= 0; i--) {
- if (hooks[i]->subscriberCount == 0)
+ for (auto &it : hooks.rev_iter()) {
+ if (it->subscriberCount == 0)
continue;
- for (int j = hooks[i]->subscriberCount - 1; j >= 0; j--) {
- if (hooks[i]->subscriber[j].hOwner != hInst)
+ for (int j = it->subscriberCount - 1; j >= 0; j--) {
+ if (it->subscriber[j].hOwner != hInst)
continue;
char szModuleName[MAX_PATH];
- GetModuleFileNameA(hooks[i]->subscriber[j].hOwner, szModuleName, sizeof(szModuleName));
- UnhookEvent((HANDLE)((hooks[i]->id << 16) + j + 1));
- if (hooks[i]->subscriberCount == 0)
+ GetModuleFileNameA(it->subscriber[j].hOwner, szModuleName, sizeof(szModuleName));
+ UnhookEvent((HANDLE)((it->id << 16) + j + 1));
+ if (it->subscriberCount == 0)
break;
}
}
@@ -434,14 +434,14 @@ MIR_CORE_DLL(void) KillObjectEventHooks(void* pObject)
{
mir_cslock lck(csHooks);
- for (int i = hooks.getCount() - 1; i >= 0; i--) {
- if (hooks[i]->subscriberCount == 0)
+ for (auto &it : hooks.rev_iter()) {
+ if (it->subscriberCount == 0)
continue;
- for (int j = hooks[i]->subscriberCount - 1; j >= 0; j--) {
- if (hooks[i]->subscriber[j].object == pObject) {
- UnhookEvent((HANDLE)((hooks[i]->id << 16) + j + 1));
- if (hooks[i]->subscriberCount == 0)
+ for (int j = it->subscriberCount - 1; j >= 0; j--) {
+ if (it->subscriber[j].object == pObject) {
+ UnhookEvent((HANDLE)((it->id << 16) + j + 1));
+ if (it->subscriberCount == 0)
break;
}
}
@@ -452,11 +452,11 @@ static void DestroyHooks()
{
mir_cslock lck(csHooks);
- for (auto &p : hooks) {
- if (p->subscriberCount)
- mir_free(p->subscriber);
- DeleteCriticalSection(&p->csHook);
- mir_free(p);
+ for (auto &it : hooks) {
+ if (it->subscriberCount)
+ mir_free(it->subscriber);
+ DeleteCriticalSection(&it->csHook);
+ mir_free(it);
}
}
@@ -639,11 +639,11 @@ MIR_CORE_DLL(void) KillModuleServices(HINSTANCE hInst)
{
mir_cslock lck(csServices);
- for (int i = services.getCount() - 1; i >= 0; i--) {
- if (services[i]->hOwner == hInst) {
+ for (auto &it : services.rev_iter()) {
+ if (it->hOwner == hInst) {
char szModuleName[MAX_PATH];
- GetModuleFileNameA(services[i]->hOwner, szModuleName, sizeof(szModuleName));
- DestroyServiceFunction((HANDLE)services[i]->nameHash);
+ GetModuleFileNameA(it->hOwner, szModuleName, sizeof(szModuleName));
+ DestroyServiceFunction((HANDLE)it->nameHash);
}
}
}
@@ -652,9 +652,9 @@ MIR_CORE_DLL(void) KillObjectServices(void* pObject)
{
mir_cslock lck(csServices);
- for (int i = services.getCount() - 1; i >= 0; i--)
- if (services[i]->object == pObject)
- DestroyServiceFunction((HANDLE)services[i]->nameHash);
+ for (auto &it : services.rev_iter())
+ if (it->object == pObject)
+ DestroyServiceFunction((HANDLE)it->nameHash);
}
static void DestroyServices()
diff --git a/src/mir_core/src/subclass.cpp b/src/mir_core/src/subclass.cpp
index c60eba41ad..d64fc3b5fb 100644
--- a/src/mir_core/src/subclass.cpp
+++ b/src/mir_core/src/subclass.cpp
@@ -179,16 +179,15 @@ MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg
MIR_CORE_DLL(void) KillModuleSubclassing(HMODULE hInst)
{
- for (int i = arSubclass.getCount() - 1; i >= 0; i--) {
- MSubclassData *p = arSubclass[i];
- for (int j = 0; j < p->m_iHooks; j++) {
- if (GetInstByAddress(p->m_hooks[j]) == hInst) {
- removeHook(p, j);
+ for (auto &it : arSubclass.rev_iter()) {
+ for (int j = 0; j < it->m_iHooks; j++) {
+ if (GetInstByAddress(it->m_hooks[j]) == hInst) {
+ removeHook(it, j);
j--;
}
}
- if (p->m_iHooks == 0)
- finalizeSubclassing(p->m_hWnd, p);
+ if (it->m_iHooks == 0)
+ finalizeSubclassing(it->m_hWnd, it);
}
}
diff --git a/src/mir_core/src/threads.cpp b/src/mir_core/src/threads.cpp
index 120cdeff1e..87a03fc62f 100644
--- a/src/mir_core/src/threads.cpp
+++ b/src/mir_core/src/threads.cpp
@@ -228,16 +228,15 @@ MIR_CORE_DLL(void) KillObjectThreads(void* owner)
if (WaitForMultipleObjects(threadCount, threadPool, TRUE, 5000) == WAIT_TIMEOUT) {
// forcibly kill all remaining threads after 5 secs
mir_cslock lck(csThreads);
- for (int j = threads.getCount() - 1; j >= 0; j--) {
- THREAD_WAIT_ENTRY *p = threads[j];
- if (p->pObject == owner) {
+ for (auto &it : threads.rev_iter()) {
+ if (it->pObject == owner) {
char szModuleName[MAX_PATH];
- GetModuleFileNameA(p->hOwner, szModuleName, sizeof(szModuleName));
- Netlib_Logf(nullptr, "Killing object thread %s:%p", szModuleName, p->dwThreadId);
- TerminateThread(p->hThread, 9999);
- CloseHandle(p->hThread);
- threads.remove(j);
- mir_free(p);
+ GetModuleFileNameA(it->hOwner, szModuleName, sizeof(szModuleName));
+ Netlib_Logf(nullptr, "Killing object thread %s:%p", szModuleName, it->dwThreadId);
+ TerminateThread(it->hThread, 9999);
+ CloseHandle(it->hThread);
+ threads.remove(it);
+ mir_free(it);
}
}
}
diff --git a/src/mir_core/src/windowlist.cpp b/src/mir_core/src/windowlist.cpp
index a785472cbb..9fe88f5c33 100644
--- a/src/mir_core/src/windowlist.cpp
+++ b/src/mir_core/src/windowlist.cpp
@@ -89,8 +89,8 @@ MIR_CORE_DLL(int) WindowList_Broadcast(MWindowList hList, UINT message, WPARAM w
if (hList == nullptr)
return NULL;
- for (int i = hList->getCount()-1; i >= 0; i--)
- SendMessage((*hList)[i].hWnd, message, wParam, lParam);
+ for (auto &it : hList->rev_iter())
+ SendMessage(it->hWnd, message, wParam, lParam);
return 0;
}
@@ -99,7 +99,7 @@ MIR_CORE_DLL(int) WindowList_BroadcastAsync(MWindowList hList, UINT message, WPA
if (hList == nullptr)
return NULL;
- for (int i = hList->getCount()-1; i >= 0; i--)
- PostMessage((*hList)[i].hWnd, message, wParam, lParam);
+ for (auto &it : hList->rev_iter())
+ PostMessage(it->hWnd, message, wParam, lParam);
return 0;
}