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 ...@@ -266,7 +266,7 @@ static void STDMETHODCALLTYPE d3d9_vertexbuffer_wined3d_object_destroyed(void *p
if (buffer->draw_buffer) if (buffer->draw_buffer)
wined3d_buffer_decref(buffer->wined3d_buffer); wined3d_buffer_decref(buffer->wined3d_buffer);
d3d9_resource_cleanup(&buffer->resource); d3d9_resource_cleanup(&buffer->resource);
heap_free(buffer); free(buffer);
} }
static const struct wined3d_parent_ops d3d9_vertexbuffer_wined3d_parent_ops = 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 ...@@ -586,7 +586,7 @@ static void STDMETHODCALLTYPE d3d9_indexbuffer_wined3d_object_destroyed(void *pa
struct d3d9_indexbuffer *buffer = parent; struct d3d9_indexbuffer *buffer = parent;
d3d9_resource_cleanup(&buffer->resource); d3d9_resource_cleanup(&buffer->resource);
heap_free(buffer); free(buffer);
} }
static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops = static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops =
......
...@@ -38,13 +38,13 @@ IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version) ...@@ -38,13 +38,13 @@ IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
TRACE("sdk_version %#x.\n", sdk_version); TRACE("sdk_version %#x.\n", sdk_version);
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return NULL; return NULL;
if (!d3d9_init(object, FALSE)) if (!d3d9_init(object, FALSE))
{ {
WARN("Failed to initialize d3d9.\n"); WARN("Failed to initialize d3d9.\n");
heap_free(object); free(object);
return NULL; return NULL;
} }
...@@ -59,13 +59,13 @@ HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9E ...@@ -59,13 +59,13 @@ HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9E
TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex); 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; return E_OUTOFMEMORY;
if (!d3d9_init(object, TRUE)) if (!d3d9_init(object, TRUE))
{ {
WARN("Failed to initialize d3d9.\n"); WARN("Failed to initialize d3d9.\n");
heap_free(object); free(object);
return D3DERR_NOTAVAILABLE; return D3DERR_NOTAVAILABLE;
} }
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
#include "d3d9.h" #include "d3d9.h"
#include "wine/wined3d.h" #include "wine/wined3d.h"
......
...@@ -661,7 +661,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if ...@@ -661,7 +661,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if
{ {
wined3d_vertex_declaration_decref(device->fvf_decls[i].decl); wined3d_vertex_declaration_decref(device->fvf_decls[i].decl);
} }
heap_free(device->fvf_decls); free(device->fvf_decls);
wined3d_streaming_buffer_cleanup(&device->vertex_buffer); wined3d_streaming_buffer_cleanup(&device->vertex_buffer);
wined3d_streaming_buffer_cleanup(&device->index_buffer); wined3d_streaming_buffer_cleanup(&device->index_buffer);
...@@ -670,7 +670,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if ...@@ -670,7 +670,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if
{ {
wined3d_swapchain_decref(device->implicit_swapchains[i]); wined3d_swapchain_decref(device->implicit_swapchains[i]);
} }
heap_free(device->implicit_swapchains); free(device->implicit_swapchains);
if (device->recording) if (device->recording)
wined3d_stateblock_decref(device->recording); wined3d_stateblock_decref(device->recording);
...@@ -682,7 +682,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if ...@@ -682,7 +682,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if
IDirect3D9Ex_Release(&device->d3d_parent->IDirect3D9Ex_iface); IDirect3D9Ex_Release(&device->d3d_parent->IDirect3D9Ex_iface);
heap_free(device); free(device);
} }
return refcount; return refcount;
...@@ -1030,7 +1030,7 @@ static HRESULT d3d9_device_get_swapchains(struct d3d9_device *device) ...@@ -1030,7 +1030,7 @@ static HRESULT d3d9_device_get_swapchains(struct d3d9_device *device)
{ {
UINT i, new_swapchain_count = wined3d_device_get_swapchain_count(device->wined3d_device); UINT i, new_swapchain_count = wined3d_device_get_swapchain_count(device->wined3d_device);
if (!(device->implicit_swapchains = heap_alloc(new_swapchain_count * sizeof(*device->implicit_swapchains)))) if (!(device->implicit_swapchains = malloc(new_swapchain_count * sizeof(*device->implicit_swapchains))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for (i = 0; i < new_swapchain_count; ++i) for (i = 0; i < new_swapchain_count; ++i)
...@@ -1137,7 +1137,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device, ...@@ -1137,7 +1137,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
{ {
struct d3d9_surface *surface; struct d3d9_surface *surface;
heap_free(device->implicit_swapchains); free(device->implicit_swapchains);
if (!extended) if (!extended)
{ {
...@@ -1405,14 +1405,14 @@ static HRESULT WINAPI d3d9_device_CreateTexture(IDirect3DDevice9Ex *iface, ...@@ -1405,14 +1405,14 @@ static HRESULT WINAPI d3d9_device_CreateTexture(IDirect3DDevice9Ex *iface,
} }
} }
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
hr = d3d9_texture_2d_init(object, device, width, height, levels, usage, format, pool); hr = d3d9_texture_2d_init(object, device, width, height, levels, usage, format, pool);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize texture, hr %#lx.\n", hr); WARN("Failed to initialize texture, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -1469,14 +1469,14 @@ static HRESULT WINAPI d3d9_device_CreateVolumeTexture(IDirect3DDevice9Ex *iface, ...@@ -1469,14 +1469,14 @@ static HRESULT WINAPI d3d9_device_CreateVolumeTexture(IDirect3DDevice9Ex *iface,
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle); FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
} }
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
hr = d3d9_texture_3d_init(object, device, width, height, depth, levels, usage, format, pool); hr = d3d9_texture_3d_init(object, device, width, height, depth, levels, usage, format, pool);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize volume texture, hr %#lx.\n", hr); WARN("Failed to initialize volume texture, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -1515,14 +1515,14 @@ static HRESULT WINAPI d3d9_device_CreateCubeTexture(IDirect3DDevice9Ex *iface, ...@@ -1515,14 +1515,14 @@ static HRESULT WINAPI d3d9_device_CreateCubeTexture(IDirect3DDevice9Ex *iface,
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle); FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
} }
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
hr = d3d9_texture_cube_init(object, device, edge_length, levels, usage, format, pool); hr = d3d9_texture_cube_init(object, device, edge_length, levels, usage, format, pool);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize cube texture, hr %#lx.\n", hr); WARN("Failed to initialize cube texture, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -1569,14 +1569,14 @@ static HRESULT WINAPI d3d9_device_CreateVertexBuffer(IDirect3DDevice9Ex *iface, ...@@ -1569,14 +1569,14 @@ static HRESULT WINAPI d3d9_device_CreateVertexBuffer(IDirect3DDevice9Ex *iface,
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle); FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
} }
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
hr = vertexbuffer_init(object, device, size, usage, fvf, pool); hr = vertexbuffer_init(object, device, size, usage, fvf, pool);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize vertex buffer, hr %#lx.\n", hr); WARN("Failed to initialize vertex buffer, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -1613,14 +1613,14 @@ static HRESULT WINAPI d3d9_device_CreateIndexBuffer(IDirect3DDevice9Ex *iface, U ...@@ -1613,14 +1613,14 @@ static HRESULT WINAPI d3d9_device_CreateIndexBuffer(IDirect3DDevice9Ex *iface, U
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle); FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
} }
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
hr = indexbuffer_init(object, device, size, usage, format, pool); hr = indexbuffer_init(object, device, size, usage, format, pool);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize index buffer, hr %#lx.\n", hr); WARN("Failed to initialize index buffer, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -2591,14 +2591,14 @@ static HRESULT WINAPI d3d9_device_CreateStateBlock(IDirect3DDevice9Ex *iface, ...@@ -2591,14 +2591,14 @@ static HRESULT WINAPI d3d9_device_CreateStateBlock(IDirect3DDevice9Ex *iface,
} }
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
hr = stateblock_init(object, device, type, NULL); hr = stateblock_init(object, device, type, NULL);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize stateblock, hr %#lx.\n", hr); WARN("Failed to initialize stateblock, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -2653,7 +2653,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire ...@@ -2653,7 +2653,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire
device->update_state = device->state; device->update_state = device->state;
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
{ {
wined3d_stateblock_decref(wined3d_stateblock); wined3d_stateblock_decref(wined3d_stateblock);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -2664,7 +2664,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire ...@@ -2664,7 +2664,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire
{ {
WARN("Failed to initialize stateblock, hr %#lx.\n", hr); WARN("Failed to initialize stateblock, hr %#lx.\n", hr);
wined3d_stateblock_decref(wined3d_stateblock); wined3d_stateblock_decref(wined3d_stateblock);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -3499,7 +3499,7 @@ static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9 ...@@ -3499,7 +3499,7 @@ static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9
return NULL; return NULL;
hr = d3d9_vertex_declaration_create(device, elements, &d3d9_declaration); hr = d3d9_vertex_declaration_create(device, elements, &d3d9_declaration);
heap_free(elements); free(elements);
if (FAILED(hr)) if (FAILED(hr))
return NULL; return NULL;
...@@ -3507,7 +3507,7 @@ static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9 ...@@ -3507,7 +3507,7 @@ static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9
{ {
UINT grow = max(device->fvf_decl_size / 2, 8); UINT grow = max(device->fvf_decl_size / 2, 8);
if (!(fvf_decls = heap_realloc(fvf_decls, sizeof(*fvf_decls) * (device->fvf_decl_size + grow)))) if (!(fvf_decls = realloc(fvf_decls, sizeof(*fvf_decls) * (device->fvf_decl_size + grow))))
{ {
IDirect3DVertexDeclaration9_Release(&d3d9_declaration->IDirect3DVertexDeclaration9_iface); IDirect3DVertexDeclaration9_Release(&d3d9_declaration->IDirect3DVertexDeclaration9_iface);
return NULL; return NULL;
...@@ -3592,14 +3592,14 @@ static HRESULT WINAPI d3d9_device_CreateVertexShader(IDirect3DDevice9Ex *iface, ...@@ -3592,14 +3592,14 @@ static HRESULT WINAPI d3d9_device_CreateVertexShader(IDirect3DDevice9Ex *iface,
TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader); TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
hr = vertexshader_init(object, device, byte_code); hr = vertexshader_init(object, device, byte_code);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize vertex shader, hr %#lx.\n", hr); WARN("Failed to initialize vertex shader, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -3923,7 +3923,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface, ...@@ -3923,7 +3923,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface,
TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader); TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
{ {
FIXME("Failed to allocate pixel shader memory.\n"); FIXME("Failed to allocate pixel shader memory.\n");
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -3933,7 +3933,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface, ...@@ -3933,7 +3933,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface,
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize pixel shader, hr %#lx.\n", hr); WARN("Failed to initialize pixel shader, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -4108,14 +4108,14 @@ static HRESULT WINAPI d3d9_device_CreateQuery(IDirect3DDevice9Ex *iface, D3DQUER ...@@ -4108,14 +4108,14 @@ static HRESULT WINAPI d3d9_device_CreateQuery(IDirect3DDevice9Ex *iface, D3DQUER
TRACE("iface %p, type %#x, query %p.\n", iface, type, query); TRACE("iface %p, type %#x, query %p.\n", iface, type, query);
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
hr = query_init(object, device, type); hr = query_init(object, device, type);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize query, hr %#lx.\n", hr); WARN("Failed to initialize query, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -4574,7 +4574,7 @@ static HRESULT CDECL device_parent_texture_sub_resource_created(struct wined3d_d ...@@ -4574,7 +4574,7 @@ static HRESULT CDECL device_parent_texture_sub_resource_created(struct wined3d_d
{ {
struct d3d9_volume *d3d_volume; struct d3d9_volume *d3d_volume;
if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume)))) if (!(d3d_volume = calloc(1, sizeof(*d3d_volume))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops); volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops);
...@@ -4701,7 +4701,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine ...@@ -4701,7 +4701,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
} }
} }
if (!(swapchain_desc = heap_alloc(sizeof(*swapchain_desc) * count))) if (!(swapchain_desc = malloc(sizeof(*swapchain_desc) * count)))
{ {
ERR("Failed to allocate wined3d parameters.\n"); ERR("Failed to allocate wined3d parameters.\n");
wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_release_focus_window(device->wined3d_device);
...@@ -4717,7 +4717,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine ...@@ -4717,7 +4717,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
{ {
wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device); wined3d_device_decref(device->wined3d_device);
heap_free(swapchain_desc); free(swapchain_desc);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
...@@ -4731,7 +4731,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine ...@@ -4731,7 +4731,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
{ {
WARN("Failed to create swapchain, hr %#lx.\n", hr); WARN("Failed to create swapchain, hr %#lx.\n", hr);
wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_release_focus_window(device->wined3d_device);
heap_free(swapchain_desc); free(swapchain_desc);
wined3d_device_decref(device->wined3d_device); wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
...@@ -4749,7 +4749,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine ...@@ -4749,7 +4749,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
wined3d_swapchain_decref(d3d_swapchain->wined3d_swapchain); wined3d_swapchain_decref(d3d_swapchain->wined3d_swapchain);
wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device); wined3d_device_decref(device->wined3d_device);
heap_free(swapchain_desc); free(swapchain_desc);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -4762,21 +4762,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine ...@@ -4762,21 +4762,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
wined3d_mutex_unlock(); wined3d_mutex_unlock();
heap_free(swapchain_desc); free(swapchain_desc);
/* Initialize the converted declaration array. This creates a valid pointer
* and when adding decls HeapReAlloc() can be used without further checking. */
if (!(device->fvf_decls = heap_alloc(0)))
{
ERR("Failed to allocate FVF vertex declaration map memory.\n");
wined3d_mutex_lock();
heap_free(device->implicit_swapchains);
wined3d_swapchain_decref(d3d_swapchain->wined3d_swapchain);
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
return E_OUTOFMEMORY;
}
/* We could also simply ignore the initial rendertarget since it's known /* We could also simply ignore the initial rendertarget since it's known
* not to be a texture (we currently use these only for automatic mipmap * not to be a texture (we currently use these only for automatic mipmap
......
...@@ -83,8 +83,8 @@ static ULONG WINAPI d3d9_Release(IDirect3D9Ex *iface) ...@@ -83,8 +83,8 @@ static ULONG WINAPI d3d9_Release(IDirect3D9Ex *iface)
{ {
wined3d_decref(d3d9->wined3d); wined3d_decref(d3d9->wined3d);
heap_free(d3d9->wined3d_outputs); free(d3d9->wined3d_outputs);
heap_free(d3d9); free(d3d9);
} }
return refcount; return refcount;
...@@ -489,14 +489,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDevice(IDirect3D9Ex *iface, U ...@@ -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", 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); 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; return E_OUTOFMEMORY;
hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, NULL); hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, NULL);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize device, hr %#lx.\n", hr); WARN("Failed to initialize device, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -610,14 +610,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDeviceEx(IDirect3D9Ex *iface, ...@@ -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", 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); 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; return E_OUTOFMEMORY;
hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, mode); hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, mode);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize device, hr %#lx.\n", hr); WARN("Failed to initialize device, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -710,7 +710,7 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended) ...@@ -710,7 +710,7 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
output_count += wined3d_adapter_get_output_count(wined3d_adapter); 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) if (!d3d9->wined3d_outputs)
{ {
wined3d_decref(d3d9->wined3d); wined3d_decref(d3d9->wined3d);
......
...@@ -78,7 +78,7 @@ static ULONG WINAPI d3d9_query_Release(IDirect3DQuery9 *iface) ...@@ -78,7 +78,7 @@ static ULONG WINAPI d3d9_query_Release(IDirect3DQuery9 *iface)
{ {
wined3d_query_decref(query->wined3d_query); wined3d_query_decref(query->wined3d_query);
IDirect3DDevice9Ex_Release(query->parent_device); IDirect3DDevice9Ex_Release(query->parent_device);
heap_free(query); free(query);
} }
return refcount; return refcount;
} }
......
...@@ -119,7 +119,7 @@ static const IDirect3DVertexShader9Vtbl d3d9_vertexshader_vtbl = ...@@ -119,7 +119,7 @@ static const IDirect3DVertexShader9Vtbl d3d9_vertexshader_vtbl =
static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed(void *parent) 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 = static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops =
...@@ -262,7 +262,7 @@ static const IDirect3DPixelShader9Vtbl d3d9_pixelshader_vtbl = ...@@ -262,7 +262,7 @@ static const IDirect3DPixelShader9Vtbl d3d9_pixelshader_vtbl =
static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed(void *parent) 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 = static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops =
......
...@@ -69,7 +69,7 @@ static ULONG WINAPI d3d9_stateblock_Release(IDirect3DStateBlock9 *iface) ...@@ -69,7 +69,7 @@ static ULONG WINAPI d3d9_stateblock_Release(IDirect3DStateBlock9 *iface)
wined3d_stateblock_decref(stateblock->wined3d_stateblock); wined3d_stateblock_decref(stateblock->wined3d_stateblock);
IDirect3DDevice9Ex_Release(stateblock->parent_device); IDirect3DDevice9Ex_Release(stateblock->parent_device);
heap_free(stateblock); free(stateblock);
} }
return refcount; return refcount;
......
...@@ -345,7 +345,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent) ...@@ -345,7 +345,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent)
{ {
struct d3d9_surface *surface = parent; struct d3d9_surface *surface = parent;
d3d9_resource_cleanup(&surface->resource); d3d9_resource_cleanup(&surface->resource);
heap_free(surface); free(surface);
} }
static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops = 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 ...@@ -359,7 +359,7 @@ struct d3d9_surface *d3d9_surface_create(struct wined3d_texture *wined3d_texture
IDirect3DBaseTexture9 *texture; IDirect3DBaseTexture9 *texture;
struct d3d9_surface *surface; struct d3d9_surface *surface;
if (!(surface = heap_alloc_zero(sizeof(*surface)))) if (!(surface = calloc(1, sizeof(*surface))))
return NULL; return NULL;
surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl; surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl;
......
...@@ -348,7 +348,7 @@ static const struct IDirect3DSwapChain9ExVtbl d3d9_swapchain_vtbl = ...@@ -348,7 +348,7 @@ static const struct IDirect3DSwapChain9ExVtbl d3d9_swapchain_vtbl =
static void STDMETHODCALLTYPE d3d9_swapchain_wined3d_object_released(void *parent) 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 = 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 ...@@ -399,13 +399,13 @@ HRESULT d3d9_swapchain_create(struct d3d9_device *device, struct wined3d_swapcha
unsigned int i; unsigned int i;
HRESULT hr; HRESULT hr;
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (FAILED(hr = swapchain_init(object, device, desc, swap_interval))) if (FAILED(hr = swapchain_init(object, device, desc, swap_interval)))
{ {
WARN("Failed to initialize swapchain, hr %#lx.\n", hr); WARN("Failed to initialize swapchain, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
......
...@@ -1264,7 +1264,7 @@ static void STDMETHODCALLTYPE d3d9_texture_wined3d_object_destroyed(void *parent ...@@ -1264,7 +1264,7 @@ static void STDMETHODCALLTYPE d3d9_texture_wined3d_object_destroyed(void *parent
if (texture->draw_texture) if (texture->draw_texture)
wined3d_texture_decref(texture->wined3d_texture); wined3d_texture_decref(texture->wined3d_texture);
d3d9_resource_cleanup(&texture->resource); d3d9_resource_cleanup(&texture->resource);
heap_free(texture); free(texture);
} }
static const struct wined3d_parent_ops d3d9_texture_wined3d_parent_ops = static const struct wined3d_parent_ops d3d9_texture_wined3d_parent_ops =
......
...@@ -88,7 +88,7 @@ HRESULT vdecl_convert_fvf( ...@@ -88,7 +88,7 @@ HRESULT vdecl_convert_fvf(
has_psize + has_diffuse + has_specular + num_textures + 1; has_psize + has_diffuse + has_specular + num_textures + 1;
/* convert the declaration */ /* convert the declaration */
if (!(elements = heap_alloc(size * sizeof(*elements)))) if (!(elements = malloc(size * sizeof(*elements))))
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
elements[size-1] = end_element; elements[size-1] = end_element;
...@@ -305,8 +305,8 @@ struct d3d9_vertex_declaration *unsafe_impl_from_IDirect3DVertexDeclaration9(IDi ...@@ -305,8 +305,8 @@ struct d3d9_vertex_declaration *unsafe_impl_from_IDirect3DVertexDeclaration9(IDi
static void STDMETHODCALLTYPE d3d9_vertexdeclaration_wined3d_object_destroyed(void *parent) static void STDMETHODCALLTYPE d3d9_vertexdeclaration_wined3d_object_destroyed(void *parent)
{ {
struct d3d9_vertex_declaration *declaration = parent; struct d3d9_vertex_declaration *declaration = parent;
heap_free(declaration->elements); free(declaration->elements);
heap_free(declaration); free(declaration);
} }
static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops = 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 ...@@ -333,7 +333,7 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem
/* Skip the END element */ /* Skip the END element */
--count; --count;
if (!(*wined3d_elements = heap_alloc(count * sizeof(**wined3d_elements)))) if (!(*wined3d_elements = malloc(count * sizeof(**wined3d_elements))))
{ {
FIXME("Memory allocation failed\n"); FIXME("Memory allocation failed\n");
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
...@@ -344,7 +344,7 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem ...@@ -344,7 +344,7 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem
if (d3d9_elements[i].Type >= ARRAY_SIZE(d3d_dtype_lookup)) if (d3d9_elements[i].Type >= ARRAY_SIZE(d3d_dtype_lookup))
{ {
WARN("Invalid element type %#x.\n", d3d9_elements[i].Type); WARN("Invalid element type %#x.\n", d3d9_elements[i].Type);
heap_free(*wined3d_elements); free(*wined3d_elements);
return E_FAIL; return E_FAIL;
} }
(*wined3d_elements)[i].format = d3d_dtype_lookup[d3d9_elements[i].Type].format; (*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 ...@@ -384,9 +384,9 @@ static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration *declaratio
declaration->refcount = 1; declaration->refcount = 1;
element_count = wined3d_element_count + 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"); ERR("Failed to allocate vertex declaration elements memory.\n");
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
} }
...@@ -397,10 +397,10 @@ static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration *declaratio ...@@ -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, hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count,
declaration, &d3d9_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_declaration); declaration, &d3d9_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_declaration);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
heap_free(wined3d_elements); free(wined3d_elements);
if (FAILED(hr)) if (FAILED(hr))
{ {
heap_free(declaration->elements); free(declaration->elements);
WARN("Failed to create wined3d vertex declaration, hr %#lx.\n", hr); WARN("Failed to create wined3d vertex declaration, hr %#lx.\n", hr);
if (hr == E_INVALIDARG) if (hr == E_INVALIDARG)
hr = E_FAIL; hr = E_FAIL;
...@@ -419,14 +419,14 @@ HRESULT d3d9_vertex_declaration_create(struct d3d9_device *device, ...@@ -419,14 +419,14 @@ HRESULT d3d9_vertex_declaration_create(struct d3d9_device *device,
struct d3d9_vertex_declaration *object; struct d3d9_vertex_declaration *object;
HRESULT hr; HRESULT hr;
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
hr = vertexdeclaration_init(object, device, elements); hr = vertexdeclaration_init(object, device, elements);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize vertex declaration, hr %#lx.\n", hr); WARN("Failed to initialize vertex declaration, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
......
...@@ -193,7 +193,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent) ...@@ -193,7 +193,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
{ {
struct d3d9_volume *volume = parent; struct d3d9_volume *volume = parent;
d3d9_resource_cleanup(&volume->resource); d3d9_resource_cleanup(&volume->resource);
heap_free(volume); free(volume);
} }
static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops = 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