Commit c71ac523 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

amstream: Use CRT memory allocators.

parent ed8cf75a
......@@ -32,7 +32,6 @@
#include "mmstream.h"
#include "austream.h"
#include "amstream.h"
#include "wine/heap.h"
HRESULT multimedia_stream_create(IUnknown *outer, void **out) DECLSPEC_HIDDEN;
HRESULT AMAudioData_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;
......
......@@ -71,19 +71,16 @@ static ULONG WINAPI IAudioDataImpl_AddRef(IAudioData* iface)
static ULONG WINAPI IAudioDataImpl_Release(IAudioData* iface)
{
AMAudioDataImpl *This = impl_from_IAudioData(iface);
ULONG ref = InterlockedDecrement(&This->ref);
AMAudioDataImpl *audiodata = impl_from_IAudioData(iface);
ULONG ref = InterlockedDecrement(&audiodata->ref);
TRACE("(%p)->(): new ref = %lu\n", iface, This->ref);
TRACE("%p decreasing refcount to %lu.\n", audiodata, ref);
if (!ref)
{
if (This->data_owned)
{
CoTaskMemFree(This->data);
}
HeapFree(GetProcessHeap(), 0, This);
if (audiodata->data_owned)
free(audiodata->data);
free(audiodata);
}
return ref;
......@@ -103,7 +100,7 @@ static HRESULT WINAPI IAudioDataImpl_SetBuffer(IAudioData* iface, DWORD size, BY
if (This->data_owned)
{
CoTaskMemFree(This->data);
free(This->data);
This->data_owned = FALSE;
}
......@@ -112,7 +109,7 @@ static HRESULT WINAPI IAudioDataImpl_SetBuffer(IAudioData* iface, DWORD size, BY
if (!This->data)
{
This->data = CoTaskMemAlloc(This->size);
This->data = malloc(This->size);
This->data_owned = TRUE;
if (!This->data)
{
......@@ -228,8 +225,7 @@ HRESULT AMAudioData_create(IUnknown *pUnkOuter, LPVOID *ppObj)
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(AMAudioDataImpl));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IAudioData_iface.lpVtbl = &AudioData_Vtbl;
......
......@@ -202,7 +202,7 @@ static ULONG WINAPI audio_sample_Release(IAudioStreamSample *iface)
IAMMediaStream_Release(&sample->parent->IAMMediaStream_iface);
IAudioData_Release(sample->audio_data);
CloseHandle(sample->update_event);
HeapFree(GetProcessHeap(), 0, sample);
free(sample);
}
return refcount;
}
......@@ -383,8 +383,7 @@ static HRESULT audiostreamsample_create(struct audio_stream *parent, IAudioData
TRACE("(%p)\n", audio_stream_sample);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IAudioStreamSample_iface.lpVtbl = &AudioStreamSample_Vtbl;
......@@ -456,15 +455,15 @@ static ULONG WINAPI audio_IAMMediaStream_AddRef(IAMMediaStream *iface)
static ULONG WINAPI audio_IAMMediaStream_Release(IAMMediaStream *iface)
{
struct audio_stream *This = impl_from_IAMMediaStream(iface);
ULONG ref = InterlockedDecrement(&This->ref);
struct audio_stream *stream = impl_from_IAMMediaStream(iface);
ULONG ref = InterlockedDecrement(&stream->ref);
TRACE("(%p/%p)->(): new ref = %lu\n", iface, This, ref);
TRACE("%p decreasing refcount to %lu.\n", stream, ref);
if (!ref)
{
DeleteCriticalSection(&This->cs);
HeapFree(GetProcessHeap(), 0, This);
DeleteCriticalSection(&stream->cs);
free(stream);
}
return ref;
......@@ -830,7 +829,7 @@ static ULONG WINAPI enum_media_types_Release(IEnumMediaTypes *iface)
ULONG refcount = InterlockedDecrement(&enum_media_types->refcount);
TRACE("%p decreasing refcount to %lu.\n", enum_media_types, refcount);
if (!refcount)
heap_free(enum_media_types);
free(enum_media_types);
return refcount;
}
......@@ -904,7 +903,7 @@ static HRESULT WINAPI enum_media_types_Clone(IEnumMediaTypes *iface, IEnumMediaT
TRACE("iface %p, out %p.\n", iface, out);
if (!(object = heap_alloc(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IEnumMediaTypes_iface.lpVtbl = &enum_media_types_vtbl;
......@@ -1121,7 +1120,7 @@ static HRESULT WINAPI audio_sink_EnumMediaTypes(IPin *iface, IEnumMediaTypes **e
if (!enum_media_types)
return E_POINTER;
if (!(object = heap_alloc(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IEnumMediaTypes_iface.lpVtbl = &enum_media_types_vtbl;
......@@ -1394,8 +1393,7 @@ HRESULT audio_stream_create(IUnknown *outer, void **out)
if (outer)
return CLASS_E_NOAGGREGATION;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IAMMediaStream_iface.lpVtbl = &audio_IAMMediaStream_vtbl;
......
......@@ -229,7 +229,7 @@ static ULONG WINAPI ddraw_IAMMediaStream_Release(IAMMediaStream *iface)
DeleteCriticalSection(&stream->cs);
if (stream->ddraw)
IDirectDraw_Release(stream->ddraw);
HeapFree(GetProcessHeap(), 0, stream);
free(stream);
}
return ref;
......@@ -815,7 +815,7 @@ static ULONG WINAPI enum_media_types_Release(IEnumMediaTypes *iface)
ULONG refcount = InterlockedDecrement(&enum_media_types->refcount);
TRACE("%p decreasing refcount to %lu.\n", enum_media_types, refcount);
if (!refcount)
heap_free(enum_media_types);
free(enum_media_types);
return refcount;
}
......@@ -873,7 +873,7 @@ static HRESULT WINAPI enum_media_types_Clone(IEnumMediaTypes *iface, IEnumMediaT
TRACE("iface %p, out %p.\n", iface, out);
if (!(object = heap_alloc(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IEnumMediaTypes_iface.lpVtbl = &enum_media_types_vtbl;
......@@ -1148,7 +1148,7 @@ static HRESULT WINAPI ddraw_sink_EnumMediaTypes(IPin *iface, IEnumMediaTypes **e
if (!enum_media_types)
return E_POINTER;
if (!(object = heap_alloc(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IEnumMediaTypes_iface.lpVtbl = &enum_media_types_vtbl;
......@@ -1460,8 +1460,7 @@ HRESULT ddraw_stream_create(IUnknown *outer, void **out)
if (outer)
return CLASS_E_NOAGGREGATION;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IAMMediaStream_iface.lpVtbl = &ddraw_IAMMediaStream_vtbl;
......@@ -1539,7 +1538,7 @@ static ULONG WINAPI ddraw_sample_Release(IDirectDrawStreamSample *iface)
if (sample->surface)
IDirectDrawSurface_Release(sample->surface);
HeapFree(GetProcessHeap(), 0, sample);
free(sample);
}
return ref;
......@@ -1736,8 +1735,7 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw
TRACE("(%p)\n", ddraw_stream_sample);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IDirectDrawStreamSample_iface.lpVtbl = &DirectDrawStreamSample_Vtbl;
......
......@@ -76,8 +76,8 @@ static ULONG WINAPI enum_pins_Release(IEnumPins *iface)
{
for (i = 0; i < enum_pins->count; ++i)
IPin_Release(enum_pins->pins[i]);
heap_free(enum_pins->pins);
heap_free(enum_pins);
free(enum_pins->pins);
free(enum_pins);
}
return refcount;
}
......@@ -131,16 +131,16 @@ static HRESULT WINAPI enum_pins_Clone(IEnumPins *iface, IEnumPins **out)
TRACE("iface %p, out %p.\n", iface, out);
if (!(object = heap_alloc(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IEnumPins_iface.lpVtbl = &enum_pins_vtbl;
object->refcount = 1;
object->count = enum_pins->count;
object->index = enum_pins->index;
if (!(object->pins = heap_alloc(enum_pins->count * sizeof(*object->pins))))
if (!(object->pins = malloc(enum_pins->count * sizeof(*object->pins))))
{
heap_free(object);
free(object);
return E_OUTOFMEMORY;
}
for (i = 0; i < enum_pins->count; ++i)
......@@ -251,11 +251,11 @@ static ULONG WINAPI filter_Release(IMediaStreamFilter *iface)
IAMMediaStream_JoinFilter(filter->streams[i], NULL);
IAMMediaStream_Release(filter->streams[i]);
}
heap_free(filter->streams);
free(filter->streams);
if (filter->clock)
IReferenceClock_Release(filter->clock);
DeleteCriticalSection(&filter->cs);
heap_free(filter);
free(filter);
}
return refcount;
......@@ -424,7 +424,7 @@ static HRESULT WINAPI filter_EnumPins(IMediaStreamFilter *iface, IEnumPins **enu
if (!enum_pins)
return E_POINTER;
if (!(object = heap_alloc(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
EnterCriticalSection(&filter->cs);
......@@ -433,9 +433,9 @@ static HRESULT WINAPI filter_EnumPins(IMediaStreamFilter *iface, IEnumPins **enu
object->refcount = 1;
object->count = filter->nb_streams;
object->index = 0;
if (!(object->pins = heap_alloc(filter->nb_streams * sizeof(*object->pins))))
if (!(object->pins = malloc(filter->nb_streams * sizeof(*object->pins))))
{
heap_free(object);
free(object);
LeaveCriticalSection(&filter->cs);
return E_OUTOFMEMORY;
}
......@@ -543,7 +543,7 @@ static HRESULT WINAPI filter_AddMediaStream(IMediaStreamFilter *iface, IAMMediaS
TRACE("(%p)->(%p)\n", iface, pAMMediaStream);
streams = CoTaskMemRealloc(This->streams, (This->nb_streams + 1) * sizeof(IAMMediaStream*));
streams = realloc(This->streams, (This->nb_streams + 1) * sizeof(*streams));
if (!streams)
return E_OUTOFMEMORY;
This->streams = streams;
......@@ -1092,7 +1092,7 @@ HRESULT filter_create(IUnknown *outer, void **out)
if (outer)
return CLASS_E_NOAGGREGATION;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IMediaStreamFilter_iface.lpVtbl = &filter_vtbl;
......
......@@ -93,7 +93,7 @@ static ULONG WINAPI AMCF_Release(IClassFactory *iface)
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
HeapFree(GetProcessHeap(), 0, This);
free(This);
return ref;
}
......@@ -173,8 +173,8 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
return CLASS_E_CLASSNOTAVAILABLE;
}
factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
if (factory == NULL) return E_OUTOFMEMORY;
if (!(factory = calloc(1, sizeof(*factory))))
return E_OUTOFMEMORY;
factory->IClassFactory_iface.lpVtbl = &DSCF_Vtbl;
factory->ref = 1;
......
......@@ -100,7 +100,7 @@ static ULONG WINAPI multimedia_stream_Release(IAMMultiMediaStream *iface)
IMediaControl_Release(This->media_control);
if (This->graph)
IGraphBuilder_Release(This->graph);
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
return ref;
......@@ -562,7 +562,7 @@ HRESULT multimedia_stream_create(IUnknown *outer, void **out)
if (outer)
return CLASS_E_NOAGGREGATION;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IAMMultiMediaStream_iface.lpVtbl = &multimedia_stream_vtbl;
......@@ -572,7 +572,7 @@ HRESULT multimedia_stream_create(IUnknown *outer, void **out)
CLSCTX_INPROC_SERVER, &IID_IMediaStreamFilter, (void **)&object->filter)))
{
ERR("Failed to create stream filter, hr %#lx.\n", hr);
heap_free(object);
free(object);
return 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