Commit 4b086877 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d8: Use the global memory allocation helpers.

parent 6187de01
......@@ -262,7 +262,7 @@ static void STDMETHODCALLTYPE d3d8_vertexbuffer_wined3d_object_destroyed(void *p
{
struct d3d8_vertexbuffer *buffer = parent;
d3d8_resource_cleanup(&buffer->resource);
HeapFree(GetProcessHeap(), 0, buffer);
heap_free(buffer);
}
static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops =
......@@ -558,7 +558,7 @@ static void STDMETHODCALLTYPE d3d8_indexbuffer_wined3d_object_destroyed(void *pa
{
struct d3d8_indexbuffer *buffer = parent;
d3d8_resource_cleanup(&buffer->resource);
HeapFree(GetProcessHeap(), 0, buffer);
heap_free(buffer);
}
static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops =
......
......@@ -41,13 +41,13 @@ IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(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 (!d3d8_init(object))
{
WARN("Failed to initialize d3d8.\n");
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return NULL;
}
......
......@@ -33,6 +33,7 @@
#include "winbase.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "d3d8.h"
#include "wine/wined3d.h"
......
......@@ -81,7 +81,7 @@ static ULONG WINAPI d3d8_Release(IDirect3D8 *iface)
wined3d_decref(d3d8->wined3d);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, d3d8);
heap_free(d3d8);
}
return refcount;
......@@ -373,15 +373,14 @@ static HRESULT WINAPI d3d8_CreateDevice(IDirect3D8 *iface, UINT adapter,
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, d3d8, d3d8->wined3d, adapter, device_type, focus_window, flags, parameters);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
......
......@@ -26,7 +26,7 @@ static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *p
{
struct d3d8_vertex_shader *shader = parent;
d3d8_vertex_declaration_destroy(shader->vertex_declaration);
HeapFree(GetProcessHeap(), 0, shader);
heap_free(shader);
}
void d3d8_vertex_shader_destroy(struct d3d8_vertex_shader *shader)
......@@ -59,15 +59,14 @@ static HRESULT d3d8_vertexshader_create_vertexdeclaration(struct d3d8_device *de
TRACE("device %p, declaration %p, shader_handle %#x, decl_ptr %p.\n",
device, declaration, shader_handle, decl_ptr);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = d3d8_vertex_declaration_init(object, device, declaration, shader_handle);
if (FAILED(hr))
{
WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
......@@ -143,7 +142,7 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, struct d3d8_d
static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent)
{
HeapFree(GetProcessHeap(), 0, parent);
heap_free(parent);
}
void d3d8_pixel_shader_destroy(struct d3d8_pixel_shader *shader)
......
......@@ -306,7 +306,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent)
{
struct d3d8_surface *surface = parent;
d3d8_resource_cleanup(&surface->resource);
HeapFree(GetProcessHeap(), 0, surface);
heap_free(surface);
}
static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops =
......
......@@ -158,7 +158,7 @@ static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl =
static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released(void *parent)
{
HeapFree(GetProcessHeap(), 0, parent);
heap_free(parent);
}
static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops =
......@@ -197,13 +197,13 @@ HRESULT d3d8_swapchain_create(struct d3d8_device *device, struct wined3d_swapcha
struct d3d8_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;
}
......
......@@ -1083,7 +1083,7 @@ static void STDMETHODCALLTYPE d3d8_texture_wined3d_object_destroyed(void *parent
{
struct d3d8_texture *texture = parent;
d3d8_resource_cleanup(&texture->resource);
HeapFree(GetProcessHeap(), 0, texture);
heap_free(texture);
}
static const struct wined3d_parent_ops d3d8_texture_wined3d_parent_ops =
......
......@@ -266,7 +266,7 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3
TRACE("d3d8_elements %p, d3d8_elements_size %p, wined3d_elements %p\n", d3d8_elements, d3d8_elements_size, wined3d_elements);
/* 128 should be enough for anyone... */
*wined3d_elements = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 128 * sizeof(**wined3d_elements));
*wined3d_elements = heap_alloc_zero(128 * sizeof(**wined3d_elements));
while (D3DVSD_END() != *token)
{
token_type = ((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT);
......@@ -314,8 +314,8 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3
static void STDMETHODCALLTYPE d3d8_vertexdeclaration_wined3d_object_destroyed(void *parent)
{
struct d3d8_vertex_declaration *declaration = parent;
HeapFree(GetProcessHeap(), 0, declaration->elements);
HeapFree(GetProcessHeap(), 0, declaration);
heap_free(declaration->elements);
heap_free(declaration);
}
void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration)
......@@ -342,11 +342,10 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration
declaration->shader_handle = shader_handle;
wined3d_element_count = convert_to_wined3d_declaration(elements, &declaration->elements_size, &wined3d_elements);
declaration->elements = HeapAlloc(GetProcessHeap(), 0, declaration->elements_size);
if (!declaration->elements)
if (!(declaration->elements = heap_alloc(declaration->elements_size)))
{
ERR("Failed to allocate vertex declaration elements memory.\n");
HeapFree(GetProcessHeap(), 0, wined3d_elements);
heap_free(wined3d_elements);
return E_OUTOFMEMORY;
}
......@@ -356,11 +355,11 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration
hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count,
declaration, &d3d8_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_vertex_declaration);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, wined3d_elements);
heap_free(wined3d_elements);
if (FAILED(hr))
{
WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, declaration->elements);
heap_free(declaration->elements);
return hr;
}
......
......@@ -195,7 +195,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
{
struct d3d8_volume *volume = parent;
d3d8_resource_cleanup(&volume->resource);
HeapFree(GetProcessHeap(), 0, volume);
heap_free(volume);
}
static const struct wined3d_parent_ops d3d8_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