quartz: Use proper alloc/free functions for COM objects.

This commit is contained in:
Chris Robinson 2007-03-08 03:03:06 -08:00 committed by Alexandre Julliard
parent 5edc7fd5ef
commit 045270605c
8 changed files with 30 additions and 25 deletions

View File

@ -411,7 +411,7 @@ static ULONG WINAPI DSoundRender_Release(IBaseFilter * iface)
IPin_Release(This->ppPins[0]);
HeapFree(GetProcessHeap(), 0, This->ppPins);
CoTaskMemFree(This->ppPins);
This->lpVtbl = NULL;
This->IBasicAudio_vtbl = NULL;

View File

@ -72,7 +72,8 @@ static int EventsQueue_Init(EventsQueue* omr)
omr->msg_tosave = 0;
omr->msg_event = CreateEventW(NULL, TRUE, FALSE, NULL);
omr->ring_buffer_size = EVENTS_RING_BUFFER_INCREMENT;
omr->messages = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,omr->ring_buffer_size * sizeof(Event));
omr->messages = CoTaskMemAlloc(omr->ring_buffer_size * sizeof(Event));
ZeroMemory(omr->messages, omr->ring_buffer_size * sizeof(Event));
InitializeCriticalSection(&omr->msg_crst);
return TRUE;
@ -81,7 +82,7 @@ static int EventsQueue_Init(EventsQueue* omr)
static int EventsQueue_Destroy(EventsQueue* omr)
{
CloseHandle(omr->msg_event);
HeapFree(GetProcessHeap(),0,omr->messages);
CoTaskMemFree(omr->messages);
DeleteCriticalSection(&omr->msg_crst);
return TRUE;
}
@ -268,9 +269,9 @@ static ULONG Filtergraph_Release(IFilterGraphImpl *This) {
CloseHandle(This->hEventCompletion);
EventsQueue_Destroy(&This->evqueue);
DeleteCriticalSection(&This->cs);
HeapFree(GetProcessHeap(), 0, This->ppFiltersInGraph);
HeapFree(GetProcessHeap(), 0, This->pFilterNames);
HeapFree(GetProcessHeap(), 0, This);
CoTaskMemFree(This->ppFiltersInGraph);
CoTaskMemFree(This->pFilterNames);
CoTaskMemFree(This);
}
return ref;
}
@ -4487,7 +4488,7 @@ HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
if( pUnkOuter )
return CLASS_E_NOAGGREGATION;
fimpl = HeapAlloc(GetProcessHeap(), 0, sizeof(*fimpl));
fimpl = CoTaskMemAlloc(sizeof(*fimpl));
fimpl->IGraphBuilder_vtbl = &IGraphBuilder_VTable;
fimpl->IMediaControl_vtbl = &IMediaControl_VTable;
fimpl->IMediaSeeking_vtbl = &IMediaSeeking_VTable;

View File

@ -105,7 +105,7 @@ static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface)
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
HeapFree(GetProcessHeap(), 0, This);
CoTaskMemFree(This);
return ref;
}
@ -185,7 +185,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
return CLASS_E_CLASSNOTAVAILABLE;
}
factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
factory = CoTaskMemAlloc(sizeof(*factory));
if (factory == NULL) return E_OUTOFMEMORY;
factory->ITF_IClassFactory.lpVtbl = &DSCF_Vtbl;

View File

@ -154,7 +154,7 @@ static ULONG WINAPI BaseMemAllocator_Release(IMemAllocator * iface)
CloseHandle(This->hSemWaiting);
if (This->bCommitted)
This->fnFree(iface);
HeapFree(GetProcessHeap(), 0, This->pProps);
CoTaskMemFree(This->pProps);
CoTaskMemFree(This);
return 0;
}
@ -179,7 +179,7 @@ static HRESULT WINAPI BaseMemAllocator_SetProperties(IMemAllocator * iface, ALLO
else
{
if (!This->pProps)
This->pProps = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->pProps));
This->pProps = CoTaskMemAlloc(sizeof(*This->pProps));
if (!This->pProps)
hr = E_OUTOFMEMORY;

View File

