Commit 25f1b058 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ole32: Change the enum formatetc constructor to return HRESULT.

parent 1cc023c5
...@@ -303,7 +303,7 @@ static HRESULT WINAPI OLEClipbrd_IEnumFORMATETC_Reset(LPENUMFORMATETC iface) ...@@ -303,7 +303,7 @@ static HRESULT WINAPI OLEClipbrd_IEnumFORMATETC_Reset(LPENUMFORMATETC iface)
return S_OK; return S_OK;
} }
static LPENUMFORMATETC OLEClipbrd_IEnumFORMATETC_Construct(UINT cfmt, const FORMATETC afmt[]); static HRESULT enum_fmtetc_construct(UINT cfmt, const FORMATETC afmt[], IEnumFORMATETC **obj);
/************************************************************************ /************************************************************************
* OLEClipbrd_IEnumFORMATETC_Clone (IEnumFORMATETC) * OLEClipbrd_IEnumFORMATETC_Clone (IEnumFORMATETC)
...@@ -321,8 +321,8 @@ static HRESULT WINAPI OLEClipbrd_IEnumFORMATETC_Clone ...@@ -321,8 +321,8 @@ static HRESULT WINAPI OLEClipbrd_IEnumFORMATETC_Clone
if ( !ppenum ) if ( !ppenum )
return E_INVALIDARG; return E_INVALIDARG;
*ppenum = OLEClipbrd_IEnumFORMATETC_Construct(This->countFmt, hr = enum_fmtetc_construct(This->countFmt, This->pFmt, ppenum);
This->pFmt); if (FAILED(hr)) return hr;
/* FIXME: This is wrong! */ /* FIXME: This is wrong! */
if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenum))) if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenum)))
...@@ -343,21 +343,20 @@ static const IEnumFORMATETCVtbl efvt = ...@@ -343,21 +343,20 @@ static const IEnumFORMATETCVtbl efvt =
}; };
/************************************************************************ /************************************************************************
* OLEClipbrd_IEnumFORMATETC_Construct * enum_fmtetc_construct
* *
* Creates an IEnumFORMATETC enumerator from an array of FORMATETC * Creates an IEnumFORMATETC enumerator from an array of FORMATETC
* Structures. * Structures.
* NOTE: this does not AddRef the interface. * NOTE: this does not AddRef the interface.
*/ */
static HRESULT enum_fmtetc_construct(UINT cfmt, const FORMATETC afmt[], IEnumFORMATETC **obj)
static LPENUMFORMATETC OLEClipbrd_IEnumFORMATETC_Construct(UINT cfmt, const FORMATETC afmt[])
{ {
enum_fmtetc* ef; enum_fmtetc* ef;
DWORD size=cfmt * sizeof(FORMATETC); DWORD size=cfmt * sizeof(FORMATETC);
*obj = NULL;
ef = HeapAlloc(GetProcessHeap(), 0, sizeof(*ef)); ef = HeapAlloc(GetProcessHeap(), 0, sizeof(*ef));
if (!ef) if (!ef) return E_OUTOFMEMORY;
return NULL;
ef->ref = 0; ef->ref = 0;
ef->lpVtbl = &efvt; ef->lpVtbl = &efvt;
...@@ -370,11 +369,12 @@ static LPENUMFORMATETC OLEClipbrd_IEnumFORMATETC_Construct(UINT cfmt, const FORM ...@@ -370,11 +369,12 @@ static LPENUMFORMATETC OLEClipbrd_IEnumFORMATETC_Construct(UINT cfmt, const FORM
else else
{ {
HeapFree(GetProcessHeap(), 0, ef); HeapFree(GetProcessHeap(), 0, ef);
return NULL; return E_OUTOFMEMORY;
} }
TRACE("(%p)->()\n",ef); TRACE("(%p)->()\n",ef);
return (LPENUMFORMATETC)ef; *obj = (IEnumFORMATETC *)ef;
return S_OK;
} }
/*********************************************************************** /***********************************************************************
...@@ -1042,14 +1042,11 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc( ...@@ -1042,14 +1042,11 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc(
afmt[i].tymed = TYMED_HGLOBAL; afmt[i].tymed = TYMED_HGLOBAL;
} }
/* hr = enum_fmtetc_construct( cfmt, afmt, ppenumFormatEtc );
* Create an EnumFORMATETC enumerator and return an if (FAILED(hr))
* EnumFORMATETC after bumping up its ref count HANDLE_ERROR( hr );
*/
*ppenumFormatEtc = OLEClipbrd_IEnumFORMATETC_Construct( cfmt, afmt );
if (!(*ppenumFormatEtc))
HANDLE_ERROR( E_OUTOFMEMORY );
/* FIXME: This is wrong! */
if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenumFormatEtc))) if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenumFormatEtc)))
HANDLE_ERROR( hr ); HANDLE_ERROR( hr );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment