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
if (buffer->draw_buffer)
wined3d_buffer_decref(buffer->wined3d_buffer);
d3d8_resource_cleanup(&buffer->resource);
heap_free(buffer);
free(buffer);
}
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
struct d3d8_indexbuffer *buffer = parent;
d3d8_resource_cleanup(&buffer->resource);
heap_free(buffer);
free(buffer);
}
static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops =
......
......@@ -40,13 +40,13 @@ IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version)
TRACE("sdk_version %#x.\n", sdk_version);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return NULL;
if (!d3d8_init(object))
{
WARN("Failed to initialize d3d8.\n");
heap_free(object);
free(object);
return NULL;
}
......@@ -95,7 +95,7 @@ done:
if (!return_error)
message = "";
message_size = strlen(message) + 1;
if (errors && (*errors = heap_alloc(message_size)))
if (errors && (*errors = malloc(message_size)))
memcpy(*errors, message, message_size);
return hr;
......@@ -140,7 +140,7 @@ done:
if (!return_error)
message = "";
message_size = strlen(message) + 1;
if (errors && (*errors = heap_alloc(message_size)))
if (errors && (*errors = malloc(message_size)))
memcpy(*errors, message, message_size);
return hr;
......
......@@ -31,7 +31,6 @@
#include "winbase.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "d3d8.h"
#include "wine/wined3d.h"
......
......@@ -494,7 +494,7 @@ static DWORD d3d8_allocate_handle(struct d3d8_handle_table *t, void *object, enu
UINT new_size = t->table_size + (t->table_size >> 1);
struct d3d8_handle_entry *new_entries;
if (!(new_entries = heap_realloc(t->entries, new_size * sizeof(*t->entries))))
if (!(new_entries = realloc(t->entries, new_size * sizeof(*t->entries))))
{
ERR("Failed to grow the handle table.\n");
return D3D8_INVALID_HANDLE;
......@@ -623,7 +623,7 @@ static ULONG WINAPI d3d8_device_Release(IDirect3DDevice8 *iface)
{
d3d8_vertex_declaration_destroy(device->decls[i].declaration);
}
heap_free(device->decls);
free(device->decls);
wined3d_streaming_buffer_cleanup(&device->vertex_buffer);
wined3d_streaming_buffer_cleanup(&device->index_buffer);
......@@ -635,8 +635,8 @@ static ULONG WINAPI d3d8_device_Release(IDirect3DDevice8 *iface)
wined3d_swapchain_decref(device->implicit_swapchain);
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
heap_free(device->handle_table.entries);
heap_free(device);
free(device->handle_table.entries);
free(device);
wined3d_mutex_unlock();
......@@ -1127,14 +1127,14 @@ static HRESULT WINAPI d3d8_device_CreateTexture(IDirect3DDevice8 *iface,
return D3DERR_INVALIDCALL;
*texture = NULL;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = d3d8_texture_2d_init(object, device, width, height, levels, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize texture, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -1169,14 +1169,14 @@ static HRESULT WINAPI d3d8_device_CreateVolumeTexture(IDirect3DDevice8 *iface,
return D3DERR_INVALIDCALL;
*texture = NULL;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = d3d8_texture_3d_init(object, device, width, height, depth, levels, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize volume texture, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -1201,14 +1201,14 @@ static HRESULT WINAPI d3d8_device_CreateCubeTexture(IDirect3DDevice8 *iface, UIN
return D3DERR_INVALIDCALL;
*texture = NULL;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = d3d8_texture_cube_init(object, device, edge_length, levels, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize cube texture, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -1238,14 +1238,14 @@ static HRESULT WINAPI d3d8_device_CreateVertexBuffer(IDirect3DDevice8 *iface, UI
TRACE("iface %p, size %u, usage %#lx, fvf %#lx, pool %#x, buffer %p.\n",
iface, size, usage, fvf, pool, buffer);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = vertexbuffer_init(object, device, size, usage, fvf, pool);
if (FAILED(hr))
{
WARN("Failed to initialize vertex buffer, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -1265,14 +1265,14 @@ static HRESULT WINAPI d3d8_device_CreateIndexBuffer(IDirect3DDevice8 *iface, UIN
TRACE("iface %p, size %u, usage %#lx, format %#x, pool %#x, buffer %p.\n",
iface, size, usage, format, pool, buffer);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = indexbuffer_init(object, device, size, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize index buffer, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -2831,7 +2831,7 @@ static HRESULT WINAPI d3d8_device_CreateVertexShader(IDirect3DDevice8 *iface,
TRACE("iface %p, declaration %p, byte_code %p, shader %p, usage %#lx.\n",
iface, declaration, byte_code, shader, usage);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
{
*shader = 0;
return E_OUTOFMEMORY;
......@@ -2843,7 +2843,7 @@ static HRESULT WINAPI d3d8_device_CreateVertexShader(IDirect3DDevice8 *iface,
if (handle == D3D8_INVALID_HANDLE)
{
ERR("Failed to allocate vertex shader handle.\n");
heap_free(object);
free(object);
*shader = 0;
return E_OUTOFMEMORY;
}
......@@ -2857,7 +2857,7 @@ static HRESULT WINAPI d3d8_device_CreateVertexShader(IDirect3DDevice8 *iface,
wined3d_mutex_lock();
d3d8_free_handle(&device->handle_table, handle, D3D8_HANDLE_VS);
wined3d_mutex_unlock();
heap_free(object);
free(object);
*shader = 0;
return hr;
}
......@@ -2897,13 +2897,13 @@ static struct d3d8_vertex_declaration *d3d8_device_get_fvf_declaration(struct d3
}
TRACE("not found. Creating and inserting at position %d.\n", low);
if (!(d3d8_declaration = heap_alloc(sizeof(*d3d8_declaration))))
if (!(d3d8_declaration = malloc(sizeof(*d3d8_declaration))))
return NULL;
if (FAILED(hr = d3d8_vertex_declaration_init_fvf(d3d8_declaration, device, fvf)))
{
WARN("Failed to initialize vertex declaration, hr %#lx.\n", hr);
heap_free(d3d8_declaration);
free(d3d8_declaration);
return NULL;
}
......@@ -2911,7 +2911,7 @@ static struct d3d8_vertex_declaration *d3d8_device_get_fvf_declaration(struct d3
{
UINT grow = device->declArraySize / 2;
if (!(convertedDecls = heap_realloc(convertedDecls,
if (!(convertedDecls = realloc(convertedDecls,
sizeof(*convertedDecls) * (device->numConvertedDecls + grow))))
{
d3d8_vertex_declaration_destroy(d3d8_declaration);
......@@ -3205,7 +3205,7 @@ static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8 *iface,
if (!shader)
return D3DERR_INVALIDCALL;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
wined3d_mutex_lock();
......@@ -3214,7 +3214,7 @@ static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8 *iface,
if (handle == D3D8_INVALID_HANDLE)
{
ERR("Failed to allocate pixel shader handle.\n");
heap_free(object);
free(object);
return E_OUTOFMEMORY;
}
......@@ -3227,7 +3227,7 @@ static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8 *iface,
wined3d_mutex_lock();
d3d8_free_handle(&device->handle_table, handle, D3D8_HANDLE_PS);
wined3d_mutex_unlock();
heap_free(object);
free(object);
*shader = 0;
return hr;
}
......@@ -3623,7 +3623,7 @@ static HRESULT CDECL device_parent_texture_sub_resource_created(struct wined3d_d
{
struct d3d8_volume *d3d_volume;
if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume))))
if (!(d3d_volume = calloc(1, sizeof(*d3d_volume))))
return E_OUTOFMEMORY;
volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops);
......@@ -3692,8 +3692,8 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
device->device_parent.ops = &d3d8_wined3d_device_parent_ops;
device->adapter_ordinal = adapter;
device->ref = 1;
if (!(device->handle_table.entries = heap_alloc_zero(D3D8_INITIAL_HANDLE_TABLE_SIZE
* sizeof(*device->handle_table.entries))))
if (!(device->handle_table.entries = calloc(D3D8_INITIAL_HANDLE_TABLE_SIZE,
sizeof(*device->handle_table.entries))))
{
ERR("Failed to allocate handle table memory.\n");
return E_OUTOFMEMORY;
......@@ -3711,7 +3711,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
{
WARN("Failed to create wined3d device, hr %#lx.\n", hr);
wined3d_mutex_unlock();
heap_free(device->handle_table.entries);
free(device->handle_table.entries);
return hr;
}
......@@ -3742,7 +3742,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
ERR("Failed to acquire focus window, hr %#lx.\n", hr);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
heap_free(device->handle_table.entries);
free(device->handle_table.entries);
return hr;
}
}
......@@ -3755,7 +3755,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
heap_free(device->handle_table.entries);
free(device->handle_table.entries);
return D3DERR_INVALIDCALL;
}
swapchain_desc.flags |= WINED3D_SWAPCHAIN_IMPLICIT;
......@@ -3767,7 +3767,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
heap_free(device->handle_table.entries);
free(device->handle_table.entries);
return hr;
}
......@@ -3785,7 +3785,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
&swapchain_desc, parameters->FullScreen_PresentationInterval);
device->declArraySize = 16;
if (!(device->decls = heap_alloc(device->declArraySize * sizeof(*device->decls))))
if (!(device->decls = malloc(device->declArraySize * sizeof(*device->decls))))
{
ERR("Failed to allocate FVF vertex declaration map memory.\n");
hr = E_OUTOFMEMORY;
......@@ -3805,6 +3805,6 @@ err:
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
heap_free(device->handle_table.entries);
free(device->handle_table.entries);
return hr;
}
......@@ -70,8 +70,8 @@ static ULONG WINAPI d3d8_Release(IDirect3D8 *iface)
wined3d_decref(d3d8->wined3d);
wined3d_mutex_unlock();
heap_free(d3d8->wined3d_outputs);
heap_free(d3d8);
free(d3d8->wined3d_outputs);
free(d3d8);
}
return refcount;
......@@ -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",
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;
hr = device_init(object, d3d8, d3d8->wined3d, adapter, device_type, focus_window, flags, parameters);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -498,7 +498,7 @@ BOOL d3d8_init(struct d3d8 *d3d8)
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)
{
wined3d_decref(d3d8->wined3d);
......
......@@ -25,7 +25,7 @@ static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *p
{
struct d3d8_vertex_shader *shader = parent;
d3d8_vertex_declaration_destroy(shader->vertex_declaration);
heap_free(shader);
free(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
TRACE("device %p, declaration %p, shader_handle %#lx, decl_ptr %p.\n",
device, declaration, shader_handle, decl_ptr);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, 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 %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -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)
{
heap_free(parent);
free(parent);
}
void d3d8_pixel_shader_destroy(struct d3d8_pixel_shader *shader)
......
......@@ -307,7 +307,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent)
{
struct d3d8_surface *surface = parent;
d3d8_resource_cleanup(&surface->resource);
heap_free(surface);
free(surface);
}
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
IDirect3DBaseTexture8 *texture;
struct d3d8_surface *surface;
if (!(surface = heap_alloc_zero(sizeof(*surface))))
if (!(surface = calloc(1, sizeof(*surface))))
return NULL;
surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl;
......
......@@ -148,7 +148,7 @@ static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl =
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 =
......@@ -199,13 +199,13 @@ HRESULT d3d8_swapchain_create(struct d3d8_device *device, struct wined3d_swapcha
unsigned int i;
HRESULT hr;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = swapchain_init(object, device, desc, swap_interval)))
{
WARN("Failed to initialize swapchain, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......
......@@ -1041,7 +1041,7 @@ static void STDMETHODCALLTYPE d3d8_texture_wined3d_object_destroyed(void *parent
if (texture->draw_texture)
wined3d_texture_decref(texture->wined3d_texture);
d3d8_resource_cleanup(&texture->resource);
heap_free(texture);
free(texture);
}
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
*stream_map = 0;
/* 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)
{
token_type = ((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT);
......@@ -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)
{
struct d3d8_vertex_declaration *declaration = parent;
heap_free(declaration->elements);
heap_free(declaration);
free(declaration->elements);
free(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
wined3d_element_count = convert_to_wined3d_declaration(elements, &declaration->elements_size,
&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");
heap_free(wined3d_elements);
free(wined3d_elements);
return E_OUTOFMEMORY;
}
......@@ -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,
declaration, &d3d8_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_vertex_declaration);
wined3d_mutex_unlock();
heap_free(wined3d_elements);
free(wined3d_elements);
if (FAILED(hr))
{
WARN("Failed to create wined3d vertex declaration, hr %#lx.\n", hr);
heap_free(declaration->elements);
free(declaration->elements);
if (hr == E_INVALIDARG)
hr = E_FAIL;
return hr;
......
......@@ -192,7 +192,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
{
struct d3d8_volume *volume = parent;
d3d8_resource_cleanup(&volume->resource);
heap_free(volume);
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