@ -192,7 +192,7 @@ static ULONG WINAPI Parser_Release(IBaseFilter * iface)
for (i = 0; i < This->cStreams + 1; i++)
IPin_Release(This->ppPins[i]);
HeapFree(GetProcessHeap(), 0, This->ppPins);
CoTaskMemFree(This->ppPins);
This->lpVtbl = NULL;
TRACE("Destroying parser\n");
@ -486,7 +486,7 @@ HRESULT Parser_AddPin(ParserImpl * This, PIN_INFO * piOutput, ALLOCATOR_PROPERTI
ppOldPins = This->ppPins;
This->ppPins = HeapAlloc(GetProcessHeap(), 0, (This->cStreams + 2) * sizeof(IPin *));
This->ppPins = CoTaskMemAlloc((This->cStreams + 2) * sizeof(IPin *));
memcpy(This->ppPins, ppOldPins, (This->cStreams + 1) * sizeof(IPin *));
hr = Parser_OutputPin_Construct(piOutput, props, NULL, Parser_OutputPin_QueryAccept, amt, fSamplesPerSec, &This->csFilter, This->ppPins + This->cStreams + 1);
@ -497,11 +497,11 @@ HRESULT Parser_AddPin(ParserImpl * This, PIN_INFO * piOutput, ALLOCATOR_PROPERTI
((Parser_OutputPin *)(This->ppPins[This->cStreams + 1]))->dwLength = dwLength;
((Parser_OutputPin *)(This->ppPins[This->cStreams + 1]))->pin.pin.pUserData = (LPVOID)This->ppPins[This->cStreams + 1];
This->cStreams++;
HeapFree(GetProcessHeap(), 0, ppOldPins);
CoTaskMemFree(ppOldPins);
}
else
{
HeapFree(GetProcessHeap(), 0, This->ppPins);
CoTaskMemFree(This->ppPins);
This->ppPins = ppOldPins;
ERR("Failed with error %x\n", hr);
}
@ -517,7 +517,7 @@ static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
IPin ** ppOldPins = This->ppPins;
/* reduce the pin array down to 1 (just our input pin) */
This->ppPins = HeapAlloc(GetProcessHeap(), 0, sizeof(IPin *) * 1);
This->ppPins = CoTaskMemAlloc(sizeof(IPin *) * 1);
memcpy(This->ppPins, ppOldPins, sizeof(IPin *) * 1);
for (i = 0; i < This->cStreams; i++)
@ -527,7 +527,7 @@ static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
}
This->cStreams = 0;
HeapFree(GetProcessHeap(), 0, ppOldPins);
CoTaskMemFree(ppOldPins);
return S_OK;
}

View File

@ -117,7 +117,7 @@ static DWORD WINAPI SystemClockAdviseThread(LPVOID lpParam) {
SetEvent((HANDLE) it->hEvent);
/** ... and Release it */
QUARTZ_RemoveAviseEntryFromQueue(This, it);
HeapFree(GetProcessHeap(), 0, it);
CoTaskMemFree(it);
}
if (NULL != it) timeOut = (DWORD) ((it->rtBaseTime + it->rtIntervalTime) - curTime) / (REFERENCE_TIME)10000;
@ -225,7 +225,7 @@ static ULONG WINAPI SystemClockImpl_Release(IReferenceClock* iface) {
CloseHandle(This->adviseThread);
}
DeleteCriticalSection(&This->safe);
HeapFree(GetProcessHeap(), 0, This);
CoTaskMemFree(This);
}
return ref;
}
@ -271,10 +271,11 @@ static HRESULT WINAPI SystemClockImpl_AdviseTime(IReferenceClock* iface, REFEREN
if (NULL == pdwAdviseCookie) {
return E_POINTER;
}
pEntry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SystemClockAdviseEntry));
pEntry = CoTaskMemAlloc(sizeof(SystemClockAdviseEntry));
if (NULL == pEntry) {
return E_OUTOFMEMORY;
}
ZeroMemory(pEntry, sizeof(SystemClockAdviseEntry));
pEntry->hEvent = (HANDLE) hEvent;
pEntry->rtBaseTime = rtBaseTime + rtStreamTime;
@ -306,10 +307,11 @@ static HRESULT WINAPI SystemClockImpl_AdvisePeriodic(IReferenceClock* iface, REF
if (NULL == pdwAdviseCookie) {
return E_POINTER;
}
pEntry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SystemClockAdviseEntry));
pEntry = CoTaskMemAlloc(sizeof(SystemClockAdviseEntry));
if (NULL == pEntry) {
return E_OUTOFMEMORY;
}
ZeroMemory(pEntry, sizeof(SystemClockAdviseEntry));
pEntry->hEvent = (HANDLE) hSemaphore;
pEntry->rtBaseTime = rtStartTime;
@ -345,7 +347,7 @@ static HRESULT WINAPI SystemClockImpl_Unadvise(IReferenceClock* iface, DWORD_PTR
}
QUARTZ_RemoveAviseEntryFromQueue(This, pEntry);
HeapFree(GetProcessHeap(), 0, pEntry);
CoTaskMemFree(pEntry);
SystemClockPostMessageToAdviseThread(This, ADVISE_REMOVE);
@ -370,11 +372,13 @@ HRESULT QUARTZ_CreateSystemClock(IUnknown * pUnkOuter, LPVOID * ppv) {
TRACE("(%p,%p)\n", ppv, pUnkOuter);
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SystemClockImpl));
obj = CoTaskMemAlloc(sizeof(SystemClockImpl));
if (NULL == obj) {
*ppv = NULL;
return E_OUTOFMEMORY;
}
ZeroMemory(obj, sizeof(SystemClockImpl));
obj->lpVtbl = &SystemClock_Vtbl;
obj->ref = 0; /* will be inited by QueryInterface */

View File

@ -282,7 +282,7 @@ static ULONG WINAPI TransformFilter_Release(IBaseFilter * iface)
for (i = 0; i < 2; i++)
IPin_Release(This->ppPins[i]);
HeapFree(GetProcessHeap(), 0, This->ppPins);
CoTaskMemFree(This->ppPins);
This->lpVtbl = NULL;
This->pFuncsTable->pfnCleanup(This);

View File

@ -532,7 +532,7 @@ static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
IPin_Release(This->ppPins[0]);
HeapFree(GetProcessHeap(), 0, This->ppPins);
CoTaskMemFree(This->ppPins);
This->lpVtbl = NULL;
TRACE("Destroying Video Renderer\n");