https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b48e77e15bce680cc819c…
commit b48e77e15bce680cc819cb45a32e17ae107b8a52
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Jan 3 16:45:23 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Jan 3 16:45:23 2024 +0900
[CTFMON][MSCTFIME][SDK] Define new(cicNoThrow) and use it (#6286)
Use new(cicNoThrow) instead of plain operator new.
JIRA issue: CORE-19360
- Define CicNoThrow structure and
cicNoThrow macro in <cicero/cicbase.h>.
- Use new(cicNoThrow) instead of
plain operator new.
---
base/applications/ctfmon/ctfmon.cpp | 2 +-
dll/ime/msctfime/msctfime.cpp | 20 ++++++++++----------
sdk/include/reactos/cicero/cicbase.h | 23 ++++++++++++++++++-----
3 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/base/applications/ctfmon/ctfmon.cpp b/base/applications/ctfmon/ctfmon.cpp
index 5ea37a4eb20..6c255f18b2e 100644
--- a/base/applications/ctfmon/ctfmon.cpp
+++ b/base/applications/ctfmon/ctfmon.cpp
@@ -224,7 +224,7 @@ InitApp(
CRegWatcher::Init();
// Create Tipbar loader window
- g_pLoaderWnd = new CLoaderWnd();
+ g_pLoaderWnd = new(cicNoThrow) CLoaderWnd();
if (!g_pLoaderWnd || !g_pLoaderWnd->Init())
return FALSE;
diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp
index 319c7de72b6..30b0191a34d 100644
--- a/dll/ime/msctfime/msctfime.cpp
+++ b/dll/ime/msctfime/msctfime.cpp
@@ -1598,7 +1598,7 @@ CFunctionProvider::GetFunction(
if (IsEqualGUID(guid, GUID_NULL) &&
IsEqualIID(riid, IID_IAImmFnDocFeed))
{
- *func = new CFnDocFeed();
+ *func = new(cicNoThrow) CFnDocFeed();
if (*func)
return S_OK;
}
@@ -2147,7 +2147,7 @@ CicProfile::InitProfileInstance(_Inout_ TLS *pTLS)
if (!m_pActiveLanguageProfileNotifySink)
{
CActiveLanguageProfileNotifySink *pSink =
- new CActiveLanguageProfileNotifySink(
+ new(cicNoThrow) CActiveLanguageProfileNotifySink(
CicProfile::ActiveLanguageProfileNotifySinkCallback, this);
if (!pSink)
{
@@ -2326,7 +2326,7 @@ CicBridge::CreateInputContext(
CicInputContext *pCicIC = imeContext.get().m_pCicIC;
if (!pCicIC)
{
- pCicIC = new CicInputContext(m_cliendId, &m_LibThread, hIMC);
+ pCicIC = new(cicNoThrow) CicInputContext(m_cliendId, &m_LibThread, hIMC);
if (!pCicIC)
{
imeContext.unlock();
@@ -2531,7 +2531,7 @@ CicBridge::ActivateIMMX(
return hr;
}
- CFunctionProvider *pProvider = new CFunctionProvider(m_cliendId);
+ CFunctionProvider *pProvider = new(cicNoThrow) CFunctionProvider(m_cliendId);
if (!pProvider)
{
hr = E_FAIL;
@@ -2645,7 +2645,7 @@ CicBridge::InitIMMX(_Inout_ TLS *pTLS)
if (!m_pThreadMgrEventSink)
{
m_pThreadMgrEventSink =
- new CThreadMgrEventSink(CThreadMgrEventSink::DIMCallback, NULL, NULL);
+ new(cicNoThrow) CThreadMgrEventSink(CThreadMgrEventSink::DIMCallback, NULL,
NULL);
if (!m_pThreadMgrEventSink)
{
UnInitIMMX(pTLS);
@@ -2658,7 +2658,7 @@ CicBridge::InitIMMX(_Inout_ TLS *pTLS)
if (!pTLS->m_pProfile)
{
- pTLS->m_pProfile = new CicProfile();
+ pTLS->m_pProfile = new(cicNoThrow) CicProfile();
if (!pTLS->m_pProfile)
return E_OUTOFMEMORY;
@@ -3297,7 +3297,7 @@ CtfImeCreateThreadMgr(VOID)
if (!pTLS->m_pBridge)
{
- pTLS->m_pBridge = new CicBridge();
+ pTLS->m_pBridge = new(cicNoThrow) CicBridge();
if (!pTLS->m_pBridge)
return E_OUTOFMEMORY;
}
@@ -3337,7 +3337,7 @@ CtfImeDestroyThreadMgr(VOID)
if (pTLS->m_pBridge)
{
- pTLS->m_pBridge = new CicBridge();
+ pTLS->m_pBridge = new(cicNoThrow) CicBridge();
if (!pTLS->m_pBridge)
return E_OUTOFMEMORY;
}
@@ -3604,7 +3604,7 @@ UI::~UI()
*/
HRESULT UI::_Create()
{
- m_pComp = new UIComposition();
+ m_pComp = new(cicNoThrow) UIComposition();
if (!m_pComp)
return E_OUTOFMEMORY;
@@ -3630,7 +3630,7 @@ void UI::OnCreate(HWND hWnd)
UI *pUI = (UI*)GetWindowLongPtrW(hWnd, UIGWLP_UI);
if (pUI)
return;
- pUI = new UI(hWnd);
+ pUI = new(cicNoThrow) UI(hWnd);
if (pUI)
pUI->_Create();
}
diff --git a/sdk/include/reactos/cicero/cicbase.h b/sdk/include/reactos/cicero/cicbase.h
index 14958780ba3..d1c76a09957 100644
--- a/sdk/include/reactos/cicero/cicbase.h
+++ b/sdk/include/reactos/cicero/cicbase.h
@@ -34,17 +34,30 @@ static inline void cicMemFree(LPVOID ptr)
LocalFree(ptr);
}
-inline void* __cdecl operator new(size_t size) noexcept
+struct CicNoThrow { };
+#define cicNoThrow CicNoThrow{}
+
+inline void* operator new(size_t size, const CicNoThrow&) noexcept
{
return cicMemAllocClear(size);
}
-
-inline void __cdecl operator delete(void* ptr) noexcept
+inline void* operator new[](size_t size, const CicNoThrow&) noexcept
+{
+ return cicMemAllocClear(size);
+}
+inline void operator delete(void* ptr) noexcept
{
cicMemFree(ptr);
}
-
-inline void __cdecl operator delete(void* ptr, size_t size) noexcept
+inline void operator delete[](void* ptr) noexcept
+{
+ cicMemFree(ptr);
+}
+inline void operator delete(void* ptr, size_t size) noexcept
+{
+ cicMemFree(ptr);
+}
+inline void operator delete[](void* ptr, size_t size) noexcept
{
cicMemFree(ptr);
}