Chris Robinson : quartz: Use proper alloc/free functions for COM
objects.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Mar 8 07:17:13 CST 2007
Module: wine
Branch: master
Commit: 045270605c4774c43f50c077ad3733c263eb6fe8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=045270605c4774c43f50c077ad3733c263eb6fe8
Author: Chris Robinson <chris.kcat at gmail.com>
Date: Thu Mar 8 03:03:06 2007 -0800
quartz: Use proper alloc/free functions for COM objects.
---
dlls/quartz/dsoundrender.c | 2 +-
dlls/quartz/filtergraph.c | 13 +++++++------
dlls/quartz/main.c | 4 ++--
dlls/quartz/memallocator.c | 4 ++--
dlls/quartz/parser.c | 12 ++++++------
dlls/quartz/systemclock.c | 16 ++++++++++------
dlls/quartz/transform.c | 2 +-
dlls/quartz/videorenderer.c | 2 +-
8 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/dlls/quartz/dsoundrender.c b/dlls/quartz/dsoundrender.c
index 9c03443..87a6f69 100644
--- a/dlls/quartz/dsoundrender.c
+++ b/dlls/quartz/dsoundrender.c
@@ -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;
diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index 3a4db4f..4bbe879 100644
--- a/dlls/quartz/filtergraph.c
+++ b/dlls/quartz/filtergraph.c
@@ -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;
diff --git a/dlls/quartz/main.c b/dlls/quartz/main.c
index 559b791..4c3eb9d 100644
--- a/dlls/quartz/main.c
+++ b/dlls/quartz/main.c
@@ -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;
diff --git a/dlls/quartz/memallocator.c b/dlls/quartz/memallocator.c
index 9b4a0fb..4bb6bab 100644
--- a/dlls/quartz/memallocator.c
+++ b/dlls/quartz/memallocator.c
@@ -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;
diff --git a/dlls/quartz/parser.c b/dlls/quartz/parser.c
index edcb9c7..e9d0854 100644
--- a/dlls/quartz/parser.c
+++ b/dlls/quartz/parser.c
@@ -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;
}
diff --git a/dlls/quartz/systemclock.c b/dlls/quartz/systemclock.c
index 50797cc..78374d8 100644
--- a/dlls/quartz/systemclock.c
+++ b/dlls/quartz/systemclock.c
@@ -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 */
diff --git a/dlls/quartz/transform.c b/dlls/quartz/transform.c
index 59c2e3a..a610d43 100644
--- a/dlls/quartz/transform.c
+++ b/dlls/quartz/transform.c
@@ -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);
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c
index 7adf59a..3ec283a 100644
--- a/dlls/quartz/videorenderer.c
+++ b/dlls/quartz/videorenderer.c
@@ -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");
More information about the wine-cvs
mailing list