ole32: Add a helper to copy FORMATETC structures.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2017-05-18 11:07:02 +01:00 committed by Alexandre Julliard
parent f6ced24999
commit 11db49190b
2 changed files with 20 additions and 8 deletions

View File

@ -334,4 +334,16 @@ static inline BOOL heap_free(void *mem)
return HeapFree(GetProcessHeap(), 0, mem);
}
static inline HRESULT copy_formatetc(FORMATETC *dst, const FORMATETC *src)
{
*dst = *src;
if (src->ptd)
{
dst->ptd = CoTaskMemAlloc( src->ptd->tdSize );
if (!dst->ptd) return E_OUTOFMEMORY;
memcpy( dst->ptd, src->ptd, src->ptd->tdSize );
}
return S_OK;
}
#endif /* __WINE_OLE_COMPOBJ_H */

View File

@ -56,14 +56,14 @@ static void release_statdata(STATDATA *data)
static HRESULT copy_statdata(STATDATA *dst, const STATDATA *src)
{
*dst = *src;
if(src->formatetc.ptd)
{
dst->formatetc.ptd = CoTaskMemAlloc(src->formatetc.ptd->tdSize);
if(!dst->formatetc.ptd) return E_OUTOFMEMORY;
memcpy(dst->formatetc.ptd, src->formatetc.ptd, src->formatetc.ptd->tdSize);
}
HRESULT hr;
hr = copy_formatetc( &dst->formatetc, &src->formatetc );
if (FAILED(hr)) return hr;
dst->advf = src->advf;
dst->pAdvSink = src->pAdvSink;
if (dst->pAdvSink) IAdviseSink_AddRef( dst->pAdvSink );
dst->dwConnection = src->dwConnection;
return S_OK;
}