https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5b522667a66bc8c9313e2…
commit 5b522667a66bc8c9313e206af4316df02c8fe716
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sun Sep 19 01:52:05 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Sep 19 01:52:05 2021 +0900
[IMM32] Define Imm32HeapFree macro and use it (#3962)
- Define Imm32HeapFree macro in precomp.h and use it.
- Omit some NULL checks (for HeapFree).
CORE-11700
---
dll/win32/imm32/ime.c | 30 ++++++++++----------------
dll/win32/imm32/imm.c | 14 ++++++------
dll/win32/imm32/keymsg.c | 10 ++++-----
dll/win32/imm32/nt3.c | 2 +-
dll/win32/imm32/precomp.h | 3 +++
dll/win32/imm32/regword.c | 54 ++++++++++++++++-------------------------------
dll/win32/imm32/utils.c | 4 ++--
7 files changed, 45 insertions(+), 72 deletions(-)
diff --git a/dll/win32/imm32/ime.c b/dll/win32/imm32/ime.c
index 80a2c50f33c..75f538c5c91 100644
--- a/dll/win32/imm32/ime.c
+++ b/dll/win32/imm32/ime.c
@@ -221,7 +221,7 @@ PIMEDPI APIENTRY Ime32LoadImeDpi(HKL hKL, BOOL bLock)
if (!Imm32LoadImeInfo(&ImeInfoEx, pImeDpiNew))
{
- HeapFree(g_hImm32Heap, 0, pImeDpiNew);
+ Imm32HeapFree(pImeDpiNew);
return FALSE;
}
@@ -236,7 +236,7 @@ PIMEDPI APIENTRY Ime32LoadImeDpi(HKL hKL, BOOL bLock)
RtlLeaveCriticalSection(&g_csImeDpi);
Imm32FreeImeDpi(pImeDpiNew, FALSE);
- HeapFree(g_hImm32Heap, 0, pImeDpiNew);
+ Imm32HeapFree(pImeDpiNew);
return pImeDpiFound;
}
else
@@ -477,7 +477,7 @@ VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
}
Imm32FreeImeDpi(pImeDpi, TRUE);
- HeapFree(g_hImm32Heap, 0, pImeDpi);
+ Imm32HeapFree(pImeDpi);
RtlLeaveCriticalSection(&g_csImeDpi);
}
@@ -1228,10 +1228,8 @@ ImmGetConversionListA(HKL hKL, HIMC hIMC, LPCSTR pSrc,
LPCANDIDATELIST lpDst,
ret = CandidateListWideToAnsi(pCL, lpDst, dwBufLen, CP_ACP);
Quit:
- if (pszSrcW)
- HeapFree(g_hImm32Heap, 0, pszSrcW);
- if (pCL)
- HeapFree(g_hImm32Heap, 0, pCL);
+ Imm32HeapFree(pszSrcW);
+ Imm32HeapFree(pCL);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
@@ -1285,10 +1283,8 @@ ImmGetConversionListW(HKL hKL, HIMC hIMC, LPCWSTR pSrc,
LPCANDIDATELIST lpDst,
ret = CandidateListAnsiToWide(pCL, lpDst, dwBufLen, CP_ACP);
Quit:
- if (pszSrcA)
- HeapFree(g_hImm32Heap, 0, pszSrcA);
- if (pCL)
- HeapFree(g_hImm32Heap, 0, pCL);
+ Imm32HeapFree(pszSrcA);
+ Imm32HeapFree(pCL);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
@@ -1429,10 +1425,8 @@ DoIt:
SendMessageW(hWnd, WM_IME_SYSTEM, 0x1A, 0);
Quit:
- if (RegWordW.lpReading)
- HeapFree(g_hImm32Heap, 0, RegWordW.lpReading);
- if (RegWordW.lpWord)
- HeapFree(g_hImm32Heap, 0, RegWordW.lpWord);
+ Imm32HeapFree(RegWordW.lpReading);
+ Imm32HeapFree(RegWordW.lpWord);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
@@ -1488,10 +1482,8 @@ DoIt:
SendMessageW(hWnd, WM_IME_SYSTEM, 0x1A, 0);
Quit:
- if (RegWordA.lpReading)
- HeapFree(g_hImm32Heap, 0, RegWordA.lpReading);
- if (RegWordA.lpWord)
- HeapFree(g_hImm32Heap, 0, RegWordA.lpWord);
+ Imm32HeapFree(RegWordA.lpReading);
+ Imm32HeapFree(RegWordA.lpWord);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 6092b354d74..0351cdae680 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -321,7 +321,7 @@ HIMC WINAPI ImmCreateContext(void)
hIMC = NtUserCreateInputContext(pClientImc);
if (hIMC == NULL)
{
- HeapFree(g_hImm32Heap, 0, pClientImc);
+ Imm32HeapFree(pClientImc);
return NULL;
}
@@ -464,7 +464,7 @@ PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
if (!NtUserUpdateInputContext(hImc, 0, pClientImc))
{
- HeapFree(g_hImm32Heap, 0, pClientImc);
+ Imm32HeapFree(pClientImc);
return NULL;
}
@@ -499,7 +499,7 @@ VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
LocalFree(hImc);
RtlDeleteCriticalSection(&pClientImc->cs);
- HeapFree(g_hImm32Heap, 0, pClientImc);
+ Imm32HeapFree(pClientImc);
}
static HIMC APIENTRY Imm32GetContextEx(HWND hWnd, DWORD dwContextFlags)
@@ -867,10 +867,8 @@ HKL WINAPI ImmInstallIMEA(LPCSTR lpszIMEFileName, LPCSTR
lpszLayoutText)
hKL = ImmInstallIMEW(pszFileNameW, pszLayoutTextW);
Quit:
- if (pszFileNameW)
- HeapFree(g_hImm32Heap, 0, pszFileNameW);
- if (pszLayoutTextW)
- HeapFree(g_hImm32Heap, 0, pszLayoutTextW);
+ Imm32HeapFree(pszFileNameW);
+ Imm32HeapFree(pszLayoutTextW);
return hKL;
}
@@ -1183,7 +1181,7 @@ BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn,
LPARAM lPara
break;
}
- HeapFree(g_hImm32Heap, 0, phList);
+ Imm32HeapFree(phList);
return ret;
}
diff --git a/dll/win32/imm32/keymsg.c b/dll/win32/imm32/keymsg.c
index 6c5ad757db6..69a26aed9be 100644
--- a/dll/win32/imm32/keymsg.c
+++ b/dll/win32/imm32/keymsg.c
@@ -497,8 +497,7 @@ BOOL WINAPI ImmGenerateMessage(HIMC hIMC)
}
Quit:
- if (pTrans)
- HeapFree(g_hImm32Heap, 0, pTrans);
+ Imm32HeapFree(pTrans);
if (hMsgBuf)
ImmUnlockIMCC(hMsgBuf);
pIC->dwNumMsgBuf = 0; /* done */
@@ -557,8 +556,8 @@ Imm32PostMessages(HWND hwnd, HIMC hIMC, DWORD dwCount, LPTRANSMSG
lpTransMsg)
}
#ifdef IMM_NT3_SUPPORT
- if (pNewTransMsg && pNewTransMsg != lpTransMsg)
- HeapFree(g_hImm32Heap, 0, pNewTransMsg);
+ if (pNewTransMsg != lpTransMsg)
+ Imm32HeapFree(pNewTransMsg);
#endif
}
@@ -678,8 +677,7 @@ BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lKeyD
}
Quit:
- if (pList)
- HeapFree(g_hImm32Heap, 0, pList);
+ Imm32HeapFree(pList);
ImmUnlockImeDpi(pImeDpi);
ImmUnlockIMC(hIMC);
ImmReleaseContext(hwnd, hIMC);
diff --git a/dll/win32/imm32/nt3.c b/dll/win32/imm32/nt3.c
index 14171de8df2..e1e8b263311 100644
--- a/dll/win32/imm32/nt3.c
+++ b/dll/win32/imm32/nt3.c
@@ -166,7 +166,7 @@ DoDefault:
}
}
- HeapFree(g_hImm32Heap, 0, pTempList);
+ Imm32HeapFree(pTempList);
return ret;
}
diff --git a/dll/win32/imm32/precomp.h b/dll/win32/imm32/precomp.h
index b96a9afa695..ecd05ca85f0 100644
--- a/dll/win32/imm32/precomp.h
+++ b/dll/win32/imm32/precomp.h
@@ -72,7 +72,10 @@ BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR
pszFileNam
VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW);
VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA);
PWND FASTCALL ValidateHwndNoErr(HWND hwnd);
+
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes);
+#define Imm32HeapFree(lpData) HeapFree(g_hImm32Heap, 0, (lpData))
+
LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA);
LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW);
PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL);
diff --git a/dll/win32/imm32/regword.c b/dll/win32/imm32/regword.c
index ceac66e8e38..8d9fa43fa3e 100644
--- a/dll/win32/imm32/regword.c
+++ b/dll/win32/imm32/regword.c
@@ -51,10 +51,8 @@ Imm32EnumWordProcA2W(LPCSTR pszReadingA, DWORD dwStyle, LPCSTR
pszRegisterA, LPV
lpEnumData->ret = ret;
Quit:
- if (pszReadingW)
- HeapFree(g_hImm32Heap, 0, pszReadingW);
- if (pszRegisterW)
- HeapFree(g_hImm32Heap, 0, pszRegisterW);
+ Imm32HeapFree(pszReadingW);
+ Imm32HeapFree(pszRegisterW);
return ret;
}
@@ -83,10 +81,8 @@ Imm32EnumWordProcW2A(LPCWSTR pszReadingW, DWORD dwStyle, LPCWSTR
pszRegisterW, L
lpEnumData->ret = ret;
Quit:
- if (pszReadingA)
- HeapFree(g_hImm32Heap, 0, pszReadingA);
- if (pszRegisterA)
- HeapFree(g_hImm32Heap, 0, pszRegisterA);
+ Imm32HeapFree(pszReadingA);
+ Imm32HeapFree(pszRegisterA);
return ret;
}
@@ -140,10 +136,8 @@ ImmEnumRegisterWordA(HKL hKL, REGISTERWORDENUMPROCA lpfnEnumProc,
ret = EnumDataW2A.ret;
Quit:
- if (pszReadingW)
- HeapFree(g_hImm32Heap, 0, pszReadingW);
- if (pszRegisterW)
- HeapFree(g_hImm32Heap, 0, pszRegisterW);
+ Imm32HeapFree(pszReadingW);
+ Imm32HeapFree(pszRegisterW);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
@@ -198,10 +192,8 @@ ImmEnumRegisterWordW(HKL hKL, REGISTERWORDENUMPROCW lpfnEnumProc,
ret = EnumDataA2W.ret;
Quit:
- if (pszReadingA)
- HeapFree(g_hImm32Heap, 0, pszReadingA);
- if (pszRegisterA)
- HeapFree(g_hImm32Heap, 0, pszRegisterA);
+ Imm32HeapFree(pszReadingA);
+ Imm32HeapFree(pszRegisterA);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
@@ -259,8 +251,7 @@ UINT WINAPI ImmGetRegisterWordStyleA(HKL hKL, UINT nItem, LPSTYLEBUFA
lpStyleBuf
}
Quit:
- if (pNewStylesW)
- HeapFree(g_hImm32Heap, 0, pNewStylesW);
+ Imm32HeapFree(pNewStylesW);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
@@ -317,8 +308,7 @@ UINT WINAPI ImmGetRegisterWordStyleW(HKL hKL, UINT nItem, LPSTYLEBUFW
lpStyleBuf
}
Quit:
- if (pNewStylesA)
- HeapFree(g_hImm32Heap, 0, pNewStylesA);
+ Imm32HeapFree(pNewStylesA);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
@@ -364,10 +354,8 @@ ImmRegisterWordA(HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR
lpszRegister
ret = pImeDpi->ImeRegisterWord(pszReadingW, dwStyle, pszRegisterW);
Quit:
- if (pszReadingW)
- HeapFree(g_hImm32Heap, 0, pszReadingW);
- if (pszRegisterW)
- HeapFree(g_hImm32Heap, 0, pszRegisterW);
+ Imm32HeapFree(pszReadingW);
+ Imm32HeapFree(pszRegisterW);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
@@ -413,10 +401,8 @@ ImmRegisterWordW(HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR
lpszRegist
ret = pImeDpi->ImeRegisterWord(pszReadingA, dwStyle, pszRegisterA);
Quit:
- if (pszReadingA)
- HeapFree(g_hImm32Heap, 0, pszReadingA);
- if (pszRegisterA)
- HeapFree(g_hImm32Heap, 0, pszRegisterA);
+ Imm32HeapFree(pszReadingA);
+ Imm32HeapFree(pszRegisterA);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
@@ -462,10 +448,8 @@ ImmUnregisterWordA(HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR
lpszUnregi
ret = pImeDpi->ImeUnregisterWord(pszReadingW, dwStyle, pszUnregisterW);
Quit:
- if (pszReadingW)
- HeapFree(g_hImm32Heap, 0, pszReadingW);
- if (pszUnregisterW)
- HeapFree(g_hImm32Heap, 0, pszUnregisterW);
+ Imm32HeapFree(pszReadingW);
+ Imm32HeapFree(pszUnregisterW);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
@@ -511,10 +495,8 @@ ImmUnregisterWordW(HKL hKL, LPCWSTR lpszReading, DWORD dwStyle,
LPCWSTR lpszUnre
ret = pImeDpi->ImeUnregisterWord(pszReadingA, dwStyle, pszUnregisterA);
Quit:
- if (pszReadingA)
- HeapFree(g_hImm32Heap, 0, pszReadingA);
- if (pszUnregisterA)
- HeapFree(g_hImm32Heap, 0, pszUnregisterA);
+ Imm32HeapFree(pszReadingA);
+ Imm32HeapFree(pszUnregisterA);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
diff --git a/dll/win32/imm32/utils.c b/dll/win32/imm32/utils.c
index c6c277efba3..2289ea895e0 100644
--- a/dll/win32/imm32/utils.c
+++ b/dll/win32/imm32/utils.c
@@ -162,7 +162,7 @@ DWORD APIENTRY Imm32AllocAndBuildHimcList(DWORD dwThreadId, HIMC
**pphList)
Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
while (Status == STATUS_BUFFER_TOO_SMALL)
{
- HeapFree(g_hImm32Heap, 0, phNewList);
+ Imm32HeapFree(phNewList);
if (cRetry++ >= MAX_RETRY)
return 0;
@@ -175,7 +175,7 @@ DWORD APIENTRY Imm32AllocAndBuildHimcList(DWORD dwThreadId, HIMC
**pphList)
if (NT_ERROR(Status) || !dwCount)
{
- HeapFree(g_hImm32Heap, 0, phNewList);
+ Imm32HeapFree(phNewList);
return 0;
}