https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dfd6d7f32a8073e2746d90...
commit dfd6d7f32a8073e2746d9005c303059e943a81df Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Tue Dec 19 18:34:08 2023 +0900 Commit: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com CommitDate: Tue Dec 19 18:34:08 2023 +0900
[MSCTFIME] Add TLS::PeekTLS and use it
Refactoring. CORE-19360 --- dll/ime/msctfime/msctfime.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index 79472cf2b88..8d1d17f364a 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -344,8 +344,17 @@ public: return InternalAllocateTLS(); }
+ /** + * @implemented + */ + static TLS* PeekTLS() + { + return (TLS*)::TlsGetValue(TLS::s_dwTlsIndex); + } + static TLS* InternalAllocateTLS(); static BOOL InternalDestroyTLS(); + };
DWORD TLS::s_dwTlsIndex = (DWORD)-1; @@ -355,7 +364,7 @@ DWORD TLS::s_dwTlsIndex = (DWORD)-1; */ TLS* TLS::InternalAllocateTLS() { - TLS *pTLS = (TLS *)::TlsGetValue(TLS::s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (pTLS) return pTLS;
@@ -382,10 +391,7 @@ TLS* TLS::InternalAllocateTLS() */ BOOL TLS::InternalDestroyTLS() { - if (s_dwTlsIndex == (DWORD)-1) - return FALSE; - - TLS *pTLS = (TLS *)::TlsGetValue(s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (!pTLS) return FALSE;
@@ -460,7 +466,7 @@ STDMETHODIMP_(ULONG) CicBridge::Release() */ CicBridge::~CicBridge() { - TLS *pTLS = (TLS *)TlsGetValue(TLS::s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (!pTLS || !pTLS->m_pThreadMgr) return;
@@ -718,7 +724,7 @@ ImeDestroy( { TRACE("(%u)\n", uReserved);
- TLS *pTLS = (TLS *)::TlsGetValue(TLS::s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (pTLS) return FALSE;
@@ -1009,7 +1015,7 @@ CtfImeDestroyThreadMgr(VOID) { TRACE("()\n");
- TLS *pTLS = (TLS *)::TlsGetValue(TLS::s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (!pTLS) return E_OUTOFMEMORY;
@@ -1051,7 +1057,7 @@ CtfImeDestroyInputContext( { TRACE("(%p)\n", hIMC);
- TLS *pTLS = (TLS*)::TlsGetValue(TLS::s_dwTlsIndex); + TLS *pTLS = TLS::PeekTLS(); if (!pTLS || !pTLS->m_pBridge) return E_OUTOFMEMORY;