Huw Davies : ole32: Add a constructor helper.
Alexandre Julliard
julliard at winehq.org
Tue Aug 11 16:26:50 CDT 2020
Module: wine
Branch: master
Commit: f946aa5b7f185faaff163dd9ceddd0e97fbf5070
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f946aa5b7f185faaff163dd9ceddd0e97fbf5070
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Aug 11 12:49:51 2020 +0100
ole32: Add a constructor helper.
Based on a patch by Dmitry Timoshkov.
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ole32/hglobalstream.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c
index 8fd1e03913..e715cd8950 100644
--- a/dlls/ole32/hglobalstream.c
+++ b/dlls/ole32/hglobalstream.c
@@ -106,6 +106,22 @@ static inline HGLOBALStreamImpl *impl_from_IStream(IStream *iface)
return CONTAINING_RECORD(iface, HGLOBALStreamImpl, IStream_iface);
}
+static const IStreamVtbl HGLOBALStreamImplVtbl;
+
+static HGLOBALStreamImpl *hglobalstream_construct(void)
+{
+ HGLOBALStreamImpl *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
+
+ if (This)
+ {
+ This->IStream_iface.lpVtbl = &HGLOBALStreamImplVtbl;
+ This->ref = 1;
+ This->handle = NULL;
+ This->currentPosition.QuadPart = 0;
+ }
+ return This;
+}
+
static HRESULT WINAPI HGLOBALStreamImpl_QueryInterface(
IStream* iface,
REFIID riid, /* [in] */
@@ -615,12 +631,9 @@ HRESULT WINAPI CreateStreamOnHGlobal(
if (!ppstm)
return E_INVALIDARG;
- This = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALStreamImpl));
+ This = hglobalstream_construct();
if (!This) return E_OUTOFMEMORY;
- This->IStream_iface.lpVtbl = &HGLOBALStreamImplVtbl;
- This->ref = 1;
-
This->handle = handle_create(hGlobal, fDeleteOnRelease);
if (!This->handle)
{
@@ -628,10 +641,6 @@ HRESULT WINAPI CreateStreamOnHGlobal(
return E_OUTOFMEMORY;
}
- /* start at the beginning */
- This->currentPosition.u.HighPart = 0;
- This->currentPosition.u.LowPart = 0;
-
*ppstm = &This->IStream_iface;
return S_OK;
More information about the wine-cvs
mailing list