[PATCH 2/6] winegstreamer: Use malloc() instead of HeapAlloc().
Zebediah Figura
z.figura12 at gmail.com
Mon Feb 22 16:53:46 CST 2021
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/winegstreamer/audioconvert.c | 5 +--
dlls/winegstreamer/gst_private.h | 1 -
dlls/winegstreamer/gstdemux.c | 26 ++++++------
dlls/winegstreamer/media_source.c | 67 +++++++++++--------------------
dlls/winegstreamer/mfplat.c | 9 ++---
5 files changed, 42 insertions(+), 66 deletions(-)
diff --git a/dlls/winegstreamer/audioconvert.c b/dlls/winegstreamer/audioconvert.c
index 3b6571ab60d..304e1c8b067 100644
--- a/dlls/winegstreamer/audioconvert.c
+++ b/dlls/winegstreamer/audioconvert.c
@@ -26,7 +26,6 @@
#include "ksmedia.h"
#include "wine/debug.h"
-#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
@@ -82,7 +81,7 @@ static ULONG WINAPI audio_converter_Release(IMFTransform *iface)
{
transform->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&transform->cs);
- heap_free(transform);
+ free(transform);
}
return refcount;
@@ -572,7 +571,7 @@ HRESULT audio_converter_create(REFIID riid, void **ret)
TRACE("%s %p\n", debugstr_guid(riid), ret);
- if (!(object = heap_alloc_zero(sizeof(*object))))
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IMFTransform_iface.lpVtbl = &audio_converter_vtbl;
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h
index ef84d611a09..3a5445a27ce 100644
--- a/dlls/winegstreamer/gst_private.h
+++ b/dlls/winegstreamer/gst_private.h
@@ -37,7 +37,6 @@
#include "strmif.h"
#include "mfobjects.h"
#include "wine/debug.h"
-#include "wine/heap.h"
#include "wine/strmbase.h"
typedef enum
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index acfd3b3ae4c..985183b0a35 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -860,7 +860,7 @@ static void parser_destroy(struct strmbase_filter *iface)
strmbase_sink_cleanup(&filter->sink);
strmbase_filter_cleanup(&filter->filter);
- heap_free(filter);
+ free(filter);
}
static HRESULT parser_init_stream(struct strmbase_filter *iface)
@@ -1096,12 +1096,12 @@ HRESULT decodebin_parser_create(IUnknown *outer, IUnknown **out)
if (!parser_init_gstreamer())
return E_FAIL;
- if (!(object = heap_alloc_zero(sizeof(*object))))
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (!(object->wg_parser = unix_funcs->wg_decodebin_parser_create()))
{
- heap_free(object);
+ free(object);
return E_OUTOFMEMORY;
}
@@ -1485,7 +1485,7 @@ static void free_source_pin(struct parser_source *pin)
strmbase_seeking_cleanup(&pin->seek);
strmbase_source_cleanup(&pin->pin);
- heap_free(pin);
+ free(pin);
}
static const struct strmbase_source_ops source_ops =
@@ -1504,11 +1504,11 @@ static struct parser_source *create_pin(struct parser *filter,
{
struct parser_source *pin, **new_array;
- if (!(new_array = heap_realloc(filter->sources, (filter->source_count + 1) * sizeof(*filter->sources))))
+ if (!(new_array = realloc(filter->sources, (filter->source_count + 1) * sizeof(*filter->sources))))
return NULL;
filter->sources = new_array;
- if (!(pin = heap_alloc_zero(sizeof(*pin))))
+ if (!(pin = calloc(1, sizeof(*pin))))
return NULL;
pin->wg_stream = stream;
@@ -1549,7 +1549,7 @@ static HRESULT GST_RemoveOutputPins(struct parser *This)
}
This->source_count = 0;
- heap_free(This->sources);
+ free(This->sources);
This->sources = NULL;
BaseFilterImpl_IncrementPinVersion(&This->filter);
@@ -1627,12 +1627,12 @@ HRESULT wave_parser_create(IUnknown *outer, IUnknown **out)
if (!parser_init_gstreamer())
return E_FAIL;
- if (!(object = heap_alloc_zero(sizeof(*object))))
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (!(object->wg_parser = unix_funcs->wg_wave_parser_create()))
{
- heap_free(object);
+ free(object);
return E_OUTOFMEMORY;
}
@@ -1713,12 +1713,12 @@ HRESULT avi_splitter_create(IUnknown *outer, IUnknown **out)
if (!parser_init_gstreamer())
return E_FAIL;
- if (!(object = heap_alloc_zero(sizeof(*object))))
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (!(object->wg_parser = unix_funcs->wg_avi_parser_create()))
{
- heap_free(object);
+ free(object);
return E_OUTOFMEMORY;
}
@@ -1820,12 +1820,12 @@ HRESULT mpeg_splitter_create(IUnknown *outer, IUnknown **out)
if (!parser_init_gstreamer())
return E_FAIL;
- if (!(object = heap_alloc_zero(sizeof(*object))))
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (!(object->wg_parser = unix_funcs->wg_mpeg_audio_parser_create()))
{
- heap_free(object);
+ free(object);
return E_OUTOFMEMORY;
}
diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c
index 74af8e41f48..f72b4ff2fd0 100644
--- a/dlls/winegstreamer/media_source.c
+++ b/dlls/winegstreamer/media_source.c
@@ -33,7 +33,6 @@
#include "mfobjects.h"
#include "wine/debug.h"
-#include "wine/heap.h"
#include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
@@ -163,7 +162,7 @@ static ULONG WINAPI source_async_command_Release(IUnknown *iface)
{
if (command->op == SOURCE_ASYNC_START)
PropVariantClear(&command->u.start.position);
- heap_free(command);
+ free(command);
}
return refcount;
@@ -180,7 +179,7 @@ static HRESULT source_create_async_op(enum source_async_op op, struct source_asy
{
struct source_async_command *command;
- if (!(command = heap_alloc_zero(sizeof(*command))))
+ if (!(command = calloc(1, sizeof(*command))))
return E_OUTOFMEMORY;
command->IUnknown_iface.lpVtbl = &source_async_command_vtbl;
@@ -590,7 +589,7 @@ static ULONG WINAPI media_stream_Release(IMFMediaStream *iface)
{
if (stream->event_queue)
IMFMediaEventQueue_Release(stream->event_queue);
- heap_free(stream);
+ free(stream);
}
return ref;
@@ -716,7 +715,7 @@ static const IMFMediaStreamVtbl media_stream_vtbl =
static HRESULT new_media_stream(struct media_source *source,
struct wg_parser_stream *wg_stream, DWORD stream_id, struct media_stream **out_stream)
{
- struct media_stream *object = heap_alloc_zero(sizeof(*object));
+ struct media_stream *object = calloc(1, sizeof(*object));
HRESULT hr;
TRACE("source %p, wg_stream %p, stream_id %u.\n", source, wg_stream, stream_id);
@@ -777,7 +776,7 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
IMFMediaType_GetGUID(base_type, &MF_MT_SUBTYPE, &base_subtype);
- stream_types = heap_alloc( sizeof(IMFMediaType *) * ARRAY_SIZE(video_types) + 1);
+ stream_types = malloc(sizeof(IMFMediaType *) * (ARRAY_SIZE(video_types) + 1));
stream_types[0] = base_type;
type_count = 1;
@@ -830,7 +829,7 @@ done:
for (i = 0; i < type_count; i++)
IMFMediaType_Release(stream_types[i]);
if (stream_types != &stream_type)
- heap_free(stream_types);
+ free(stream_types);
return hr;
}
@@ -878,7 +877,7 @@ static ULONG WINAPI media_source_Release(IMFMediaSource *iface)
{
IMFMediaSource_Shutdown(&source->IMFMediaSource_iface);
IMFMediaEventQueue_Release(source->event_queue);
- heap_free(source);
+ free(source);
}
return ref;
@@ -1050,7 +1049,7 @@ static HRESULT WINAPI media_source_Shutdown(IMFMediaSource *iface)
unix_funcs->wg_parser_destroy(source->wg_parser);
if (source->stream_count)
- heap_free(source->streams);
+ free(source->streams);
if (source->async_commands_queue)
MFUnlockWorkQueue(source->async_commands_queue);
@@ -1101,7 +1100,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
return hr;
}
- if (!(object = heap_alloc_zero(sizeof(*object))))
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IMFMediaSource_iface.lpVtbl = &IMFMediaSource_vtbl;
@@ -1140,7 +1139,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
object->stream_count = unix_funcs->wg_parser_get_stream_count(parser);
- if (!(object->streams = heap_alloc_zero(object->stream_count * sizeof(*object->streams))))
+ if (!(object->streams = calloc(object->stream_count, sizeof(*object->streams))))
{
hr = E_OUTOFMEMORY;
goto fail;
@@ -1161,7 +1160,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
/* init presentation descriptor */
- descriptors = heap_alloc(object->stream_count * sizeof(IMFStreamDescriptor*));
+ descriptors = malloc(object->stream_count * sizeof(IMFStreamDescriptor *));
for (i = 0; i < object->stream_count; i++)
{
IMFMediaStream_GetStreamDescriptor(&object->streams[i]->IMFMediaStream_iface, &descriptors[i]);
@@ -1175,7 +1174,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
IMFPresentationDescriptor_SelectStream(object->pres_desc, i);
IMFStreamDescriptor_Release(descriptors[i]);
}
- heap_free(descriptors);
+ free(descriptors);
descriptors = NULL;
for (i = 0; i < object->stream_count; i++)
@@ -1193,7 +1192,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
fail:
WARN("Failed to construct MFMediaSource, hr %#x.\n", hr);
- heap_free(descriptors);
+ free(descriptors);
IMFMediaSource_Release(&object->IMFMediaSource_iface);
return hr;
}
@@ -1268,10 +1267,10 @@ static ULONG WINAPI winegstreamer_stream_handler_Release(IMFByteStreamHandler *i
IMFAsyncResult_Release(result->result);
if (result->object)
IUnknown_Release(result->object);
- heap_free(result);
+ free(result);
}
DeleteCriticalSection(&handler->cs);
- heap_free(handler);
+ free(handler);
}
return refcount;
@@ -1332,8 +1331,8 @@ static ULONG WINAPI create_object_context_Release(IUnknown *iface)
IPropertyStore_Release(context->props);
if (context->stream)
IMFByteStream_Release(context->stream);
- heap_free(context->url);
- heap_free(context);
+ free(context->url);
+ free(context);
}
return refcount;
@@ -1346,23 +1345,6 @@ static const IUnknownVtbl create_object_context_vtbl =
create_object_context_Release,
};
-static WCHAR *heap_strdupW(const WCHAR *str)
-{
- WCHAR *ret = NULL;
-
- if (str)
- {
- unsigned int size;
-
- size = (lstrlenW(str) + 1) * sizeof(WCHAR);
- ret = heap_alloc(size);
- if (ret)
- memcpy(ret, str, size);
- }
-
- return ret;
-}
-
static HRESULT WINAPI winegstreamer_stream_handler_BeginCreateObject(IMFByteStreamHandler *iface, IMFByteStream *stream, const WCHAR *url, DWORD flags,
IPropertyStore *props, IUnknown **cancel_cookie, IMFAsyncCallback *callback, IUnknown *state)
{
@@ -1379,8 +1361,7 @@ static HRESULT WINAPI winegstreamer_stream_handler_BeginCreateObject(IMFByteStre
if (FAILED(hr = MFCreateAsyncResult(NULL, callback, state, &caller)))
return hr;
- context = heap_alloc_zero(sizeof(*context));
- if (!context)
+ if (!(context = calloc(1, sizeof(*context))))
{
IMFAsyncResult_Release(caller);
return E_OUTOFMEMORY;
@@ -1396,7 +1377,7 @@ static HRESULT WINAPI winegstreamer_stream_handler_BeginCreateObject(IMFByteStre
if (context->stream)
IMFByteStream_AddRef(context->stream);
if (url)
- context->url = heap_strdupW(url);
+ context->url = wcsdup(url);
if (!context->stream)
{
IMFAsyncResult_Release(caller);
@@ -1453,7 +1434,7 @@ static HRESULT WINAPI winegstreamer_stream_handler_EndCreateObject(IMFByteStream
*object = found->object;
hr = IMFAsyncResult_GetStatus(found->result);
IMFAsyncResult_Release(found->result);
- heap_free(found);
+ free(found);
}
else
{
@@ -1491,7 +1472,7 @@ static HRESULT WINAPI winegstreamer_stream_handler_CancelObjectCreation(IMFByteS
IMFAsyncResult_Release(found->result);
if (found->object)
IUnknown_Release(found->object);
- heap_free(found);
+ free(found);
}
return found ? S_OK : MF_E_UNEXPECTED;
@@ -1595,8 +1576,7 @@ static HRESULT WINAPI winegstreamer_stream_handler_callback_Invoke(IMFAsyncCallb
hr = winegstreamer_stream_handler_create_object(handler, context->url, context->stream, context->flags, context->props, &object, &obj_type);
- handler_result = heap_alloc(sizeof(*handler_result));
- if (handler_result)
+ if ((handler_result = malloc(sizeof(*handler_result))))
{
handler_result->result = caller;
IMFAsyncResult_AddRef(handler_result->result);
@@ -1638,8 +1618,7 @@ HRESULT winegstreamer_stream_handler_create(REFIID riid, void **obj)
TRACE("%s, %p.\n", debugstr_guid(riid), obj);
- this = heap_alloc_zero(sizeof(*this));
- if (!this)
+ if (!(this = calloc(1, sizeof(*this))))
return E_OUTOFMEMORY;
list_init(&this->results);
diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c
index 22581eb7311..e6913d099b0 100644
--- a/dlls/winegstreamer/mfplat.c
+++ b/dlls/winegstreamer/mfplat.c
@@ -29,7 +29,6 @@
#include "ksmedia.h"
#include "wine/debug.h"
-#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
@@ -86,7 +85,7 @@ static ULONG WINAPI video_processor_Release(IMFTransform *iface)
IMFAttributes_Release(transform->attributes);
if (transform->output_attributes)
IMFAttributes_Release(transform->output_attributes);
- heap_free(transform);
+ free(transform);
}
return refcount;
@@ -337,7 +336,7 @@ static ULONG WINAPI class_factory_Release(IClassFactory *iface)
ULONG refcount = InterlockedDecrement(&factory->refcount);
if (!refcount)
- heap_free(factory);
+ free(factory);
return refcount;
}
@@ -383,7 +382,7 @@ static HRESULT video_processor_create(REFIID riid, void **ret)
struct video_processor *object;
HRESULT hr;
- if (!(object = heap_alloc_zero(sizeof(*object))))
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IMFTransform_iface.lpVtbl = &video_processor_vtbl;
@@ -430,7 +429,7 @@ HRESULT mfplat_get_class_object(REFCLSID rclsid, REFIID riid, void **obj)
{
if (IsEqualGUID(class_objects[i].clsid, rclsid))
{
- if (!(factory = heap_alloc(sizeof(*factory))))
+ if (!(factory = malloc(sizeof(*factory))))
return E_OUTOFMEMORY;
factory->IClassFactory_iface.lpVtbl = &class_factory_vtbl;
--
2.30.1
More information about the wine-devel
mailing list