[PATCH 2/4] riched20: Get rid of the FREE_OBJ() macro

Michael Stefaniuc mstefani at winehq.org
Sat Feb 3 16:59:46 CST 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
New heap_realloc(NULL, ...) functionality comes in handy.



 dlls/riched20/editor.c  | 13 ++++++-------
 dlls/riched20/editor.h  |  1 -
 dlls/riched20/list.c    |  2 +-
 dlls/riched20/richole.c |  2 +-
 dlls/riched20/style.c   |  2 +-
 dlls/riched20/writer.c  |  7 +++----
 6 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index daafe80055..da7d62b095 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2147,7 +2147,7 @@ static int ME_GetTextRange(ME_TextEditor *editor, WCHAR *strText,
       nChars = ME_GetTextW(editor, p, nLen, start, nLen, FALSE, FALSE);
       WideCharToMultiByte(CP_ACP, 0, p, nChars+1, (char *)strText,
                           nLen+1, NULL, NULL);
-      FREE_OBJ(p);
+      heap_free(p);
       return nChars;
     }
 }
@@ -3160,10 +3160,9 @@ void ME_DestroyEditor(ME_TextEditor *editor)
   }
   OleUninitialize();
 
-  FREE_OBJ(editor->pBuffer);
-  FREE_OBJ(editor->pCursors);
-
-  FREE_OBJ(editor);
+  heap_free(editor->pBuffer);
+  heap_free(editor->pCursors);
+  heap_free(editor);
 }
 
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
@@ -4305,7 +4304,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
       if ((tmp = ALLOC_N_OBJ(WCHAR, nChars)) != NULL)
         MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, tmp, nChars);
       r = ME_FindText(editor, wParam, &ft->chrg, tmp, NULL);
-      FREE_OBJ( tmp );
+      heap_free(tmp);
     }else{
       FINDTEXTW *ft = (FINDTEXTW *)lParam;
       r = ME_FindText(editor, wParam, &ft->chrg, ft->lpstrText, NULL);
@@ -4323,7 +4322,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
       if ((tmp = ALLOC_N_OBJ(WCHAR, nChars)) != NULL)
         MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, tmp, nChars);
       r = ME_FindText(editor, wParam, &ex->chrg, tmp, &ex->chrgText);
-      FREE_OBJ( tmp );
+      heap_free(tmp);
     }else{
       FINDTEXTEXW *ex = (FINDTEXTEXW *)lParam;
       r = ME_FindText(editor, wParam, &ex->chrg, ex->lpstrText, &ex->chrgText);
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 7d4a8ef979..55e259afb2 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -27,7 +27,6 @@ extern HANDLE me_heap DECLSPEC_HIDDEN;
 
 #define ALLOC_OBJ(type) heap_alloc(sizeof(type))
 #define ALLOC_N_OBJ(type, count) heap_alloc((count)*sizeof(type))
-#define FREE_OBJ(ptr) heap_free(ptr)
 
 #define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \
                              && (run)->style->fmt.dwEffects & CFE_HIDDEN)
diff --git a/dlls/riched20/list.c b/dlls/riched20/list.c
index d321446684..7cb9927712 100644
--- a/dlls/riched20/list.c
+++ b/dlls/riched20/list.c
@@ -174,7 +174,7 @@ void ME_DestroyDisplayItem(ME_DisplayItem *item)
     heap_free( item->member.run.clusters );
     ME_ReleaseStyle(item->member.run.style);
   }
-  FREE_OBJ(item);
+  heap_free(item);
 }
 
 ME_DisplayItem *ME_MakeDI(ME_DIType type)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 120bcf8190..30331572e8 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -5383,7 +5383,7 @@ void ME_DeleteReObject(REOBJECT* reo)
     if (reo->poleobj)   IOleObject_Release(reo->poleobj);
     if (reo->pstg)      IStorage_Release(reo->pstg);
     if (reo->polesite)  IOleClientSite_Release(reo->polesite);
-    FREE_OBJ(reo);
+    heap_free(reo);
 }
 
 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
diff --git a/dlls/riched20/style.c b/dlls/riched20/style.c
index 4f08b3b133..546258027c 100644
--- a/dlls/riched20/style.c
+++ b/dlls/riched20/style.c
@@ -425,7 +425,7 @@ void ME_DestroyStyle(ME_Style *s)
     s->font_cache = NULL;
   }
   ScriptFreeCache( &s->script_cache );
-  FREE_OBJ(s);
+  heap_free(s);
 }
 
 void ME_AddRefStyle(ME_Style *s)
diff --git a/dlls/riched20/writer.c b/dlls/riched20/writer.c
index 5494afef50..de0bb8d72f 100644
--- a/dlls/riched20/writer.c
+++ b/dlls/riched20/writer.c
@@ -101,7 +101,7 @@ ME_StreamOutFree(ME_OutStream *pStream)
   LONG written = pStream->written;
   TRACE("total length = %u\n", written);
 
-  FREE_OBJ(pStream);
+  heap_free(pStream);
   return written;
 }
 
@@ -1148,8 +1148,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
         nSize = WideCharToMultiByte(nCodePage, 0, get_text( &cursor.pRun->member.run, cursor.nOffset ),
                                     nLen, NULL, 0, NULL, NULL);
         if (nSize > nBufLen) {
-          FREE_OBJ(buffer);
-          buffer = ALLOC_N_OBJ(char, nSize);
+          buffer = heap_realloc(buffer, nSize);
           nBufLen = nSize;
         }
         WideCharToMultiByte(nCodePage, 0, get_text( &cursor.pRun->member.run, cursor.nOffset ),
@@ -1163,7 +1162,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
     cursor.pRun = ME_FindItemFwd(cursor.pRun, diRun);
   }
 
-  FREE_OBJ(buffer);
+  heap_free(buffer);
   return success;
 }
 
-- 
2.14.3




More information about the wine-devel mailing list