Commit 9a5b854e authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

d3d9: Use CRT allocation functions.

parent 6db89702
......@@ -266,7 +266,7 @@ static void STDMETHODCALLTYPE d3d9_vertexbuffer_wined3d_object_destroyed(void *p
if (buffer->draw_buffer)
wined3d_buffer_decref(buffer->wined3d_buffer);
d3d9_resource_cleanup(&buffer->resource);
heap_free(buffer);
free(buffer);
}
static const struct wined3d_parent_ops d3d9_vertexbuffer_wined3d_parent_ops =
......@@ -586,7 +586,7 @@ static void STDMETHODCALLTYPE d3d9_indexbuffer_wined3d_object_destroyed(void *pa
struct d3d9_indexbuffer *buffer = parent;
d3d9_resource_cleanup(&buffer->resource);
heap_free(buffer);
free(buffer);
}
static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops =
......
......@@ -38,13 +38,13 @@ IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
TRACE("sdk_version %#x.\n", sdk_version);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return NULL;
if (!d3d9_init(object, FALSE))
{
WARN("Failed to initialize d3d9.\n");
heap_free(object);
free(object);
return NULL;
}
......@@ -59,13 +59,13 @@ HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9E
TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (!d3d9_init(object, TRUE))
{
WARN("Failed to initialize d3d9.\n");
heap_free(object);
free(object);
return D3DERR_NOTAVAILABLE;
}
......
......@@ -32,7 +32,6 @@
#include "wingdi.h"
#include "winuser.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "d3d9.h"
#include "wine/wined3d.h"
......
......@@ -83,8 +83,8 @@ static ULONG WINAPI d3d9_Release(IDirect3D9Ex *iface)
{
wined3d_decref(d3d9->wined3d);
heap_free(d3d9->wined3d_outputs);
heap_free(d3d9);
free(d3d9->wined3d_outputs);
free(d3d9);
}
return refcount;
......@@ -489,14 +489,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDevice(IDirect3D9Ex *iface, U
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#lx, parameters %p, device %p.\n",
iface, adapter, device_type, focus_window, flags, parameters, device);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, NULL);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -610,14 +610,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDeviceEx(IDirect3D9Ex *iface,
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#lx, parameters %p, mode %p, device %p.\n",
iface, adapter, device_type, focus_window, flags, parameters, mode, device);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, mode);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -710,7 +710,7 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
output_count += wined3d_adapter_get_output_count(wined3d_adapter);
}
d3d9->wined3d_outputs = heap_calloc(output_count, sizeof(*d3d9->wined3d_outputs));
d3d9->wined3d_outputs = calloc(output_count, sizeof(*d3d9->wined3d_outputs));
if (!d3d9->wined3d_outputs)
{
wined3d_decref(d3d9->wined3d);
......
......@@ -78,7 +78,7 @@ static ULONG WINAPI d3d9_query_Release(IDirect3DQuery9 *iface)
{
wined3d_query_decref(query->wined3d_query);
IDirect3DDevice9Ex_Release(query->parent_device);
heap_free(query);
free(query);
}
return refcount;
}
......
......@@ -119,7 +119,7 @@ static const IDirect3DVertexShader9Vtbl d3d9_vertexshader_vtbl =
static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed(void *parent)
{
heap_free(parent);
free(parent);
}
static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops =
......@@ -262,7 +262,7 @@ static const IDirect3DPixelShader9Vtbl d3d9_pixelshader_vtbl =
static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed(void *parent)
{
heap_free(parent);
free(parent);
}
static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops =
......
......@@ -69,7 +69,7 @@ static ULONG WINAPI d3d9_stateblock_Release(IDirect3DStateBlock9 *iface)
wined3d_stateblock_decref(stateblock->wined3d_stateblock);
IDirect3DDevice9Ex_Release(stateblock->parent_device);
heap_free(stateblock);
free(stateblock);
}
return refcount;
......
......@@ -345,7 +345,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent)
{
struct d3d9_surface *surface = parent;
d3d9_resource_cleanup(&surface->resource);
heap_free(surface);
free(surface);
}
static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
......@@ -359,7 +359,7 @@ struct d3d9_surface *d3d9_surface_create(struct wined3d_texture *wined3d_texture
IDirect3DBaseTexture9 *texture;
struct d3d9_surface *surface;
if (!(surface = heap_alloc_zero(sizeof(*surface))))
if (!(surface = calloc(1, sizeof(*surface))))
return NULL;
surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl;
......
......@@ -348,7 +348,7 @@ static const struct IDirect3DSwapChain9ExVtbl d3d9_swapchain_vtbl =
static void STDMETHODCALLTYPE d3d9_swapchain_wined3d_object_released(void *parent)
{
heap_free(parent);
free(parent);
}
static const struct wined3d_parent_ops d3d9_swapchain_wined3d_parent_ops =
......@@ -399,13 +399,13 @@ HRESULT d3d9_swapchain_create(struct d3d9_device *device, struct wined3d_swapcha
unsigned int i;
HRESULT hr;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = swapchain_init(object, device, desc, swap_interval)))
{
WARN("Failed to initialize swapchain, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......
......@@ -1264,7 +1264,7 @@ static void STDMETHODCALLTYPE d3d9_texture_wined3d_object_destroyed(void *parent
if (texture->draw_texture)
wined3d_texture_decref(texture->wined3d_texture);
d3d9_resource_cleanup(&texture->resource);
heap_free(texture);
free(texture);
}
static const struct wined3d_parent_ops d3d9_texture_wined3d_parent_ops =
......
......@@ -88,7 +88,7 @@ HRESULT vdecl_convert_fvf(
has_psize + has_diffuse + has_specular + num_textures + 1;
/* convert the declaration */
if (!(elements = heap_alloc(size * sizeof(*elements))))
if (!(elements = malloc(size * sizeof(*elements))))
return D3DERR_OUTOFVIDEOMEMORY;
elements[size-1] = end_element;
......@@ -305,8 +305,8 @@ struct d3d9_vertex_declaration *unsafe_impl_from_IDirect3DVertexDeclaration9(IDi
static void STDMETHODCALLTYPE d3d9_vertexdeclaration_wined3d_object_destroyed(void *parent)
{
struct d3d9_vertex_declaration *declaration = parent;
heap_free(declaration->elements);
heap_free(declaration);
free(declaration->elements);
free(declaration);
}
static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops =
......@@ -333,7 +333,7 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem
/* Skip the END element */
--count;
if (!(*wined3d_elements = heap_alloc(count * sizeof(**wined3d_elements))))
if (!(*wined3d_elements = malloc(count * sizeof(**wined3d_elements))))
{
FIXME("Memory allocation failed\n");
return D3DERR_OUTOFVIDEOMEMORY;
......@@ -344,7 +344,7 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem
if (d3d9_elements[i].Type >= ARRAY_SIZE(d3d_dtype_lookup))
{
WARN("Invalid element type %#x.\n", d3d9_elements[i].Type);
heap_free(*wined3d_elements);
free(*wined3d_elements);
return E_FAIL;
}
(*wined3d_elements)[i].format = d3d_dtype_lookup[d3d9_elements[i].Type].format;
......@@ -384,9 +384,9 @@ static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration *declaratio
declaration->refcount = 1;
element_count = wined3d_element_count + 1;
if (!(declaration->elements = heap_alloc(element_count * sizeof(*declaration->elements))))
if (!(declaration->elements = malloc(element_count * sizeof(*declaration->elements))))
{
heap_free(wined3d_elements);
free(wined3d_elements);
ERR("Failed to allocate vertex declaration elements memory.\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
......@@ -397,10 +397,10 @@ static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration *declaratio
hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count,
declaration, &d3d9_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_declaration);
wined3d_mutex_unlock();
heap_free(wined3d_elements);
free(wined3d_elements);
if (FAILED(hr))
{
heap_free(declaration->elements);
free(declaration->elements);
WARN("Failed to create wined3d vertex declaration, hr %#lx.\n", hr);
if (hr == E_INVALIDARG)
hr = E_FAIL;
......@@ -419,14 +419,14 @@ HRESULT d3d9_vertex_declaration_create(struct d3d9_device *device,
struct d3d9_vertex_declaration *object;
HRESULT hr;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
hr = vertexdeclaration_init(object, device, elements);
if (FAILED(hr))
{
WARN("Failed to initialize vertex declaration, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......
......@@ -193,7 +193,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
{
struct d3d9_volume *volume = parent;
d3d9_resource_cleanup(&volume->resource);
heap_free(volume);
free(volume);
}
static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops =
......
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