Commit 0b6affbe authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplat: Use CRT allocation functions.

parent c0619c09
......@@ -141,9 +141,9 @@ static ULONG WINAPI memory_buffer_Release(IMFMediaBuffer *iface)
clear_attributes_object(&buffer->dxgi_surface.attributes);
}
DeleteCriticalSection(&buffer->cs);
heap_free(buffer->_2d.linear_buffer);
heap_free(buffer->data);
heap_free(buffer);
free(buffer->_2d.linear_buffer);
free(buffer->data);
free(buffer);
}
return refcount;
......@@ -278,7 +278,7 @@ static HRESULT WINAPI memory_1d_2d_buffer_Lock(IMFMediaBuffer *iface, BYTE **dat
hr = MF_E_INVALIDREQUEST;
else if (!buffer->_2d.linear_buffer)
{
if (!(buffer->_2d.linear_buffer = heap_alloc(ALIGN_SIZE(buffer->_2d.plane_size, MF_64_BYTE_ALIGNMENT))))
if (!(buffer->_2d.linear_buffer = malloc(ALIGN_SIZE(buffer->_2d.plane_size, MF_64_BYTE_ALIGNMENT))))
hr = E_OUTOFMEMORY;
}
......@@ -310,7 +310,7 @@ static HRESULT WINAPI memory_1d_2d_buffer_Unlock(IMFMediaBuffer *iface)
MFCopyImage(buffer->data, buffer->_2d.pitch, buffer->_2d.linear_buffer, buffer->_2d.width,
buffer->_2d.width, buffer->_2d.height);
heap_free(buffer->_2d.linear_buffer);
free(buffer->_2d.linear_buffer);
buffer->_2d.linear_buffer = NULL;
}
......@@ -349,7 +349,7 @@ static HRESULT WINAPI d3d9_surface_buffer_Lock(IMFMediaBuffer *iface, BYTE **dat
{
D3DLOCKED_RECT rect;
if (!(buffer->_2d.linear_buffer = heap_alloc(ALIGN_SIZE(buffer->_2d.plane_size, MF_64_BYTE_ALIGNMENT))))
if (!(buffer->_2d.linear_buffer = malloc(ALIGN_SIZE(buffer->_2d.plane_size, MF_64_BYTE_ALIGNMENT))))
hr = E_OUTOFMEMORY;
if (SUCCEEDED(hr))
......@@ -401,7 +401,7 @@ static HRESULT WINAPI d3d9_surface_buffer_Unlock(IMFMediaBuffer *iface)
IDirect3DSurface9_UnlockRect(buffer->d3d9_surface.surface);
}
heap_free(buffer->_2d.linear_buffer);
free(buffer->_2d.linear_buffer);
buffer->_2d.linear_buffer = NULL;
}
......@@ -928,7 +928,7 @@ static HRESULT WINAPI dxgi_surface_buffer_Lock(IMFMediaBuffer *iface, BYTE **dat
hr = MF_E_INVALIDREQUEST;
else if (!buffer->_2d.linear_buffer)
{
if (!(buffer->_2d.linear_buffer = heap_alloc(ALIGN_SIZE(buffer->_2d.plane_size, MF_64_BYTE_ALIGNMENT))))
if (!(buffer->_2d.linear_buffer = malloc(ALIGN_SIZE(buffer->_2d.plane_size, MF_64_BYTE_ALIGNMENT))))
hr = E_OUTOFMEMORY;
if (SUCCEEDED(hr))
......@@ -974,7 +974,7 @@ static HRESULT WINAPI dxgi_surface_buffer_Unlock(IMFMediaBuffer *iface)
buffer->_2d.linear_buffer, buffer->_2d.width, buffer->_2d.width, buffer->_2d.height);
dxgi_surface_buffer_unmap(buffer);
heap_free(buffer->_2d.linear_buffer);
free(buffer->_2d.linear_buffer);
buffer->_2d.linear_buffer = NULL;
}
......@@ -1225,8 +1225,7 @@ static const IMFDXGIBufferVtbl dxgi_buffer_vtbl =
static HRESULT memory_buffer_init(struct buffer *buffer, DWORD max_length, DWORD alignment,
const IMFMediaBufferVtbl *vtbl)
{
buffer->data = heap_alloc_zero(ALIGN_SIZE(max_length, alignment));
if (!buffer->data)
if (!(buffer->data = calloc(1, ALIGN_SIZE(max_length, alignment))))
return E_OUTOFMEMORY;
buffer->IMFMediaBuffer_iface.lpVtbl = vtbl;
......@@ -1248,14 +1247,13 @@ static HRESULT create_1d_buffer(DWORD max_length, DWORD alignment, IMFMediaBuffe
*buffer = NULL;
object = heap_alloc_zero(sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
hr = memory_buffer_init(object, max_length, alignment, &memory_1d_buffer_vtbl);
if (FAILED(hr))
{
heap_free(object);
free(object);
return hr;
}
......@@ -1291,8 +1289,7 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
if (FAILED(hr = MFGetPlaneSize(fourcc, width, height, &plane_size)))
return hr;
object = heap_alloc_zero(sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
switch (fourcc)
......@@ -1326,7 +1323,7 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
if (FAILED(hr = memory_buffer_init(object, max_length, MF_1_BYTE_ALIGNMENT, &memory_1d_2d_buffer_vtbl)))
{
heap_free(object);
free(object);
return hr;
}
......@@ -1360,8 +1357,7 @@ static HRESULT create_d3d9_surface_buffer(IUnknown *surface, BOOL bottom_up, IMF
if (!(stride = mf_format_get_stride(&subtype, desc.Width, &is_yuv)))
return MF_E_INVALIDMEDIATYPE;
object = heap_alloc_zero(sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IMFMediaBuffer_iface.lpVtbl = &d3d9_surface_1d_buffer_vtbl;
......@@ -1412,8 +1408,7 @@ static HRESULT create_dxgi_surface_buffer(IUnknown *surface, unsigned int sub_re
return MF_E_INVALIDMEDIATYPE;
}
object = heap_alloc_zero(sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
{
ID3D11Texture2D_Release(texture);
return E_OUTOFMEMORY;
......
......@@ -157,7 +157,7 @@ static ULONG WINAPI mediatype_Release(IMFMediaType *iface)
clear_attributes_object(&media_type->attributes);
CoTaskMemFree(media_type->video_format);
CoTaskMemFree(media_type->audio_format);
heap_free(media_type);
free(media_type);
}
return refcount;
......@@ -1435,13 +1435,12 @@ static HRESULT create_media_type(struct media_type **ret)
struct media_type *object;
HRESULT hr;
object = heap_alloc_zero(sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = init_attributes_object(&object->attributes, 0)))
{
heap_free(object);
free(object);
return hr;
}
object->IMFMediaType_iface.lpVtbl = &mediatypevtbl;
......@@ -1519,11 +1518,11 @@ static ULONG WINAPI stream_descriptor_Release(IMFStreamDescriptor *iface)
if (stream_desc->media_types[i])
IMFMediaType_Release(stream_desc->media_types[i]);
}
heap_free(stream_desc->media_types);
free(stream_desc->media_types);
if (stream_desc->current_type)
IMFMediaType_Release(stream_desc->current_type);
clear_attributes_object(&stream_desc->attributes);
heap_free(stream_desc);
free(stream_desc);
}
return refcount;
......@@ -2052,19 +2051,18 @@ HRESULT WINAPI MFCreateStreamDescriptor(DWORD identifier, DWORD count,
if (!count)
return E_INVALIDARG;
object = heap_alloc_zero(sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = init_attributes_object(&object->attributes, 0)))
{
heap_free(object);
free(object);
return hr;
}
object->IMFStreamDescriptor_iface.lpVtbl = &streamdescriptorvtbl;
object->IMFMediaTypeHandler_iface.lpVtbl = &mediatypehandlervtbl;
object->identifier = identifier;
object->media_types = heap_alloc(count * sizeof(*object->media_types));
object->media_types = calloc(count, sizeof(*object->media_types));
if (!object->media_types)
{
IMFStreamDescriptor_Release(&object->IMFStreamDescriptor_iface);
......@@ -2127,8 +2125,8 @@ static ULONG WINAPI presentation_descriptor_Release(IMFPresentationDescriptor *i
IMFStreamDescriptor_Release(presentation_desc->descriptors[i].descriptor);
}
clear_attributes_object(&presentation_desc->attributes);
heap_free(presentation_desc->descriptors);
heap_free(presentation_desc);
free(presentation_desc->descriptors);
free(presentation_desc);
}
return refcount;
......@@ -2491,8 +2489,7 @@ static HRESULT WINAPI presentation_descriptor_Clone(IMFPresentationDescriptor *i
TRACE("%p, %p.\n", iface, descriptor);
object = heap_alloc_zero(sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
presentation_descriptor_init(object, presentation_desc->count);
......@@ -2563,8 +2560,7 @@ static HRESULT presentation_descriptor_init(struct presentation_desc *object, DW
if (FAILED(hr = init_attributes_object(&object->attributes, 0)))
return hr;
object->IMFPresentationDescriptor_iface.lpVtbl = &presentationdescriptorvtbl;
object->descriptors = heap_alloc_zero(count * sizeof(*object->descriptors));
if (!object->descriptors)
if (!(object->descriptors = calloc(count, sizeof(*object->descriptors))))
{
IMFPresentationDescriptor_Release(&object->IMFPresentationDescriptor_iface);
return E_OUTOFMEMORY;
......@@ -2595,13 +2591,12 @@ HRESULT WINAPI MFCreatePresentationDescriptor(DWORD count, IMFStreamDescriptor *
return E_INVALIDARG;
}
object = heap_alloc_zero(sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = presentation_descriptor_init(object, count)))
{
heap_free(object);
free(object);
return hr;
}
......@@ -2818,7 +2813,7 @@ HRESULT WINAPI MFWrapMediaType(IMFMediaType *original, REFGUID major, REFGUID su
if (FAILED(hr = MFGetAttributesAsBlobSize((IMFAttributes *)original, &size)))
return hr;
if (!(buffer = heap_alloc(size)))
if (!(buffer = malloc(size)))
return E_OUTOFMEMORY;
if (FAILED(hr = MFGetAttributesAsBlob((IMFAttributes *)original, buffer, size)))
......@@ -2839,7 +2834,7 @@ HRESULT WINAPI MFWrapMediaType(IMFMediaType *original, REFGUID major, REFGUID su
*ret = mediatype;
failed:
heap_free(buffer);
free(buffer);
return hr;
}
......
......@@ -25,7 +25,6 @@
#include "mferror.h"
#include "d3d9types.h"
#include "wine/heap.h"
#include "wine/debug.h"
struct attribute
......@@ -106,7 +105,7 @@ static inline BOOL mf_array_reserve(void **elements, size_t *capacity, size_t co
if (new_capacity < count)
new_capacity = max_capacity;
if (!(new_elements = heap_realloc(*elements, new_capacity * size)))
if (!(new_elements = realloc(*elements, new_capacity * size)))
return FALSE;
*elements = new_elements;
......
......@@ -162,8 +162,8 @@ static void release_sample_object(struct sample *sample)
for (i = 0; i < sample->buffer_count; ++i)
IMFMediaBuffer_Release(sample->buffers[i]);
clear_attributes_object(&sample->attributes);
heap_free(sample->buffers);
heap_free(sample);
free(sample->buffers);
free(sample);
}
static ULONG WINAPI sample_Release(IMFSample *iface)
......@@ -1020,13 +1020,12 @@ HRESULT WINAPI MFCreateSample(IMFSample **sample)
TRACE("%p.\n", sample);
object = heap_alloc_zero(sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = init_attributes_object(&object->attributes, 0)))
{
heap_free(object);
free(object);
return hr;
}
......@@ -1049,13 +1048,12 @@ HRESULT WINAPI MFCreateTrackedSample(IMFTrackedSample **sample)
TRACE("%p.\n", sample);
object = heap_alloc_zero(sizeof(*object));
if (!object)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = init_attributes_object(&object->attributes, 0)))
{
heap_free(object);
free(object);
return hr;
}
......@@ -1112,13 +1110,13 @@ static void sample_allocator_release_samples(struct sample_allocator *allocator)
{
list_remove(&iter->entry);
IMFSample_Release(iter->sample);
heap_free(iter);
free(iter);
}
LIST_FOR_EACH_ENTRY_SAFE(iter, iter2, &allocator->used_samples, struct queued_sample, entry)
{
list_remove(&iter->entry);
heap_free(iter);
free(iter);
}
allocator->free_sample_count = 0;
......@@ -1183,7 +1181,7 @@ static ULONG WINAPI sample_allocator_Release(IMFVideoSampleAllocatorEx *iface)
sample_allocator_set_attributes(allocator, NULL);
sample_allocator_release_samples(allocator);
DeleteCriticalSection(&allocator->cs);
heap_free(allocator);
free(allocator);
}
return refcount;
......@@ -1308,7 +1306,7 @@ static void sample_allocator_release_surface_service(struct sample_allocator *al
static HRESULT sample_allocator_allocate_sample(struct sample_allocator *allocator, const struct surface_service *service,
IMFSample **sample)
{
struct queued_sample *queued_sample = heap_alloc(sizeof(*queued_sample));
struct queued_sample *queued_sample = malloc(sizeof(*queued_sample));
IMFTrackedSample *tracked_sample;
IMFMediaBuffer *buffer;
unsigned int i;
......@@ -1445,7 +1443,7 @@ static HRESULT sample_allocator_initialize(struct sample_allocator *allocator, u
if (SUCCEEDED(hr = sample_allocator_allocate_sample(allocator, &service, &sample)))
{
queued_sample = heap_alloc(sizeof(*queued_sample));
queued_sample = malloc(sizeof(*queued_sample));
queued_sample->sample = sample;
list_add_tail(&allocator->free_samples, &queued_sample->entry);
allocator->free_sample_count++;
......@@ -1534,7 +1532,7 @@ static HRESULT WINAPI sample_allocator_AllocateSample(IMFVideoSampleAllocatorEx
{
if (SUCCEEDED(hr = sample_allocator_track_sample(allocator, sample)))
{
struct queued_sample *queued_sample = heap_alloc(sizeof(*queued_sample));
struct queued_sample *queued_sample = malloc(sizeof(*queued_sample));
queued_sample->sample = sample;
list_add_tail(&allocator->used_samples, &queued_sample->entry);
......@@ -1738,7 +1736,7 @@ HRESULT WINAPI MFCreateVideoSampleAllocatorEx(REFIID riid, void **obj)
TRACE("%s, %p.\n", debugstr_guid(riid), obj);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->IMFVideoSampleAllocatorEx_iface.lpVtbl = &sample_allocator_vtbl;
......
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