Commit a70e3059 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

d3d8: Use CRT allocation functions.

parent f2d17347
...@@ -270,7 +270,7 @@ static void STDMETHODCALLTYPE d3d8_vertexbuffer_wined3d_object_destroyed(void *p ...@@ -270,7 +270,7 @@ static void STDMETHODCALLTYPE d3d8_vertexbuffer_wined3d_object_destroyed(void *p
if (buffer->draw_buffer) if (buffer->draw_buffer)
wined3d_buffer_decref(buffer->wined3d_buffer); wined3d_buffer_decref(buffer->wined3d_buffer);
d3d8_resource_cleanup(&buffer->resource); d3d8_resource_cleanup(&buffer->resource);
heap_free(buffer); free(buffer);
} }
static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops = static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops =
...@@ -588,7 +588,7 @@ static void STDMETHODCALLTYPE d3d8_indexbuffer_wined3d_object_destroyed(void *pa ...@@ -588,7 +588,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);
heap_free(buffer); free(buffer);
} }
static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops = static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops =
......
...@@ -40,13 +40,13 @@ IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version) ...@@ -40,13 +40,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 = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, 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");
heap_free(object); free(object);
return NULL; return NULL;
} }
...@@ -95,7 +95,7 @@ done: ...@@ -95,7 +95,7 @@ done:
if (!return_error) if (!return_error)
message = ""; message = "";
message_size = strlen(message) + 1; message_size = strlen(message) + 1;
if (errors && (*errors = heap_alloc(message_size))) if (errors && (*errors = malloc(message_size)))
memcpy(*errors, message, message_size); memcpy(*errors, message, message_size);
return hr; return hr;
...@@ -140,7 +140,7 @@ done: ...@@ -140,7 +140,7 @@ done:
if (!return_error) if (!return_error)
message = ""; message = "";
message_size = strlen(message) + 1; message_size = strlen(message) + 1;
if (errors && (*errors = heap_alloc(message_size))) if (errors && (*errors = malloc(message_size)))
memcpy(*errors, message, message_size); memcpy(*errors, message, message_size);
return hr; return hr;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#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"
......
...@@ -70,8 +70,8 @@ static ULONG WINAPI d3d8_Release(IDirect3D8 *iface) ...@@ -70,8 +70,8 @@ static ULONG WINAPI d3d8_Release(IDirect3D8 *iface)
wined3d_decref(d3d8->wined3d); wined3d_decref(d3d8->wined3d);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
heap_free(d3d8->wined3d_outputs); free(d3d8->wined3d_outputs);
heap_free(d3d8); free(d3d8);
} }
return refcount; return refcount;
...@@ -432,14 +432,14 @@ static HRESULT WINAPI d3d8_CreateDevice(IDirect3D8 *iface, UINT adapter, ...@@ -432,14 +432,14 @@ static HRESULT WINAPI d3d8_CreateDevice(IDirect3D8 *iface, UINT adapter,
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#lx, parameters %p, device %p.\n", 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); 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; 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 %#lx.\n", hr); WARN("Failed to initialize device, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -498,7 +498,7 @@ BOOL d3d8_init(struct d3d8 *d3d8) ...@@ -498,7 +498,7 @@ BOOL d3d8_init(struct d3d8 *d3d8)
output_count += wined3d_adapter_get_output_count(wined3d_adapter); output_count += wined3d_adapter_get_output_count(wined3d_adapter);
} }
d3d8->wined3d_outputs = heap_calloc(output_count, sizeof(*d3d8->wined3d_outputs)); d3d8->wined3d_outputs = calloc(output_count, sizeof(*d3d8->wined3d_outputs));
if (!d3d8->wined3d_outputs) if (!d3d8->wined3d_outputs)
{ {
wined3d_decref(d3d8->wined3d); wined3d_decref(d3d8->wined3d);
......
...@@ -25,7 +25,7 @@ static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *p ...@@ -25,7 +25,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);
heap_free(shader); free(shader);
} }
void d3d8_vertex_shader_destroy(struct d3d8_vertex_shader *shader) void d3d8_vertex_shader_destroy(struct d3d8_vertex_shader *shader)
...@@ -58,14 +58,14 @@ static HRESULT d3d8_vertexshader_create_vertexdeclaration(struct d3d8_device *de ...@@ -58,14 +58,14 @@ static HRESULT d3d8_vertexshader_create_vertexdeclaration(struct d3d8_device *de
TRACE("device %p, declaration %p, shader_handle %#lx, decl_ptr %p.\n", TRACE("device %p, declaration %p, shader_handle %#lx, decl_ptr %p.\n",
device, declaration, shader_handle, decl_ptr); device, declaration, shader_handle, decl_ptr);
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*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 %#lx.\n", hr); WARN("Failed to initialize vertex declaration, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
...@@ -136,7 +136,7 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, struct d3d8_d ...@@ -136,7 +136,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)
{ {
heap_free(parent); free(parent);
} }
void d3d8_pixel_shader_destroy(struct d3d8_pixel_shader *shader) void d3d8_pixel_shader_destroy(struct d3d8_pixel_shader *shader)
......
...@@ -307,7 +307,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent) ...@@ -307,7 +307,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);
heap_free(surface); free(surface);
} }
static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops = static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops =
...@@ -321,7 +321,7 @@ struct d3d8_surface *d3d8_surface_create(struct wined3d_texture *wined3d_texture ...@@ -321,7 +321,7 @@ struct d3d8_surface *d3d8_surface_create(struct wined3d_texture *wined3d_texture
IDirect3DBaseTexture8 *texture; IDirect3DBaseTexture8 *texture;
struct d3d8_surface *surface; struct d3d8_surface *surface;
if (!(surface = heap_alloc_zero(sizeof(*surface)))) if (!(surface = calloc(1, sizeof(*surface))))
return NULL; return NULL;
surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl; surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl;
......
...@@ -148,7 +148,7 @@ static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl = ...@@ -148,7 +148,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)
{ {
heap_free(parent); free(parent);
} }
static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops = static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops =
...@@ -199,13 +199,13 @@ HRESULT d3d8_swapchain_create(struct d3d8_device *device, struct wined3d_swapcha ...@@ -199,13 +199,13 @@ HRESULT d3d8_swapchain_create(struct d3d8_device *device, struct wined3d_swapcha
unsigned int i; unsigned int i;
HRESULT hr; HRESULT hr;
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (FAILED(hr = swapchain_init(object, device, desc, swap_interval))) if (FAILED(hr = swapchain_init(object, device, desc, swap_interval)))
{ {
WARN("Failed to initialize swapchain, hr %#lx.\n", hr); WARN("Failed to initialize swapchain, hr %#lx.\n", hr);
heap_free(object); free(object);
return hr; return hr;
} }
......
...@@ -1041,7 +1041,7 @@ static void STDMETHODCALLTYPE d3d8_texture_wined3d_object_destroyed(void *parent ...@@ -1041,7 +1041,7 @@ static void STDMETHODCALLTYPE d3d8_texture_wined3d_object_destroyed(void *parent
if (texture->draw_texture) if (texture->draw_texture)
wined3d_texture_decref(texture->wined3d_texture); wined3d_texture_decref(texture->wined3d_texture);
d3d8_resource_cleanup(&texture->resource); d3d8_resource_cleanup(&texture->resource);
heap_free(texture); free(texture);
} }
static const struct wined3d_parent_ops d3d8_texture_wined3d_parent_ops = static const struct wined3d_parent_ops d3d8_texture_wined3d_parent_ops =
......
...@@ -261,7 +261,7 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3 ...@@ -261,7 +261,7 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3
*stream_map = 0; *stream_map = 0;
/* 128 should be enough for anyone... */ /* 128 should be enough for anyone... */
*wined3d_elements = heap_alloc_zero(128 * sizeof(**wined3d_elements)); *wined3d_elements = calloc(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);
...@@ -311,8 +311,8 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3 ...@@ -311,8 +311,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;
heap_free(declaration->elements); free(declaration->elements);
heap_free(declaration); free(declaration);
} }
void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration) void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration)
...@@ -338,10 +338,10 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration ...@@ -338,10 +338,10 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration
wined3d_element_count = convert_to_wined3d_declaration(elements, &declaration->elements_size, wined3d_element_count = convert_to_wined3d_declaration(elements, &declaration->elements_size,
&wined3d_elements, &declaration->stream_map); &wined3d_elements, &declaration->stream_map);
if (!(declaration->elements = heap_alloc(declaration->elements_size))) if (!(declaration->elements = malloc(declaration->elements_size)))
{ {
ERR("Failed to allocate vertex declaration elements memory.\n"); ERR("Failed to allocate vertex declaration elements memory.\n");
heap_free(wined3d_elements); free(wined3d_elements);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -351,11 +351,11 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration ...@@ -351,11 +351,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();
heap_free(wined3d_elements); free(wined3d_elements);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to create wined3d vertex declaration, hr %#lx.\n", hr); WARN("Failed to create wined3d vertex declaration, hr %#lx.\n", hr);
heap_free(declaration->elements); free(declaration->elements);
if (hr == E_INVALIDARG) if (hr == E_INVALIDARG)
hr = E_FAIL; hr = E_FAIL;
return hr; return hr;
......
...@@ -192,7 +192,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent) ...@@ -192,7 +192,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);
heap_free(volume); 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