Zebediah Figura : compobj: Store the IMalloc pointer as a SEGPTR.

Alexandre Julliard julliard at winehq.org
Wed Jan 22 14:52:58 CST 2020


Module: wine
Branch: master
Commit: 464b74bf5b4717c08a75664c8b6d785607045337
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=464b74bf5b4717c08a75664c8b6d785607045337

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Jan 15 00:24:29 2020 -0600

compobj: Store the IMalloc pointer as a SEGPTR.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/compobj.dll16/compobj.c          | 47 ++++++++++++++---------------------
 dlls/compobj.dll16/compobj.dll16.spec |  2 +-
 2 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/dlls/compobj.dll16/compobj.c b/dlls/compobj.dll16/compobj.c
index dc5e315b4c..701f0012ff 100644
--- a/dlls/compobj.dll16/compobj.c
+++ b/dlls/compobj.dll16/compobj.c
@@ -65,7 +65,7 @@ typedef struct
 typedef struct
 {
     SEGPTR lpVtbl;
-} IMalloc16, *LPMALLOC16;
+} IMalloc16;
 
 static SEGPTR call_IMalloc_Alloc(SEGPTR iface, DWORD size)
 {
@@ -82,7 +82,7 @@ static SEGPTR call_IMalloc_Alloc(SEGPTR iface, DWORD size)
 static HTASK16 hETask = 0;
 static WORD Table_ETask[62];
 
-static LPMALLOC16 currentMalloc16=NULL;
+static SEGPTR compobj_malloc;
 
 /* --- IMalloc16 implementation */
 
@@ -211,8 +211,7 @@ LPVOID CDECL IMalloc16_fnHeapMinimize(IMalloc16* iface) {
 /******************************************************************************
  * IMalloc16_Constructor [VTABLE]
  */
-static LPMALLOC16
-IMalloc16_Constructor(void)
+static SEGPTR IMalloc16_Constructor(void)
 {
     static IMalloc16Vtbl vt16;
     static SEGPTR msegvt16;
@@ -237,7 +236,7 @@ IMalloc16_Constructor(void)
     }
     This->IMalloc16_iface.lpVtbl = msegvt16;
     This->ref = 1;
-    return (LPMALLOC16)MapLS( This );
+    return MapLS(This);
 }
 
 
@@ -250,32 +249,24 @@ DWORD WINAPI CoBuildVersion16(void)
 }
 
 /***********************************************************************
- *           CoGetMalloc    [COMPOBJ.4]
- *
- * Retrieve the current win16 IMalloc interface.
- *
- * RETURNS
- *	The current win16 IMalloc
+ *           CoGetMalloc   [COMPOBJ.4]
  */
-HRESULT WINAPI CoGetMalloc16(
-	DWORD dwMemContext,	/* [in] unknown */
-	LPMALLOC16 * lpMalloc	/* [out] current win16 malloc interface */
-) {
-    if(!currentMalloc16)
-	currentMalloc16 = IMalloc16_Constructor();
-    *lpMalloc = currentMalloc16;
+HRESULT WINAPI CoGetMalloc16(MEMCTX context, SEGPTR *malloc)
+{
+    if (!compobj_malloc)
+        compobj_malloc = IMalloc16_Constructor();
+    *malloc = compobj_malloc;
     return S_OK;
 }
 
 /***********************************************************************
  *           CoCreateStandardMalloc [COMPOBJ.71]
  */
-HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext,
-					  LPMALLOC16 *lpMalloc)
+HRESULT WINAPI CoCreateStandardMalloc16(MEMCTX context, SEGPTR *malloc)
 {
     /* FIXME: docu says we shouldn't return the same allocator as in
      * CoGetMalloc16 */
-    *lpMalloc = IMalloc16_Constructor();
+    *malloc = IMalloc16_Constructor();
     return S_OK;
 }
 
@@ -292,19 +283,17 @@ SEGPTR WINAPI CoMemAlloc(DWORD size, MEMCTX context, DWORD unknown)
     if (unknown)
         FIXME("Ignoring unknown parameter %#x.\n", unknown);
 
-    if (CoGetMalloc16(0, (IMalloc16 **)&malloc))
+    if (CoGetMalloc16(0, &malloc))
         return 0;
     return call_IMalloc_Alloc(malloc, size);
 }
 
-/******************************************************************************
- *		CoInitialize	[COMPOBJ.2]
- * Set the win16 IMalloc used for memory management
+/***********************************************************************
+ *           CoInitialize   [COMPOBJ.2]
  */
-HRESULT WINAPI CoInitialize16(
-	LPVOID lpReserved	/* [in] pointer to win16 malloc interface */
-) {
-    currentMalloc16 = (LPMALLOC16)lpReserved;
+HRESULT WINAPI CoInitialize16(SEGPTR malloc)
+{
+    compobj_malloc = malloc;
     return S_OK;
 }
 
diff --git a/dlls/compobj.dll16/compobj.dll16.spec b/dlls/compobj.dll16/compobj.dll16.spec
index 2ef011fcb0..8c0456504d 100644
--- a/dlls/compobj.dll16/compobj.dll16.spec
+++ b/dlls/compobj.dll16/compobj.dll16.spec
@@ -1,5 +1,5 @@
 1 pascal CoBuildVersion() CoBuildVersion16
-2 pascal CoInitialize(long) CoInitialize16
+2 pascal CoInitialize(segptr) CoInitialize16
 3 pascal CoUninitialize() CoUninitialize16
 4 pascal CoGetMalloc(long ptr) CoGetMalloc16
 5 pascal CoRegisterClassObject(ptr ptr long long ptr) CoRegisterClassObject16




More information about the wine-cvs mailing list