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