From 59e6b15f513cc998ce13e9e49e2a6a3ace445ebb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 15 Mar 2018 21:05:06 +0300 Subject: LIST<> iterators: - new method LIST::removeItem added to save a pointer to removed record; - code cleaning related to the fact that LIST::remove() shall be the last operation inside an iterator, because otherwise the reference to it will point to a record next to deleted one; - a few remaining cycles converted to iterators --- src/mir_core/src/modules.cpp | 4 ++-- src/mir_core/src/threads.cpp | 2 +- src/mir_core/src/windowlist.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mir_core') diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp index b78c204aff..a57f0d19ea 100644 --- a/src/mir_core/src/modules.cpp +++ b/src/mir_core/src/modules.cpp @@ -526,8 +526,8 @@ MIR_CORE_DLL(int) DestroyServiceFunction(HANDLE hService) { mir_cslock lck(csServices); - int idx; - if ((idx = services.getIndex((TService*)&hService)) != -1) { + int idx = services.getIndex((TService*)&hService); + if (idx != -1) { mir_free(services[idx]); services.remove(idx); } diff --git a/src/mir_core/src/threads.cpp b/src/mir_core/src/threads.cpp index 5be6150a91..a71d366585 100644 --- a/src/mir_core/src/threads.cpp +++ b/src/mir_core/src/threads.cpp @@ -236,8 +236,8 @@ MIR_CORE_DLL(void) KillObjectThreads(void* owner) Netlib_Logf(nullptr, "Killing object thread %s:%p", szModuleName, it->dwThreadId); TerminateThread(it->hThread, 9999); CloseHandle(it->hThread); - threads.remove(T.indexOf(&it)); mir_free(it); + threads.remove(T.indexOf(&it)); } } } diff --git a/src/mir_core/src/windowlist.cpp b/src/mir_core/src/windowlist.cpp index 9fe88f5c33..f997352fe9 100644 --- a/src/mir_core/src/windowlist.cpp +++ b/src/mir_core/src/windowlist.cpp @@ -68,7 +68,7 @@ MIR_CORE_DLL(int) WindowList_Remove(MWindowList hList, HWND hwnd) for (auto &it : *hList) if (it->hWnd == hwnd) { - hList->remove(it); + hList->removeItem(&it); return 0; } -- cgit v1.2.3