-- v2: d3d9: Use CRT allocation functions.
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/d3d9/buffer.c | 4 +- dlls/d3d9/d3d9_main.c | 8 ++-- dlls/d3d9/d3d9_private.h | 1 - dlls/d3d9/device.c | 80 +++++++++++++++-------------------- dlls/d3d9/directx.c | 14 +++--- dlls/d3d9/query.c | 2 +- dlls/d3d9/shader.c | 4 +- dlls/d3d9/stateblock.c | 2 +- dlls/d3d9/surface.c | 4 +- dlls/d3d9/swapchain.c | 6 +-- dlls/d3d9/texture.c | 2 +- dlls/d3d9/vertexdeclaration.c | 22 +++++----- dlls/d3d9/volume.c | 2 +- 13 files changed, 68 insertions(+), 83 deletions(-)
diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index 822b2c00df3..73190cb9dd6 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -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 = diff --git a/dlls/d3d9/d3d9_main.c b/dlls/d3d9/d3d9_main.c index 5b525c97ff3..5bdf05409aa 100644 --- a/dlls/d3d9/d3d9_main.c +++ b/dlls/d3d9/d3d9_main.c @@ -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; }
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index 6ade2e69a4f..fcd82d2e674 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -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" diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 0a031f854af..1eeefac6cc0 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -661,7 +661,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if { 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->index_buffer); @@ -670,7 +670,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if { wined3d_swapchain_decref(device->implicit_swapchains[i]); } - heap_free(device->implicit_swapchains); + free(device->implicit_swapchains);
if (device->recording) wined3d_stateblock_decref(device->recording); @@ -682,7 +682,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if
IDirect3D9Ex_Release(&device->d3d_parent->IDirect3D9Ex_iface);
- heap_free(device); + free(device); }
return refcount; @@ -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);
- 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;
for (i = 0; i < new_swapchain_count; ++i) @@ -1137,7 +1137,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device, { struct d3d9_surface *surface;
- heap_free(device->implicit_swapchains); + free(device->implicit_swapchains);
if (!extended) { @@ -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;
hr = d3d9_texture_2d_init(object, device, width, height, levels, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize texture, hr %#lx.\n", hr); - heap_free(object); + free(object); return hr; }
@@ -1469,14 +1469,14 @@ static HRESULT WINAPI d3d9_device_CreateVolumeTexture(IDirect3DDevice9Ex *iface, 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;
hr = d3d9_texture_3d_init(object, device, width, height, depth, levels, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize volume texture, hr %#lx.\n", hr); - heap_free(object); + free(object); return hr; }
@@ -1515,14 +1515,14 @@ static HRESULT WINAPI d3d9_device_CreateCubeTexture(IDirect3DDevice9Ex *iface, 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;
hr = d3d9_texture_cube_init(object, device, edge_length, levels, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize cube texture, hr %#lx.\n", hr); - heap_free(object); + free(object); return hr; }
@@ -1569,14 +1569,14 @@ static HRESULT WINAPI d3d9_device_CreateVertexBuffer(IDirect3DDevice9Ex *iface, 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;
hr = vertexbuffer_init(object, device, size, usage, fvf, pool); if (FAILED(hr)) { WARN("Failed to initialize vertex buffer, hr %#lx.\n", hr); - heap_free(object); + free(object); return hr; }
@@ -1613,14 +1613,14 @@ static HRESULT WINAPI d3d9_device_CreateIndexBuffer(IDirect3DDevice9Ex *iface, U 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;
hr = indexbuffer_init(object, device, size, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize index buffer, hr %#lx.\n", hr); - heap_free(object); + free(object); return hr; }
@@ -2591,14 +2591,14 @@ static HRESULT WINAPI d3d9_device_CreateStateBlock(IDirect3DDevice9Ex *iface, } wined3d_mutex_unlock();
- if (!(object = heap_alloc_zero(sizeof(*object)))) + if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
hr = stateblock_init(object, device, type, NULL); if (FAILED(hr)) { WARN("Failed to initialize stateblock, hr %#lx.\n", hr); - heap_free(object); + free(object); return hr; }
@@ -2653,7 +2653,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire device->update_state = device->state; wined3d_mutex_unlock();
- if (!(object = heap_alloc_zero(sizeof(*object)))) + if (!(object = calloc(1, sizeof(*object)))) { wined3d_stateblock_decref(wined3d_stateblock); return E_OUTOFMEMORY; @@ -2664,7 +2664,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire { WARN("Failed to initialize stateblock, hr %#lx.\n", hr); wined3d_stateblock_decref(wined3d_stateblock); - heap_free(object); + free(object); return hr; }
@@ -3499,7 +3499,7 @@ static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9 return NULL;
hr = d3d9_vertex_declaration_create(device, elements, &d3d9_declaration); - heap_free(elements); + free(elements); if (FAILED(hr)) return NULL;
@@ -3507,7 +3507,7 @@ static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9 { 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); return NULL; @@ -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);
- if (!(object = heap_alloc_zero(sizeof(*object)))) + if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
hr = vertexshader_init(object, device, byte_code); if (FAILED(hr)) { WARN("Failed to initialize vertex shader, hr %#lx.\n", hr); - heap_free(object); + free(object); return hr; }
@@ -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);
- if (!(object = heap_alloc_zero(sizeof(*object)))) + if (!(object = calloc(1, sizeof(*object)))) { FIXME("Failed to allocate pixel shader memory.\n"); return E_OUTOFMEMORY; @@ -3933,7 +3933,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface, if (FAILED(hr)) { WARN("Failed to initialize pixel shader, hr %#lx.\n", hr); - heap_free(object); + free(object); return hr; }
@@ -4108,14 +4108,14 @@ static HRESULT WINAPI d3d9_device_CreateQuery(IDirect3DDevice9Ex *iface, D3DQUER
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;
hr = query_init(object, device, type); if (FAILED(hr)) { WARN("Failed to initialize query, hr %#lx.\n", hr); - heap_free(object); + free(object); return hr; }
@@ -4574,7 +4574,7 @@ static HRESULT CDECL device_parent_texture_sub_resource_created(struct wined3d_d { 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;
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 } }
- if (!(swapchain_desc = heap_alloc(sizeof(*swapchain_desc) * count))) + if (!(swapchain_desc = malloc(sizeof(*swapchain_desc) * count))) { ERR("Failed to allocate wined3d parameters.\n"); wined3d_device_release_focus_window(device->wined3d_device); @@ -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_decref(device->wined3d_device); - heap_free(swapchain_desc); + free(swapchain_desc); wined3d_mutex_unlock(); return D3DERR_INVALIDCALL; } @@ -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); wined3d_device_release_focus_window(device->wined3d_device); - heap_free(swapchain_desc); + free(swapchain_desc); wined3d_device_decref(device->wined3d_device); wined3d_mutex_unlock(); return hr; @@ -4749,7 +4749,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine wined3d_swapchain_decref(d3d_swapchain->wined3d_swapchain); wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_decref(device->wined3d_device); - heap_free(swapchain_desc); + free(swapchain_desc); wined3d_mutex_unlock(); return E_OUTOFMEMORY; } @@ -4762,21 +4762,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
wined3d_mutex_unlock();
- heap_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; - } + free(swapchain_desc);
/* 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 diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c index 3dc7ff6da53..d5b8e276075 100644 --- a/dlls/d3d9/directx.c +++ b/dlls/d3d9/directx.c @@ -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); diff --git a/dlls/d3d9/query.c b/dlls/d3d9/query.c index f419f8b173e..37ec8591f13 100644 --- a/dlls/d3d9/query.c +++ b/dlls/d3d9/query.c @@ -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; } diff --git a/dlls/d3d9/shader.c b/dlls/d3d9/shader.c index 7ae8868541c..267d8502d6c 100644 --- a/dlls/d3d9/shader.c +++ b/dlls/d3d9/shader.c @@ -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 = diff --git a/dlls/d3d9/stateblock.c b/dlls/d3d9/stateblock.c index 76299877b89..18d3a108093 100644 --- a/dlls/d3d9/stateblock.c +++ b/dlls/d3d9/stateblock.c @@ -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; diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index f0cc36da3a1..1ea8c60a4fd 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -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; diff --git a/dlls/d3d9/swapchain.c b/dlls/d3d9/swapchain.c index 0c8b12dce91..26c47f2c6ec 100644 --- a/dlls/d3d9/swapchain.c +++ b/dlls/d3d9/swapchain.c @@ -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; }
diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index 3adfaaee2f3..285c7961333 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -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 = diff --git a/dlls/d3d9/vertexdeclaration.c b/dlls/d3d9/vertexdeclaration.c index acfcc6e0b48..7efd9b30c45 100644 --- a/dlls/d3d9/vertexdeclaration.c +++ b/dlls/d3d9/vertexdeclaration.c @@ -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; }
diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index f8b23804ee6..63fac84c923 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -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 =
This merge request was approved by Jan Sikorski.