ole32: pFmt isn't exposed to the client, so simplify its allocation.

This commit is contained in:
Huw Davies 2009-03-17 14:25:09 +00:00 committed by Alexandre Julliard
parent 8beb83866f
commit d72181381e
1 changed files with 7 additions and 15 deletions

View File

@ -231,7 +231,6 @@ static ULONG WINAPI OLEClipbrd_IEnumFORMATETC_AddRef(LPENUMFORMATETC iface)
static ULONG WINAPI OLEClipbrd_IEnumFORMATETC_Release(LPENUMFORMATETC iface) static ULONG WINAPI OLEClipbrd_IEnumFORMATETC_Release(LPENUMFORMATETC iface)
{ {
IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface;
LPMALLOC pIMalloc;
ULONG ref; ULONG ref;
TRACE("(%p)->(count=%u)\n",This, This->ref); TRACE("(%p)->(count=%u)\n",This, This->ref);
@ -243,12 +242,7 @@ static ULONG WINAPI OLEClipbrd_IEnumFORMATETC_Release(LPENUMFORMATETC iface)
if (!ref) if (!ref)
{ {
TRACE("() - destroying IEnumFORMATETC(%p)\n",This); TRACE("() - destroying IEnumFORMATETC(%p)\n",This);
if (SUCCEEDED(CoGetMalloc(MEMCTX_TASK, &pIMalloc))) HeapFree(GetProcessHeap(), 0, This->pFmt);
{
IMalloc_Free(pIMalloc, This->pFmt);
IMalloc_Release(pIMalloc);
}
HeapFree(GetProcessHeap(),0,This); HeapFree(GetProcessHeap(),0,This);
} }
return ref; return ref;
@ -379,9 +373,8 @@ static LPENUMFORMATETC OLEClipbrd_IEnumFORMATETC_Construct(UINT cfmt, const FORM
{ {
IEnumFORMATETCImpl* ef; IEnumFORMATETCImpl* ef;
DWORD size=cfmt * sizeof(FORMATETC); DWORD size=cfmt * sizeof(FORMATETC);
LPMALLOC pIMalloc;
ef = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumFORMATETCImpl)); ef = HeapAlloc(GetProcessHeap(), 0, sizeof(IEnumFORMATETCImpl));
if (!ef) if (!ef)
return NULL; return NULL;
@ -391,15 +384,14 @@ static LPENUMFORMATETC OLEClipbrd_IEnumFORMATETC_Construct(UINT cfmt, const FORM
ef->posFmt = 0; ef->posFmt = 0;
ef->countFmt = cfmt; ef->countFmt = cfmt;
if (FAILED(CoGetMalloc(MEMCTX_TASK, &pIMalloc))) { ef->pFmt = HeapAlloc(GetProcessHeap(), 0, size);
if (ef->pFmt)
memcpy(ef->pFmt, afmt, size);
else
{
HeapFree(GetProcessHeap(), 0, ef); HeapFree(GetProcessHeap(), 0, ef);
return NULL; return NULL;
} }
ef->pFmt = IMalloc_Alloc(pIMalloc, size);
IMalloc_Release(pIMalloc);
if (ef->pFmt)
memcpy(ef->pFmt, afmt, size);
TRACE("(%p)->()\n",ef); TRACE("(%p)->()\n",ef);
return (LPENUMFORMATETC)ef; return (LPENUMFORMATETC)ef;