d3d9: Use the global memory allocation helpers.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-02-07 02:11:32 +03:30 committed by Alexandre Julliard
parent c8dd71bbc4
commit 31250d6d4d
13 changed files with 70 additions and 87 deletions

View File

@ -263,7 +263,7 @@ static void STDMETHODCALLTYPE d3d9_vertexbuffer_wined3d_object_destroyed(void *p
{
struct d3d9_vertexbuffer *buffer = parent;
d3d9_resource_cleanup(&buffer->resource);
HeapFree(GetProcessHeap(), 0, buffer);
heap_free(buffer);
}
static const struct wined3d_parent_ops d3d9_vertexbuffer_wined3d_parent_ops =
@ -553,7 +553,7 @@ static void STDMETHODCALLTYPE d3d9_indexbuffer_wined3d_object_destroyed(void *pa
{
struct d3d9_indexbuffer *buffer = parent;
d3d9_resource_cleanup(&buffer->resource);
HeapFree(GetProcessHeap(), 0, buffer);
heap_free(buffer);
}
static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops =

View File

@ -39,13 +39,13 @@ IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
TRACE("sdk_version %#x.\n", sdk_version);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return NULL;
if (!d3d9_init(object, FALSE))
{
WARN("Failed to initialize d3d9.\n");
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return NULL;
}
@ -60,13 +60,13 @@ HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9E
TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (!d3d9_init(object, TRUE))
{
WARN("Failed to initialize d3d9.\n");
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return D3DERR_NOTAVAILABLE;
}

View File

@ -34,6 +34,7 @@
#include "wingdi.h"
#include "winuser.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/unicode.h"
#include "d3d9.h"

View File

@ -480,14 +480,14 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if
{
wined3d_vertex_declaration_decref(device->fvf_decls[i].decl);
}
HeapFree(GetProcessHeap(), 0, device->fvf_decls);
heap_free(device->fvf_decls);
if (device->vertex_buffer)
wined3d_buffer_decref(device->vertex_buffer);
if (device->index_buffer)
wined3d_buffer_decref(device->index_buffer);
HeapFree(GetProcessHeap(), 0, device->implicit_swapchains);
heap_free(device->implicit_swapchains);
wined3d_device_uninit_3d(device->wined3d_device);
wined3d_device_release_focus_window(device->wined3d_device);
@ -496,7 +496,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if
IDirect3D9Ex_Release(&device->d3d_parent->IDirect3D9Ex_iface);
HeapFree(GetProcessHeap(), 0, device);
heap_free(device);
}
return refcount;
@ -796,8 +796,7 @@ static HRESULT d3d9_device_get_swapchains(struct d3d9_device *device)
UINT i, new_swapchain_count = wined3d_device_get_swapchain_count(device->wined3d_device);
struct wined3d_swapchain *wined3d_swapchain;
if (!(device->implicit_swapchains = HeapAlloc(GetProcessHeap(), 0,
new_swapchain_count * sizeof(*device->implicit_swapchains))))
if (!(device->implicit_swapchains = heap_alloc(new_swapchain_count * sizeof(*device->implicit_swapchains))))
return E_OUTOFMEMORY;
for (i = 0; i < new_swapchain_count; ++i)
@ -855,7 +854,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc,
mode ? &wined3d_mode : NULL, reset_enum_callback, !extended)))
{
HeapFree(GetProcessHeap(), 0, device->implicit_swapchains);
heap_free(device->implicit_swapchains);
if (!extended)
{
@ -1051,15 +1050,14 @@ static HRESULT WINAPI d3d9_device_CreateTexture(IDirect3DDevice9Ex *iface,
}
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = texture_init(object, device, width, height, levels, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize texture, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -1104,15 +1102,14 @@ static HRESULT WINAPI d3d9_device_CreateVolumeTexture(IDirect3DDevice9Ex *iface,
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = volumetexture_init(object, device, width, height, depth, levels, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize volume texture, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -1150,15 +1147,14 @@ static HRESULT WINAPI d3d9_device_CreateCubeTexture(IDirect3DDevice9Ex *iface,
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = cubetexture_init(object, device, edge_length, levels, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize cube texture, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -1195,15 +1191,14 @@ static HRESULT WINAPI d3d9_device_CreateVertexBuffer(IDirect3DDevice9Ex *iface,
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = vertexbuffer_init(object, device, size, usage, fvf, pool);
if (FAILED(hr))
{
WARN("Failed to initialize vertex buffer, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -1240,15 +1235,14 @@ static HRESULT WINAPI d3d9_device_CreateIndexBuffer(IDirect3DDevice9Ex *iface, U
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = indexbuffer_init(object, device, size, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize index buffer, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -2107,15 +2101,14 @@ static HRESULT WINAPI d3d9_device_CreateStateBlock(IDirect3DDevice9Ex *iface,
return D3DERR_INVALIDCALL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = stateblock_init(object, device, type, NULL);
if (FAILED(hr))
{
WARN("Failed to initialize stateblock, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -2157,8 +2150,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire
return hr;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
{
wined3d_mutex_lock();
wined3d_stateblock_decref(wined3d_stateblock);
@ -2173,7 +2165,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire
wined3d_mutex_lock();
wined3d_stateblock_decref(wined3d_stateblock);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -2897,7 +2889,7 @@ static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9
return NULL;
hr = d3d9_vertex_declaration_create(device, elements, &d3d9_declaration);
HeapFree(GetProcessHeap(), 0, elements);
heap_free(elements);
if (FAILED(hr))
return NULL;
@ -2905,8 +2897,7 @@ static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9
{
UINT grow = max(device->fvf_decl_size / 2, 8);
fvf_decls = HeapReAlloc(GetProcessHeap(), 0, fvf_decls, sizeof(*fvf_decls) * (device->fvf_decl_size + grow));
if (!fvf_decls)
if (!(fvf_decls = heap_realloc(fvf_decls, sizeof(*fvf_decls) * (device->fvf_decl_size + grow))))
{
IDirect3DVertexDeclaration9_Release(&d3d9_declaration->IDirect3DVertexDeclaration9_iface);
return NULL;
@ -2992,15 +2983,14 @@ static HRESULT WINAPI d3d9_device_CreateVertexShader(IDirect3DDevice9Ex *iface,
TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = vertexshader_init(object, device, byte_code);
if (FAILED(hr))
{
WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -3290,8 +3280,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface,
TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
{
FIXME("Failed to allocate pixel shader memory.\n");
return E_OUTOFMEMORY;
@ -3301,7 +3290,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface,
if (FAILED(hr))
{
WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -3478,15 +3467,14 @@ static HRESULT WINAPI d3d9_device_CreateQuery(IDirect3DDevice9Ex *iface, D3DQUER
TRACE("iface %p, type %#x, query %p.\n", iface, type, query);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = query_init(object, device, type);
if (FAILED(hr))
{
WARN("Failed to initialize query, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -3915,7 +3903,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
if (!(d3d_surface = heap_alloc_zero(sizeof(*d3d_surface))))
return E_OUTOFMEMORY;
surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops);
@ -3934,7 +3922,7 @@ static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *
TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume))))
if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume))))
return E_OUTOFMEMORY;
volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops);
@ -4085,8 +4073,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
}
}
swapchain_desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*swapchain_desc) * count);
if (!swapchain_desc)
if (!(swapchain_desc = heap_alloc(sizeof(*swapchain_desc) * count)))
{
ERR("Failed to allocate wined3d parameters.\n");
wined3d_device_release_focus_window(device->wined3d_device);
@ -4102,7 +4089,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);
HeapFree(GetProcessHeap(), 0, swapchain_desc);
heap_free(swapchain_desc);
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
@ -4112,7 +4099,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
{
WARN("Failed to initialize 3D, hr %#x.\n", hr);
wined3d_device_release_focus_window(device->wined3d_device);
HeapFree(GetProcessHeap(), 0, swapchain_desc);
heap_free(swapchain_desc);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
return hr;
@ -4137,16 +4124,15 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, swapchain_desc);
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. */
device->fvf_decls = HeapAlloc(GetProcessHeap(), 0, 0);
if (!device->fvf_decls)
if (!(device->fvf_decls = heap_alloc(0)))
{
ERR("Failed to allocate FVF vertex declaration map memory.\n");
wined3d_mutex_lock();
HeapFree(GetProcessHeap(), 0, device->implicit_swapchains);
heap_free(device->implicit_swapchains);
wined3d_device_uninit_3d(device->wined3d_device);
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);

View File

@ -86,7 +86,7 @@ static ULONG WINAPI d3d9_Release(IDirect3D9Ex *iface)
wined3d_decref(d3d9->wined3d);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, d3d9);
heap_free(d3d9);
}
return refcount;
@ -400,15 +400,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDevice(IDirect3D9Ex *iface, U
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n",
iface, adapter, device_type, focus_window, flags, parameters, device);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(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 %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
@ -508,15 +507,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDeviceEx(IDirect3D9Ex *iface,
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, mode %p, device %p.\n",
iface, adapter, device_type, focus_window, flags, parameters, mode, device);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(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 %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}

View File

@ -72,7 +72,7 @@ static ULONG WINAPI d3d9_query_Release(IDirect3DQuery9 *iface)
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(query->parent_device);
HeapFree(GetProcessHeap(), 0, query);
heap_free(query);
}
return refcount;
}

View File

@ -126,7 +126,7 @@ static const IDirect3DVertexShader9Vtbl d3d9_vertexshader_vtbl =
static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed(void *parent)
{
HeapFree(GetProcessHeap(), 0, parent);
heap_free(parent);
}
static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops =
@ -280,7 +280,7 @@ static const IDirect3DPixelShader9Vtbl d3d9_pixelshader_vtbl =
static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed(void *parent)
{
HeapFree(GetProcessHeap(), 0, parent);
heap_free(parent);
}
static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops =

View File

@ -72,7 +72,7 @@ static ULONG WINAPI d3d9_stateblock_Release(IDirect3DStateBlock9 *iface)
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(stateblock->parent_device);
HeapFree(GetProcessHeap(), 0, stateblock);
heap_free(stateblock);
}
return refcount;

View File

@ -340,7 +340,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent)
{
struct d3d9_surface *surface = parent;
d3d9_resource_cleanup(&surface->resource);
HeapFree(GetProcessHeap(), 0, surface);
heap_free(surface);
}
static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =

View File

@ -335,7 +335,7 @@ static const struct IDirect3DSwapChain9ExVtbl d3d9_swapchain_vtbl =
static void STDMETHODCALLTYPE d3d9_swapchain_wined3d_object_released(void *parent)
{
HeapFree(GetProcessHeap(), 0, parent);
heap_free(parent);
}
static const struct wined3d_parent_ops d3d9_swapchain_wined3d_parent_ops =
@ -374,13 +374,13 @@ HRESULT d3d9_swapchain_create(struct d3d9_device *device, struct wined3d_swapcha
struct d3d9_swapchain *object;
HRESULT hr;
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = swapchain_init(object, device, desc)))
{
WARN("Failed to initialize swapchain, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}

View File

@ -1195,7 +1195,7 @@ static void STDMETHODCALLTYPE d3d9_texture_wined3d_object_destroyed(void *parent
{
struct d3d9_texture *texture = parent;
d3d9_resource_cleanup(&texture->resource);
HeapFree(GetProcessHeap(), 0, texture);
heap_free(texture);
}
static const struct wined3d_parent_ops d3d9_texture_wined3d_parent_ops =

View File

@ -89,8 +89,8 @@ HRESULT vdecl_convert_fvf(
has_psize + has_diffuse + has_specular + num_textures + 1;
/* convert the declaration */
elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(D3DVERTEXELEMENT9));
if (!elements) return D3DERR_OUTOFVIDEOMEMORY;
if (!(elements = heap_alloc(size * sizeof(*elements))))
return D3DERR_OUTOFVIDEOMEMORY;
elements[size-1] = end_element;
idx = 0;
@ -310,8 +310,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;
HeapFree(GetProcessHeap(), 0, declaration->elements);
HeapFree(GetProcessHeap(), 0, declaration);
heap_free(declaration->elements);
heap_free(declaration);
}
static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops =
@ -336,8 +336,8 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem
/* Skip the END element */
--count;
*wined3d_elements = HeapAlloc(GetProcessHeap(), 0, count * sizeof(**wined3d_elements));
if (!*wined3d_elements) {
if (!(*wined3d_elements = heap_alloc(count * sizeof(**wined3d_elements))))
{
FIXME("Memory allocation failed\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
@ -347,7 +347,7 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem
if (d3d9_elements[i].Type >= (sizeof(d3d_dtype_lookup) / sizeof(*d3d_dtype_lookup)))
{
WARN("Invalid element type %#x.\n", d3d9_elements[i].Type);
HeapFree(GetProcessHeap(), 0, *wined3d_elements);
heap_free(*wined3d_elements);
return E_FAIL;
}
(*wined3d_elements)[i].format = d3d_dtype_lookup[d3d9_elements[i].Type].format;
@ -385,10 +385,9 @@ static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration *declaratio
declaration->refcount = 1;
element_count = wined3d_element_count + 1;
declaration->elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(*declaration->elements));
if (!declaration->elements)
if (!(declaration->elements = heap_alloc(element_count * sizeof(*declaration->elements))))
{
HeapFree(GetProcessHeap(), 0, wined3d_elements);
heap_free(wined3d_elements);
ERR("Failed to allocate vertex declaration elements memory.\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
@ -399,10 +398,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();
HeapFree(GetProcessHeap(), 0, wined3d_elements);
heap_free(wined3d_elements);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, declaration->elements);
heap_free(declaration->elements);
WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr);
return hr;
}
@ -419,15 +418,14 @@ HRESULT d3d9_vertex_declaration_create(struct d3d9_device *device,
struct d3d9_vertex_declaration *object;
HRESULT hr;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = vertexdeclaration_init(object, device, elements);
if (FAILED(hr))
{
WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}

View File

@ -195,7 +195,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
{
struct d3d9_volume *volume = parent;
d3d9_resource_cleanup(&volume->resource);
HeapFree(GetProcessHeap(), 0, volume);
heap_free(volume);
}
static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops =