diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-15 21:05:06 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-15 21:05:06 +0300 |
commit | 59e6b15f513cc998ce13e9e49e2a6a3ace445ebb (patch) | |
tree | af52b73a17039ed1fbe398ba9f488c26a7071257 /src/mir_core | |
parent | bdaa5cf8b48515af2ac39f3f3245dd1183cbad52 (diff) |
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
Diffstat (limited to 'src/mir_core')
-rw-r--r-- | src/mir_core/src/modules.cpp | 4 | ||||
-rw-r--r-- | src/mir_core/src/threads.cpp | 2 | ||||
-rw-r--r-- | src/mir_core/src/windowlist.cpp | 2 |
3 files changed, 4 insertions, 4 deletions
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;
}
|