Commit 31250d6d authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Use the global memory allocation helpers.

parent c8dd71bb
......@@ -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 =
......
......@@ -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;
}
......
......@@ -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"
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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 =
......
......@@ -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;
......
......@@ -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 =
......
......@@ -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;
}
......
......@@ -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 =
......
......@@ -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;
}
......
......@@ -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 =
......
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