ole32: Add a constructor helper.
Based on a patch by Dmitry Timoshkov. Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
fe3421ba2c
commit
f946aa5b7f
|
@ -106,6 +106,22 @@ static inline HGLOBALStreamImpl *impl_from_IStream(IStream *iface)
|
||||||
return CONTAINING_RECORD(iface, HGLOBALStreamImpl, 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(
|
static HRESULT WINAPI HGLOBALStreamImpl_QueryInterface(
|
||||||
IStream* iface,
|
IStream* iface,
|
||||||
REFIID riid, /* [in] */
|
REFIID riid, /* [in] */
|
||||||
|
@ -615,12 +631,9 @@ HRESULT WINAPI CreateStreamOnHGlobal(
|
||||||
if (!ppstm)
|
if (!ppstm)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
This = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALStreamImpl));
|
This = hglobalstream_construct();
|
||||||
if (!This) return E_OUTOFMEMORY;
|
if (!This) return E_OUTOFMEMORY;
|
||||||
|
|
||||||
This->IStream_iface.lpVtbl = &HGLOBALStreamImplVtbl;
|
|
||||||
This->ref = 1;
|
|
||||||
|
|
||||||
This->handle = handle_create(hGlobal, fDeleteOnRelease);
|
This->handle = handle_create(hGlobal, fDeleteOnRelease);
|
||||||
if (!This->handle)
|
if (!This->handle)
|
||||||
{
|
{
|
||||||
|
@ -628,10 +641,6 @@ HRESULT WINAPI CreateStreamOnHGlobal(
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start at the beginning */
|
|
||||||
This->currentPosition.u.HighPart = 0;
|
|
||||||
This->currentPosition.u.LowPart = 0;
|
|
||||||
|
|
||||||
*ppstm = &This->IStream_iface;
|
*ppstm = &This->IStream_iface;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
Loading…
Reference in New Issue