Commit 9e47b64c authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d2d1: Use CRT memory allocation functions.

parent beee5160
......@@ -93,7 +93,7 @@ static ULONG STDMETHODCALLTYPE d2d_bitmap_Release(ID2D1Bitmap1 *iface)
IDXGISurface_Release(bitmap->surface);
ID3D11Resource_Release(bitmap->resource);
ID2D1Factory_Release(bitmap->factory);
heap_free(bitmap);
free(bitmap);
}
return refcount;
......@@ -485,7 +485,7 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size,
return hr;
}
if ((*bitmap = heap_alloc_zero(sizeof(**bitmap))))
if ((*bitmap = calloc(1, sizeof(**bitmap))))
{
d2d_bitmap_init(*bitmap, context, (ID3D11Resource *)texture, size, desc);
TRACE("Created bitmap %p.\n", *bitmap);
......@@ -562,7 +562,7 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid,
goto failed;
}
if (!(*bitmap = heap_alloc_zero(sizeof(**bitmap))))
if (!(*bitmap = calloc(1, sizeof(**bitmap))))
{
hr = E_OUTOFMEMORY;
goto failed;
......@@ -598,7 +598,7 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid,
return D2DERR_UNSUPPORTED_OPERATION;
}
if (!(*bitmap = heap_alloc_zero(sizeof(**bitmap))))
if (!(*bitmap = calloc(1, sizeof(**bitmap))))
{
ID3D11Resource_Release(resource);
return E_OUTOFMEMORY;
......@@ -735,7 +735,7 @@ HRESULT d2d_bitmap_create_from_wic_bitmap(struct d2d_device_context *context, IW
pitch = ((bpp * size.width) + 15) & ~15;
if (pitch / bpp < size.width)
return E_OUTOFMEMORY;
if (!(data = heap_calloc(size.height, pitch)))
if (!(data = calloc(size.height, pitch)))
return E_OUTOFMEMORY;
data_size = size.height * pitch;
......@@ -746,13 +746,13 @@ HRESULT d2d_bitmap_create_from_wic_bitmap(struct d2d_device_context *context, IW
if (FAILED(hr = IWICBitmapSource_CopyPixels(bitmap_source, &rect, pitch, data_size, data)))
{
WARN("Failed to copy bitmap pixels, hr %#lx.\n", hr);
heap_free(data);
free(data);
return hr;
}
hr = d2d_bitmap_create(context, size, data, pitch, &bitmap_desc, bitmap);
heap_free(data);
free(data);
return hr;
}
......
......@@ -68,7 +68,7 @@ static ULONG STDMETHODCALLTYPE d2d_bitmap_render_target_Release(ID2D1BitmapRende
IUnknown_Release(render_target->dxgi_inner);
if (render_target->bitmap)
ID2D1Bitmap_Release(render_target->bitmap);
heap_free(render_target);
free(render_target);
}
return refcount;
......
......@@ -64,10 +64,10 @@ static ULONG STDMETHODCALLTYPE d2d_gradient_Release(ID2D1GradientStopCollection
if (!refcount)
{
heap_free(gradient->stops);
free(gradient->stops);
ID3D11ShaderResourceView_Release(gradient->view);
ID2D1Factory_Release(gradient->factory);
heap_free(gradient);
free(gradient);
}
return refcount;
......@@ -141,7 +141,7 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const
HRESULT hr;
*out = NULL;
if (!(data = heap_calloc(stop_count, 2 * sizeof(*data))))
if (!(data = calloc(stop_count, 2 * sizeof(*data))))
{
ERR("Failed to allocate data.\n");
return E_OUTOFMEMORY;
......@@ -167,7 +167,7 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const
buffer_data.SysMemSlicePitch = 0;
hr = ID3D11Device1_CreateBuffer(device, &buffer_desc, &buffer_data, &buffer);
heap_free(data);
free(data);
if (FAILED(hr))
{
ERR("Failed to create buffer, hr %#lx.\n", hr);
......@@ -187,7 +187,7 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const
return hr;
}
if (!(gradient = heap_alloc_zero(sizeof(*gradient))))
if (!(gradient = calloc(1, sizeof(*gradient))))
{
ID3D11ShaderResourceView_Release(view);
return E_OUTOFMEMORY;
......@@ -204,10 +204,10 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const
gradient->view = view;
gradient->stop_count = stop_count;
if (!(gradient->stops = heap_calloc(stop_count, sizeof(*stops))))
if (!(gradient->stops = calloc(stop_count, sizeof(*stops))))
{
ID3D11ShaderResourceView_Release(view);
heap_free(gradient);
free(gradient);
return E_OUTOFMEMORY;
}
memcpy(gradient->stops, stops, stop_count * sizeof(*stops));
......@@ -236,7 +236,7 @@ static void d2d_gradient_bind(struct d2d_gradient *gradient, ID3D11Device1 *devi
static void d2d_brush_destroy(struct d2d_brush *brush)
{
ID2D1Factory_Release(brush->factory);
heap_free(brush);
free(brush);
}
static void d2d_brush_init(struct d2d_brush *brush, ID2D1Factory *factory,
......@@ -389,7 +389,7 @@ static const struct ID2D1SolidColorBrushVtbl d2d_solid_color_brush_vtbl =
HRESULT d2d_solid_color_brush_create(ID2D1Factory *factory, const D2D1_COLOR_F *color,
const D2D1_BRUSH_PROPERTIES *desc, struct d2d_brush **brush)
{
if (!(*brush = heap_alloc_zero(sizeof(**brush))))
if (!(*brush = calloc(1, sizeof(**brush))))
return E_OUTOFMEMORY;
d2d_brush_init(*brush, factory, D2D_BRUSH_TYPE_SOLID, desc,
......@@ -573,7 +573,7 @@ HRESULT d2d_linear_gradient_brush_create(ID2D1Factory *factory,
const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
ID2D1GradientStopCollection *gradient, struct d2d_brush **brush)
{
if (!(*brush = heap_alloc_zero(sizeof(**brush))))
if (!(*brush = calloc(1, sizeof(**brush))))
return E_OUTOFMEMORY;
d2d_brush_init(*brush, factory, D2D_BRUSH_TYPE_LINEAR, brush_desc,
......@@ -802,7 +802,7 @@ HRESULT d2d_radial_gradient_brush_create(ID2D1Factory *factory,
{
struct d2d_brush *b;
if (!(b = heap_alloc_zero(sizeof(*b))))
if (!(b = calloc(1, sizeof(*b))))
return E_OUTOFMEMORY;
d2d_brush_init(b, factory, D2D_BRUSH_TYPE_RADIAL, brush_desc, (ID2D1BrushVtbl *)&d2d_radial_gradient_brush_vtbl);
......@@ -1077,7 +1077,7 @@ HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap,
const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
struct d2d_brush **brush)
{
if (!(*brush = heap_alloc_zero(sizeof(**brush))))
if (!(*brush = calloc(1, sizeof(**brush))))
return E_OUTOFMEMORY;
d2d_brush_init(*brush, factory, D2D_BRUSH_TYPE_BITMAP,
......@@ -1324,7 +1324,7 @@ HRESULT d2d_image_brush_create(ID2D1Factory *factory, ID2D1Image *image,
const D2D1_IMAGE_BRUSH_PROPERTIES *image_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
struct d2d_brush **brush)
{
if (!(*brush = heap_alloc_zero(sizeof(**brush))))
if (!(*brush = calloc(1, sizeof(**brush))))
return E_OUTOFMEMORY;
d2d_brush_init(*brush, factory, D2D_BRUSH_TYPE_IMAGE,
......
......@@ -20,7 +20,6 @@
#define __WINE_D2D1_PRIVATE_H
#include "wine/debug.h"
#include "wine/heap.h"
#include <assert.h>
#include <limits.h>
......@@ -646,7 +645,7 @@ static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t c
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;
......
......@@ -99,7 +99,7 @@ static ULONG STDMETHODCALLTYPE d2d_dc_render_target_Release(ID2D1DCRenderTarget
if (render_target->dxgi_surface)
IDXGISurface1_Release(render_target->dxgi_surface);
ID3D10Device1_Release(render_target->d3d_device);
heap_free(render_target);
free(render_target);
}
return refcount;
......
......@@ -81,7 +81,7 @@ static void d2d_size_set(D2D1_SIZE_U *dst, float width, float height)
static BOOL d2d_clip_stack_init(struct d2d_clip_stack *stack)
{
if (!(stack->stack = heap_alloc(INITIAL_CLIP_STACK_SIZE * sizeof(*stack->stack))))
if (!(stack->stack = malloc(INITIAL_CLIP_STACK_SIZE * sizeof(*stack->stack))))
return FALSE;
stack->size = INITIAL_CLIP_STACK_SIZE;
......@@ -92,7 +92,7 @@ static BOOL d2d_clip_stack_init(struct d2d_clip_stack *stack)
static void d2d_clip_stack_cleanup(struct d2d_clip_stack *stack)
{
heap_free(stack->stack);
free(stack->stack);
}
static BOOL d2d_clip_stack_push(struct d2d_clip_stack *stack, const D2D1_RECT_F *rect)
......@@ -294,7 +294,7 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface)
ID3D11Device1_Release(context->d3d_device);
ID2D1Factory_Release(context->factory);
ID2D1Device_Release(context->device);
heap_free(context);
free(context);
}
return refcount;
......@@ -517,14 +517,14 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateCompatibleRenderTarget
TRACE("iface %p, size %p, pixel_size %p, format %p, options %#x, render_target %p.\n",
iface, size, pixel_size, format, options, rt);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_bitmap_render_target_init(object, render_target, size, pixel_size,
format, options)))
{
WARN("Failed to initialise render target, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -1345,7 +1345,7 @@ static void d2d_device_context_draw_glyph_run_bitmap(struct d2d_device_context *
if (texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1)
bitmap_size.width *= 3;
if (!(opacity_values = heap_calloc(bitmap_size.height, bitmap_size.width)))
if (!(opacity_values = calloc(bitmap_size.height, bitmap_size.width)))
{
ERR("Failed to allocate opacity values.\n");
goto done;
......@@ -1408,7 +1408,7 @@ done:
ID2D1BitmapBrush_Release(opacity_brush);
if (opacity_bitmap)
ID2D1Bitmap_Release(opacity_bitmap);
heap_free(opacity_values);
free(opacity_values);
IDWriteGlyphRunAnalysis_Release(analysis);
}
......@@ -1951,7 +1951,7 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateEffect(ID2D1DeviceCont
FIXME("iface %p, effect_id %s, effect %p stub!\n", iface, debugstr_guid(effect_id), effect);
if (!(effect_context = heap_alloc_zero(sizeof(*effect_context))))
if (!(effect_context = calloc(1, sizeof(*effect_context))))
return E_OUTOFMEMORY;
d2d_effect_context_init(effect_context, context);
......@@ -4202,13 +4202,13 @@ HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface,
else if (bitmap_desc.dpiX <= 0.0f || bitmap_desc.dpiY <= 0.0f)
return E_INVALIDARG;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_device_context_init(object, device, outer_unknown, ops)))
{
WARN("Failed to initialise render target, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -4225,7 +4225,7 @@ HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface,
{
WARN("Failed to create target bitmap, hr %#lx.\n", hr);
IUnknown_Release(&object->IUnknown_iface);
heap_free(object);
free(object);
return hr;
}
......@@ -4281,7 +4281,7 @@ static ULONG WINAPI d2d_device_Release(ID2D1Device *iface)
{
IDXGIDevice_Release(device->dxgi_device);
ID2D1Factory1_Release(device->factory);
heap_free(device);
free(device);
}
return refcount;
......@@ -4308,13 +4308,13 @@ static HRESULT WINAPI d2d_device_CreateDeviceContext(ID2D1Device *iface, D2D1_DE
if (options)
FIXME("Options are ignored %#x.\n", options);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_device_context_init(object, iface, NULL, NULL)))
{
WARN("Failed to initialise device context, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......
......@@ -41,7 +41,7 @@ static void d2d_effect_context_cleanup(struct d2d_effect_context *effect_context
for (i = 0; i < effect_context->shader_count; ++i)
IUnknown_Release(effect_context->shaders[i].shader);
heap_free(effect_context->shaders);
free(effect_context->shaders);
ID2D1DeviceContext1_Release(&effect_context->device_context->ID2D1DeviceContext1_iface);
}
......@@ -104,7 +104,7 @@ static ULONG STDMETHODCALLTYPE d2d_effect_context_Release(ID2D1EffectContext *if
if (!refcount)
{
d2d_effect_context_cleanup(effect_context);
heap_free(effect_context);
free(effect_context);
}
return refcount;
......@@ -128,13 +128,13 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_CreateEffect(ID2D1EffectCont
TRACE("iface %p, clsid %s, effect %p.\n", iface, debugstr_guid(clsid), effect);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_effect_init(object, effect_context, clsid)))
{
WARN("Failed to initialise effect, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -379,7 +379,7 @@ static void d2d_effect_cleanup(struct d2d_effect *effect)
if (effect->inputs[i])
ID2D1Image_Release(effect->inputs[i]);
}
heap_free(effect->inputs);
free(effect->inputs);
ID2D1EffectContext_Release(&effect->effect_context->ID2D1EffectContext_iface);
}
......@@ -431,7 +431,7 @@ static ULONG STDMETHODCALLTYPE d2d_effect_Release(ID2D1Effect *iface)
if (!refcount)
{
d2d_effect_cleanup(effect);
heap_free(effect);
free(effect);
}
return refcount;
......
......@@ -120,7 +120,7 @@ static ULONG STDMETHODCALLTYPE d2d_factory_Release(ID2D1Factory3 *iface)
if (factory->device)
ID3D10Device1_Release(factory->device);
DeleteCriticalSection(&factory->cs);
heap_free(factory);
free(factory);
}
return refcount;
......@@ -153,13 +153,13 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateRectangleGeometry(ID2D1Factor
TRACE("iface %p, rect %s, geometry %p.\n", iface, debug_d2d_rect_f(rect), geometry);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_rectangle_geometry_init(object, (ID2D1Factory *)iface, rect)))
{
WARN("Failed to initialise rectangle geometry, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -177,13 +177,13 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateRoundedRectangleGeometry(ID2D
TRACE("iface %p, rounded_rect %s, geometry %p.\n", iface, debug_d2d_rounded_rect(rounded_rect), geometry);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_rounded_rectangle_geometry_init(object, (ID2D1Factory *)iface, rounded_rect)))
{
WARN("Failed to initialise rounded rectangle geometry, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -201,13 +201,13 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateEllipseGeometry(ID2D1Factory3
TRACE("iface %p, ellipse %s, geometry %p.\n", iface, debug_d2d_ellipse(ellipse), geometry);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_ellipse_geometry_init(object, (ID2D1Factory *)iface, ellipse)))
{
WARN("Failed to initialise ellipse geometry, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -226,13 +226,13 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateGeometryGroup(ID2D1Factory3 *
TRACE("iface %p, fill_mode %#x, geometries %p, geometry_count %u, group %p.\n",
iface, fill_mode, geometries, geometry_count, group);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_geometry_group_init(object, (ID2D1Factory *)iface, fill_mode, geometries, geometry_count)))
{
WARN("Failed to initialise geometry group, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -251,7 +251,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateTransformedGeometry(ID2D1Fact
TRACE("iface %p, src_geometry %p, transform %p, transformed_geometry %p.\n",
iface, src_geometry, transform, transformed_geometry);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
d2d_transformed_geometry_init(object, (ID2D1Factory *)iface, src_geometry, transform);
......@@ -268,7 +268,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreatePathGeometry(ID2D1Factory3 *i
TRACE("iface %p, geometry %p.\n", iface, geometry);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
d2d_path_geometry_init(object, (ID2D1Factory *)iface);
......@@ -290,7 +290,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateStrokeStyle(ID2D1Factory3 *if
TRACE("iface %p, desc %p, dashes %p, dash_count %u, stroke_style %p.\n",
iface, desc, dashes, dash_count, stroke_style);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
desc1.startCap = desc->startCap;
......@@ -305,7 +305,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateStrokeStyle(ID2D1Factory3 *if
if (FAILED(hr = d2d_stroke_style_init(object, (ID2D1Factory *)iface, &desc1, dashes, dash_count)))
{
WARN("Failed to initialise stroke style, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -325,7 +325,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDrawingStateBlock(ID2D1Factor
TRACE("iface %p, desc %p, text_rendering_params %p, state_block %p.\n",
iface, desc, text_rendering_params, state_block);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (desc)
......@@ -365,19 +365,19 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateWicBitmapRenderTarget(ID2D1Fa
TRACE("iface %p, target %p, desc %p, render_target %p.\n", iface, target, desc, render_target);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_factory_get_device(factory, &device)))
{
heap_free(object);
free(object);
return hr;
}
if (FAILED(hr = d2d_wic_render_target_init(object, (ID2D1Factory1 *)iface, device, target, desc)))
{
WARN("Failed to initialise render target, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -401,13 +401,13 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateHwndRenderTarget(ID2D1Factory
if (FAILED(hr = d2d_factory_get_device(factory, &device)))
return hr;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_hwnd_render_target_init(object, (ID2D1Factory1 *)iface, device, desc, hwnd_rt_desc)))
{
WARN("Failed to initialise render target, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -458,13 +458,13 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDCRenderTarget(ID2D1Factory3
if (FAILED(hr = d2d_factory_get_device(factory, &device)))
return hr;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_dc_render_target_init(object, (ID2D1Factory1 *)iface, device, desc)))
{
WARN("Failed to initialise render target, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -481,7 +481,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDevice(ID2D1Factory3 *iface,
TRACE("iface %p, dxgi_device %p, device %p.\n", iface, dxgi_device, device);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
d2d_device_init(object, (ID2D1Factory1 *)iface, dxgi_device);
......@@ -502,14 +502,14 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateStrokeStyle1(ID2D1Factory3 *i
TRACE("iface %p, desc %p, dashes %p, dash_count %u, stroke_style %p.\n",
iface, desc, dashes, dash_count, stroke_style);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_stroke_style_init(object, (ID2D1Factory *)iface,
desc, dashes, dash_count)))
{
WARN("Failed to initialise stroke style, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -525,7 +525,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreatePathGeometry1(ID2D1Factory3 *
TRACE("iface %p, geometry %p.\n", iface, geometry);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
d2d_path_geometry_init(object, (ID2D1Factory *)iface);
......@@ -545,7 +545,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDrawingStateBlock1(ID2D1Facto
TRACE("iface %p, desc %p, text_rendering_params %p, state_block %p.\n",
iface, desc, text_rendering_params, state_block);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
d2d_state_block_init(object, (ID2D1Factory *)iface, desc, text_rendering_params);
......@@ -760,7 +760,7 @@ HRESULT WINAPI D2D1CreateFactory(D2D1_FACTORY_TYPE factory_type, REFIID iid,
return E_INVALIDARG;
}
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
d2d_factory_init(object, factory_type, factory_options);
......
......@@ -1679,7 +1679,7 @@ static BOOL d2d_cdt_generate_faces(const struct d2d_cdt *cdt, struct d2d_geometr
return TRUE;
fail:
heap_free(geometry->fill.faces);
free(geometry->fill.faces);
geometry->fill.faces = NULL;
geometry->fill.faces_size = 0;
geometry->fill.face_count = 0;
......@@ -2275,7 +2275,7 @@ static BOOL d2d_geometry_intersect_self(struct d2d_geometry *geometry)
ret = d2d_geometry_apply_intersections(geometry, &intersections);
done:
heap_free(intersections.intersections);
free(intersections.intersections);
return ret;
}
......@@ -2299,7 +2299,7 @@ static HRESULT d2d_path_geometry_triangulate(struct d2d_geometry *geometry)
return S_OK;
}
if (!(vertices = heap_calloc(vertex_count, sizeof(*vertices))))
if (!(vertices = calloc(vertex_count, sizeof(*vertices))))
return E_OUTOFMEMORY;
for (i = 0, j = 0; i < geometry->u.path.figure_count; ++i)
......@@ -2326,7 +2326,7 @@ static HRESULT d2d_path_geometry_triangulate(struct d2d_geometry *geometry)
if (vertex_count < 3)
{
WARN("Geometry has %lu vertices after eliminating duplicates.\n", (long)vertex_count);
heap_free(vertices);
free(vertices);
return S_OK;
}
......@@ -2342,14 +2342,14 @@ static HRESULT d2d_path_geometry_triangulate(struct d2d_geometry *geometry)
if (!d2d_cdt_generate_faces(&cdt, geometry))
goto fail;
heap_free(cdt.edges);
free(cdt.edges);
return S_OK;
fail:
geometry->fill.vertices = NULL;
geometry->fill.vertex_count = 0;
heap_free(vertices);
heap_free(cdt.edges);
free(vertices);
free(cdt.edges);
return E_FAIL;
}
......@@ -2702,16 +2702,16 @@ static BOOL d2d_geometry_fill_add_arc_triangle(struct d2d_geometry *geometry,
static void d2d_geometry_cleanup(struct d2d_geometry *geometry)
{
heap_free(geometry->outline.arc_faces);
heap_free(geometry->outline.arcs);
heap_free(geometry->outline.bezier_faces);
heap_free(geometry->outline.beziers);
heap_free(geometry->outline.faces);
heap_free(geometry->outline.vertices);
heap_free(geometry->fill.arc_vertices);
heap_free(geometry->fill.bezier_vertices);
heap_free(geometry->fill.faces);
heap_free(geometry->fill.vertices);
free(geometry->outline.arc_faces);
free(geometry->outline.arcs);
free(geometry->outline.bezier_faces);
free(geometry->outline.beziers);
free(geometry->outline.faces);
free(geometry->outline.vertices);
free(geometry->fill.arc_vertices);
free(geometry->fill.bezier_vertices);
free(geometry->fill.faces);
free(geometry->fill.vertices);
ID2D1Factory_Release(geometry->factory);
}
......@@ -2950,11 +2950,11 @@ static void d2d_path_geometry_free_figures(struct d2d_geometry *geometry)
for (i = 0; i < geometry->u.path.figure_count; ++i)
{
heap_free(geometry->u.path.figures[i].original_bezier_controls);
heap_free(geometry->u.path.figures[i].bezier_controls);
heap_free(geometry->u.path.figures[i].vertices);
free(geometry->u.path.figures[i].original_bezier_controls);
free(geometry->u.path.figures[i].bezier_controls);
free(geometry->u.path.figures[i].vertices);
}
heap_free(geometry->u.path.figures);
free(geometry->u.path.figures);
geometry->u.path.figures = NULL;
geometry->u.path.figures_size = 0;
}
......@@ -3160,7 +3160,7 @@ static HRESULT d2d_geometry_resolve_beziers(struct d2d_geometry *geometry)
geometry->fill.bezier_vertex_count += 3 * geometry->u.path.figures[i].bezier_control_count;
}
if (!(geometry->fill.bezier_vertices = heap_calloc(geometry->fill.bezier_vertex_count,
if (!(geometry->fill.bezier_vertices = calloc(geometry->fill.bezier_vertex_count,
sizeof(*geometry->fill.bezier_vertices))))
{
ERR("Failed to allocate bezier vertices array.\n");
......@@ -3230,7 +3230,7 @@ static HRESULT STDMETHODCALLTYPE d2d_geometry_sink_Close(ID2D1GeometrySink *ifac
done:
if (FAILED(hr))
{
heap_free(geometry->fill.bezier_vertices);
free(geometry->fill.bezier_vertices);
geometry->fill.bezier_vertex_count = 0;
d2d_path_geometry_free_figures(geometry);
geometry->u.path.state = D2D_GEOMETRY_STATE_ERROR;
......@@ -3401,7 +3401,7 @@ static ULONG STDMETHODCALLTYPE d2d_path_geometry_Release(ID2D1PathGeometry1 *ifa
{
d2d_path_geometry_free_figures(geometry);
d2d_geometry_cleanup(geometry);
heap_free(geometry);
free(geometry);
}
return refcount;
......@@ -4001,7 +4001,7 @@ static ULONG STDMETHODCALLTYPE d2d_ellipse_geometry_Release(ID2D1EllipseGeometry
if (!refcount)
{
d2d_geometry_cleanup(geometry);
heap_free(geometry);
free(geometry);
}
return refcount;
......@@ -4174,7 +4174,7 @@ HRESULT d2d_ellipse_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *f
d2d_geometry_init(geometry, factory, &identity, (ID2D1GeometryVtbl *)&d2d_ellipse_geometry_vtbl);
geometry->u.ellipse.ellipse = *ellipse;
if (!(geometry->fill.vertices = heap_alloc(4 * sizeof(*geometry->fill.vertices))))
if (!(geometry->fill.vertices = malloc(4 * sizeof(*geometry->fill.vertices))))
goto fail;
if (!d2d_array_reserve((void **)&geometry->fill.faces,
&geometry->fill.faces_size, 2, sizeof(*geometry->fill.faces)))
......@@ -4273,7 +4273,7 @@ static ULONG STDMETHODCALLTYPE d2d_rectangle_geometry_Release(ID2D1RectangleGeom
if (!refcount)
{
d2d_geometry_cleanup(geometry);
heap_free(geometry);
free(geometry);
}
return refcount;
......@@ -4595,7 +4595,7 @@ HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry, ID2D1Factory
d2d_geometry_init(geometry, factory, &identity, (ID2D1GeometryVtbl *)&d2d_rectangle_geometry_vtbl);
geometry->u.rectangle.rect = *rect;
if (!(geometry->fill.vertices = heap_alloc(4 * sizeof(*geometry->fill.vertices))))
if (!(geometry->fill.vertices = malloc(4 * sizeof(*geometry->fill.vertices))))
goto fail;
if (!d2d_array_reserve((void **)&geometry->fill.faces,
&geometry->fill.faces_size, 2, sizeof(*geometry->fill.faces)))
......@@ -4689,7 +4689,7 @@ static ULONG STDMETHODCALLTYPE d2d_rounded_rectangle_geometry_Release(ID2D1Round
if (!refcount)
{
d2d_geometry_cleanup(geometry);
heap_free(geometry);
free(geometry);
}
return refcount;
......@@ -4867,7 +4867,7 @@ HRESULT d2d_rounded_rectangle_geometry_init(struct d2d_geometry *geometry,
d2d_geometry_init(geometry, factory, &identity, (ID2D1GeometryVtbl *)&d2d_rounded_rectangle_geometry_vtbl);
geometry->u.rounded_rectangle.rounded_rect = *rounded_rect;
if (!(geometry->fill.vertices = heap_alloc(8 * sizeof(*geometry->fill.vertices))))
if (!(geometry->fill.vertices = malloc(8 * sizeof(*geometry->fill.vertices))))
goto fail;
if (!d2d_array_reserve((void **)&geometry->fill.faces,
&geometry->fill.faces_size, 6, sizeof(*geometry->fill.faces)))
......@@ -4996,7 +4996,7 @@ static ULONG STDMETHODCALLTYPE d2d_transformed_geometry_Release(ID2D1Transformed
geometry->fill.vertices = NULL;
ID2D1Geometry_Release(geometry->u.transformed.src_geometry);
d2d_geometry_cleanup(geometry);
heap_free(geometry);
free(geometry);
}
return refcount;
......@@ -5271,9 +5271,9 @@ static ULONG STDMETHODCALLTYPE d2d_geometry_group_Release(ID2D1GeometryGroup *if
{
for (i = 0; i < geometry->u.group.geometry_count; ++i)
ID2D1Geometry_Release(geometry->u.group.src_geometries[i]);
heap_free(geometry->u.group.src_geometries);
free(geometry->u.group.src_geometries);
d2d_geometry_cleanup(geometry);
heap_free(geometry);
free(geometry);
}
return refcount;
......@@ -5484,7 +5484,7 @@ HRESULT d2d_geometry_group_init(struct d2d_geometry *geometry, ID2D1Factory *fac
d2d_geometry_init(geometry, factory, &identity, (ID2D1GeometryVtbl *)&d2d_geometry_group_vtbl);
if (!(geometry->u.group.src_geometries = heap_calloc(geometry_count, sizeof(*geometries))))
if (!(geometry->u.group.src_geometries = calloc(geometry_count, sizeof(*geometries))))
{
d2d_geometry_cleanup(geometry);
return E_OUTOFMEMORY;
......
......@@ -83,7 +83,7 @@ static ULONG STDMETHODCALLTYPE d2d_hwnd_render_target_Release(ID2D1HwndRenderTar
{
IUnknown_Release(render_target->dxgi_inner);
IDXGISwapChain_Release(render_target->swapchain);
heap_free(render_target);
free(render_target);
}
return refcount;
......
......@@ -64,7 +64,7 @@ static ULONG STDMETHODCALLTYPE d2d_layer_Release(ID2D1Layer *iface)
if (!refcount)
{
ID2D1Factory_Release(layer->factory);
heap_free(layer);
free(layer);
}
return refcount;
......@@ -100,7 +100,7 @@ static const struct ID2D1LayerVtbl d2d_layer_vtbl =
HRESULT d2d_layer_create(ID2D1Factory *factory, const D2D1_SIZE_F *size, struct d2d_layer **layer)
{
if (!(*layer = heap_alloc_zero(sizeof(**layer))))
if (!(*layer = calloc(1, sizeof(**layer))))
return E_OUTOFMEMORY;
(*layer)->ID2D1Layer_iface.lpVtbl = &d2d_layer_vtbl;
......
......@@ -64,7 +64,7 @@ static ULONG STDMETHODCALLTYPE d2d_mesh_Release(ID2D1Mesh *iface)
if (!refcount)
{
ID2D1Factory_Release(mesh->factory);
heap_free(mesh);
free(mesh);
}
return refcount;
......@@ -97,7 +97,7 @@ static const struct ID2D1MeshVtbl d2d_mesh_vtbl =
HRESULT d2d_mesh_create(ID2D1Factory *factory, struct d2d_mesh **mesh)
{
if (!(*mesh = heap_alloc_zero(sizeof(**mesh))))
if (!(*mesh = calloc(1, sizeof(**mesh))))
return E_OUTOFMEMORY;
(*mesh)->ID2D1Mesh_iface.lpVtbl = &d2d_mesh_vtbl;
......
......@@ -67,7 +67,7 @@ static ULONG STDMETHODCALLTYPE d2d_state_block_Release(ID2D1DrawingStateBlock1 *
if (state_block->text_rendering_params)
IDWriteRenderingParams_Release(state_block->text_rendering_params);
ID2D1Factory_Release(state_block->factory);
heap_free(state_block);
free(state_block);
}
return refcount;
......
......@@ -65,8 +65,8 @@ static ULONG STDMETHODCALLTYPE d2d_stroke_style_Release(ID2D1StrokeStyle1 *iface
{
ID2D1Factory_Release(style->factory);
if (style->desc.dashStyle == D2D1_DASH_STYLE_CUSTOM)
heap_free(style->dashes);
heap_free(style);
free(style->dashes);
free(style);
}
return refcount;
......@@ -222,7 +222,7 @@ HRESULT d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *fact
if (!dashes || !dash_count)
return E_INVALIDARG;
if (!(style->dashes = heap_calloc(dash_count, sizeof(*style->dashes))))
if (!(style->dashes = calloc(dash_count, sizeof(*style->dashes))))
return E_OUTOFMEMORY;
memcpy(style->dashes, dashes, dash_count * sizeof(*style->dashes));
style->dash_count = dash_count;
......
......@@ -131,7 +131,7 @@ static ULONG STDMETHODCALLTYPE d2d_wic_render_target_Release(IUnknown *iface)
ID3D10Texture2D_Release(render_target->readback_texture);
IUnknown_Release(render_target->dxgi_inner);
IDXGISurface_Release(render_target->dxgi_surface);
heap_free(render_target);
free(render_target);
}
return refcount;
......
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