summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-09 19:32:32 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-09 19:32:39 +0300
commitdf6b0c988eb26339d4c7e4a1d0fe3b9717703c28 (patch)
tree5b4960edd6c9186e1fbc14f83f7f08a6a842f0a7 /src/mir_core
parent303dd9297732fc943ed3e20ab37587f0c009dfe5 (diff)
more loop-related code cleaning
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/threads.cpp30
-rw-r--r--src/mir_core/src/windowlist.cpp8
2 files changed, 17 insertions, 21 deletions
diff --git a/src/mir_core/src/threads.cpp b/src/mir_core/src/threads.cpp
index 9d293c2e5e..120cdeff1e 100644
--- a/src/mir_core/src/threads.cpp
+++ b/src/mir_core/src/threads.cpp
@@ -218,11 +218,9 @@ MIR_CORE_DLL(void) KillObjectThreads(void* owner)
{
mir_cslock lck(csThreads);
- for (int j = threads.getCount(); j--;) {
- THREAD_WAIT_ENTRY *p = threads[j];
- if (p->pObject == owner)
- threadPool[threadCount++] = p->hThread;
- }
+ for (auto &it : threads)
+ if (it->pObject == owner)
+ threadPool[threadCount++] = it->hThread;
}
// is there anything to kill?
@@ -250,20 +248,18 @@ MIR_CORE_DLL(void) KillObjectThreads(void* owner)
static void CALLBACK KillAllThreads(HWND, UINT, UINT_PTR, DWORD)
{
- {
- mir_cslock lck(csThreads);
- for (auto &p : threads) {
- char szModuleName[MAX_PATH];
- GetModuleFileNameA(p->hOwner, szModuleName, sizeof(szModuleName));
- Netlib_Logf(nullptr, "Killing thread %s:%p (%p)", szModuleName, p->dwThreadId, p->pEntryPoint);
- TerminateThread(p->hThread, 9999);
- CloseHandle(p->hThread);
- mir_free(p);
- }
-
- threads.destroy();
+ mir_cslock lck(csThreads);
+ for (auto &p : threads) {
+ char szModuleName[MAX_PATH];
+ GetModuleFileNameA(p->hOwner, szModuleName, sizeof(szModuleName));
+ Netlib_Logf(nullptr, "Killing thread %s:%p (%p)", szModuleName, p->dwThreadId, p->pEntryPoint);
+ TerminateThread(p->hThread, 9999);
+ CloseHandle(p->hThread);
+ mir_free(p);
}
+ threads.destroy();
+
SetEvent(hThreadQueueEmpty);
}
diff --git a/src/mir_core/src/windowlist.cpp b/src/mir_core/src/windowlist.cpp
index 13b339b8f6..a785472cbb 100644
--- a/src/mir_core/src/windowlist.cpp
+++ b/src/mir_core/src/windowlist.cpp
@@ -66,12 +66,12 @@ MIR_CORE_DLL(int) WindowList_Remove(MWindowList hList, HWND hwnd)
{
if (hList == nullptr) return 1;
- for (int i = 0; i < hList->getCount(); i++) {
- if ((*hList)[i].hWnd == hwnd) {
- hList->remove(i);
+ for (auto &it : *hList)
+ if (it->hWnd == hwnd) {
+ hList->remove(it);
return 0;
}
- }
+
return 1;
}