[PATCH 4/4] riched20: Get rid of the ALLOC_N_OBJ macro
Michael Stefaniuc
mstefani at winehq.org
Sat Feb 3 16:59:48 CST 2018
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
I see opportunities for some heap_strdupX() in here but that's something
for later.
dlls/riched20/editor.c | 8 ++++----
dlls/riched20/editor.h | 2 --
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 53d0950bd4..c4425127e7 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2136,7 +2136,7 @@ static int ME_GetTextRange(ME_TextEditor *editor, WCHAR *strText,
return ME_GetTextW(editor, strText, INT_MAX, start, nLen, FALSE, FALSE);
} else {
int nChars;
- WCHAR *p = ALLOC_N_OBJ(WCHAR, nLen+1);
+ WCHAR *p = heap_alloc((nLen+1) * sizeof(*p));
if (!p) return 0;
nChars = ME_GetTextW(editor, p, nLen, start, nLen, FALSE, FALSE);
WideCharToMultiByte(CP_ACP, 0, p, nChars+1, (char *)strText,
@@ -3021,7 +3021,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
* or paragraph selection.
*/
ed->nCursors = 4;
- ed->pCursors = ALLOC_N_OBJ(ME_Cursor, ed->nCursors);
+ ed->pCursors = heap_alloc(ed->nCursors * sizeof(*ed->pCursors));
ME_SetCursorToStart(ed, &ed->pCursors[0]);
ed->pCursors[1] = ed->pCursors[0];
ed->pCursors[2] = ed->pCursors[0];
@@ -4295,7 +4295,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
int nChars = MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, NULL, 0);
WCHAR *tmp;
- if ((tmp = ALLOC_N_OBJ(WCHAR, nChars)) != NULL)
+ if ((tmp = heap_alloc(nChars * sizeof(*tmp))) != NULL)
MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, tmp, nChars);
r = ME_FindText(editor, wParam, &ft->chrg, tmp, NULL);
heap_free(tmp);
@@ -4313,7 +4313,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
int nChars = MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, NULL, 0);
WCHAR *tmp;
- if ((tmp = ALLOC_N_OBJ(WCHAR, nChars)) != NULL)
+ if ((tmp = heap_alloc(nChars * sizeof(*tmp))) != NULL)
MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, tmp, nChars);
r = ME_FindText(editor, wParam, &ex->chrg, tmp, &ex->chrgText);
heap_free(tmp);
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 6215068cdd..0db532640b 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -25,8 +25,6 @@ struct _RTF_Info;
extern HANDLE me_heap DECLSPEC_HIDDEN;
-#define ALLOC_N_OBJ(type, count) heap_alloc((count)*sizeof(type))
-
#define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \
&& (run)->style->fmt.dwEffects & CFE_HIDDEN)
--
2.14.3
More information about the wine-devel
mailing list