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

ddraw: Use CRT allocation functions.

parent 042f9304
......@@ -110,7 +110,7 @@ static ULONG WINAPI ddraw_clipper_Release(IDirectDrawClipper *iface)
if (clipper->region)
DeleteObject(clipper->region);
clipper->IDirectDrawClipper_iface.lpVtbl = NULL; /* Should help with detecting freed clippers. */
heap_free(clipper);
free(clipper);
}
return refcount;
......
......@@ -387,7 +387,7 @@ static void ddraw_destroy_swapchain(struct ddraw *ddraw)
{
wined3d_vertex_declaration_decref(ddraw->decls[i].decl);
}
heap_free(ddraw->decls);
free(ddraw->decls);
ddraw->numConvertedDecls = 0;
wined3d_swapchain_decref(ddraw->wined3d_swapchain);
......@@ -445,7 +445,7 @@ static void ddraw_destroy(struct ddraw *This)
This->d3ddevice->ddraw = NULL;
/* Now free the object */
heap_free(This);
free(This);
}
/*****************************************************************************
......@@ -631,7 +631,7 @@ static HRESULT ddraw_attach_d3d_device(struct ddraw *ddraw, HWND window,
}
ddraw->declArraySize = 2;
if (!(ddraw->decls = heap_alloc_zero(ddraw->declArraySize * sizeof(*ddraw->decls))))
if (!(ddraw->decls = calloc(ddraw->declArraySize, sizeof(*ddraw->decls))))
{
ERR("Error allocating an array for the converted vertex decls.\n");
ddraw->declArraySize = 0;
......@@ -2441,7 +2441,7 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
if (!cb)
return DDERR_INVALIDPARAMS;
if (!(enum_modes = heap_alloc(enum_mode_array_size * sizeof(*enum_modes))))
if (!(enum_modes = malloc(enum_mode_array_size * sizeof(*enum_modes))))
return DDERR_OUTOFMEMORY;
wined3d_mutex_lock();
......@@ -2506,7 +2506,7 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
if(cb(&callback_sd, Context) == DDENUMRET_CANCEL)
{
TRACE("Application asked to terminate the enumeration\n");
heap_free(enum_modes);
free(enum_modes);
wined3d_mutex_unlock();
return DD_OK;
}
......@@ -2516,9 +2516,9 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
struct wined3d_display_mode *new_enum_modes;
enum_mode_array_size *= 2;
if (!(new_enum_modes = heap_realloc(enum_modes, enum_mode_array_size * sizeof(*new_enum_modes))))
if (!(new_enum_modes = realloc(enum_modes, enum_mode_array_size * sizeof(*new_enum_modes))))
{
heap_free(enum_modes);
free(enum_modes);
wined3d_mutex_unlock();
return DDERR_OUTOFMEMORY;
}
......@@ -2530,7 +2530,7 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
}
TRACE("End of enumeration\n");
heap_free(enum_modes);
free(enum_modes);
wined3d_mutex_unlock();
return DD_OK;
......@@ -3450,7 +3450,7 @@ HRESULT WINAPI DirectDrawCreateClipper(DWORD flags, IDirectDrawClipper **clipper
wined3d_mutex_lock();
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
{
wined3d_mutex_unlock();
return E_OUTOFMEMORY;
......@@ -3460,7 +3460,7 @@ HRESULT WINAPI DirectDrawCreateClipper(DWORD flags, IDirectDrawClipper **clipper
if (FAILED(hr))
{
WARN("Failed to initialize clipper, hr %#lx.\n", hr);
heap_free(object);
free(object);
wined3d_mutex_unlock();
return hr;
}
......@@ -3560,7 +3560,7 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
return DDERR_NOCOOPERATIVELEVELSET;
}
if (!(object = heap_alloc(sizeof(*object))))
if (!(object = malloc(sizeof(*object))))
{
ERR("Out of memory when allocating memory for a palette implementation\n");
wined3d_mutex_unlock();
......@@ -3571,7 +3571,7 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
if (FAILED(hr))
{
WARN("Failed to initialize palette, hr %#lx.\n", hr);
heap_free(object);
free(object);
wined3d_mutex_unlock();
return hr;
}
......@@ -3978,7 +3978,7 @@ static HRESULT WINAPI d3d3_CreateLight(IDirect3D3 *iface, IDirect3DLight **light
if (outer_unknown)
return CLASS_E_NOAGGREGATION;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
{
ERR("Failed to allocate light memory.\n");
return DDERR_OUTOFMEMORY;
......@@ -4125,7 +4125,7 @@ static HRESULT WINAPI d3d3_CreateViewport(IDirect3D3 *iface, IDirect3DViewport3
if (outer_unknown) return CLASS_E_NOAGGREGATION;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
{
ERR("Failed to allocate viewport memory.\n");
return DDERR_OUTOFMEMORY;
......@@ -4921,7 +4921,7 @@ struct wined3d_vertex_declaration *ddraw_find_decl(struct ddraw *This, DWORD fvf
{
unsigned int grow = max(This->declArraySize / 2, 8);
if (!(convertedDecls = heap_realloc(convertedDecls,
if (!(convertedDecls = realloc(convertedDecls,
(This->numConvertedDecls + grow) * sizeof(*convertedDecls))))
{
wined3d_vertex_declaration_decref(pDecl);
......
......@@ -25,7 +25,6 @@
#include <stdbool.h>
#define COBJMACROS
#include "wine/debug.h"
#include "wine/heap.h"
#include "winbase.h"
#include "wingdi.h"
......
......@@ -362,7 +362,7 @@ static ULONG WINAPI d3d_device_inner_Release(IUnknown *iface)
This->ddraw->d3ddevice = NULL;
/* Now free the structure */
heap_free(This);
free(This);
wined3d_mutex_unlock();
}
......@@ -703,7 +703,7 @@ static HRESULT WINAPI d3d_device1_CreateExecuteBuffer(IDirect3DDevice *iface,
return CLASS_E_NOAGGREGATION;
/* Allocate the new Execute Buffer */
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
{
ERR("Failed to allocate execute buffer memory.\n");
return DDERR_OUTOFMEMORY;
......@@ -713,7 +713,7 @@ static HRESULT WINAPI d3d_device1_CreateExecuteBuffer(IDirect3DDevice *iface,
if (FAILED(hr))
{
WARN("Failed to initialize execute buffer, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......@@ -1329,7 +1329,7 @@ static HRESULT WINAPI d3d_device1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIX
if(!D3DMatHandle)
return DDERR_INVALIDPARAMS;
if (!(matrix = heap_alloc_zero(sizeof(*matrix))))
if (!(matrix = calloc(1, sizeof(*matrix))))
{
ERR("Out of memory when allocating a D3DMATRIX\n");
return DDERR_OUTOFMEMORY;
......@@ -1341,7 +1341,7 @@ static HRESULT WINAPI d3d_device1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIX
if (h == DDRAW_INVALID_HANDLE)
{
ERR("Failed to allocate a matrix handle.\n");
heap_free(matrix);
free(matrix);
wined3d_mutex_unlock();
return DDERR_OUTOFMEMORY;
}
......@@ -1493,7 +1493,7 @@ static HRESULT WINAPI d3d_device1_DeleteMatrix(IDirect3DDevice *iface, D3DMATRIX
wined3d_mutex_unlock();
heap_free(m);
free(m);
return D3D_OK;
}
......@@ -2260,11 +2260,11 @@ static HRESULT WINAPI d3d_device3_Vertex(IDirect3DDevice3 *iface, void *vertex)
device->buffer_size = device->buffer_size ? device->buffer_size * 2 : device->vertex_size * 3;
old_buffer = device->sysmem_vertex_buffer;
device->sysmem_vertex_buffer = heap_alloc(device->buffer_size);
device->sysmem_vertex_buffer = malloc(device->buffer_size);
if (old_buffer)
{
memcpy(device->sysmem_vertex_buffer, old_buffer, device->nb_vertices * device->vertex_size);
heap_free(old_buffer);
free(old_buffer);
}
}
......@@ -6944,7 +6944,7 @@ HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_su
return DDERR_INVALIDPARAMS;
}
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
{
ERR("Failed to allocate device memory.\n");
return DDERR_OUTOFMEMORY;
......@@ -6953,7 +6953,7 @@ HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_su
if (FAILED(hr = d3d_device_init(object, ddraw, guid, target, rt_iface, version, outer_unknown)))
{
WARN("Failed to initialize device, hr %#lx.\n", hr);
heap_free(object);
free(object);
return hr;
}
......
......@@ -488,7 +488,7 @@ static ULONG WINAPI d3d_execute_buffer_Release(IDirect3DExecuteBuffer *iface)
if (!ref)
{
if (buffer->need_free)
heap_free(buffer->desc.lpData);
free(buffer->desc.lpData);
if (buffer->index_buffer)
wined3d_buffer_decref(buffer->index_buffer);
if (buffer->dst_vertex_buffer)
......@@ -496,7 +496,7 @@ static ULONG WINAPI d3d_execute_buffer_Release(IDirect3DExecuteBuffer *iface)
wined3d_buffer_decref(buffer->src_vertex_buffer);
wined3d_buffer_decref(buffer->dst_vertex_buffer);
}
heap_free(buffer);
free(buffer);
}
return ref;
......@@ -780,7 +780,7 @@ HRESULT d3d_execute_buffer_init(struct d3d_execute_buffer *execute_buffer,
if (!execute_buffer->desc.lpData && execute_buffer->desc.dwBufferSize)
{
execute_buffer->need_free = TRUE;
if (!(execute_buffer->desc.lpData = heap_alloc_zero(execute_buffer->desc.dwBufferSize)))
if (!(execute_buffer->desc.lpData = calloc(1, execute_buffer->desc.dwBufferSize)))
{
ERR("Failed to allocate execute buffer data.\n");
return DDERR_OUTOFMEMORY;
......
......@@ -137,7 +137,7 @@ static ULONG WINAPI d3d_light_Release(IDirect3DLight *iface)
if (!ref)
{
heap_free(light);
free(light);
return 0;
}
return ref;
......
......@@ -115,7 +115,7 @@ static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMC
/* Handle table functions */
BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size)
{
if (!(t->entries = heap_alloc_zero(initial_size * sizeof(*t->entries))))
if (!(t->entries = calloc(initial_size, sizeof(*t->entries))))
{
ERR("Failed to allocate handle table memory.\n");
return FALSE;
......@@ -129,7 +129,7 @@ BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size)
void ddraw_handle_table_destroy(struct ddraw_handle_table *t)
{
heap_free(t->entries);
free(t->entries);
memset(t, 0, sizeof(*t));
}
......@@ -160,7 +160,7 @@ DWORD ddraw_allocate_handle(struct ddraw_handle_table *t, void *object, enum ddr
UINT new_size = t->table_size + (t->table_size >> 1);
struct ddraw_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 DDRAW_INVALID_HANDLE;
......@@ -311,7 +311,7 @@ static HRESULT DDRAW_Create(const GUID *guid, void **out, IUnknown *outer_unknow
if (!IsEqualGUID(iid, &IID_IDirectDraw7))
flags = WINED3D_LEGACY_FFP_LIGHTING;
if (!(ddraw = heap_alloc_zero(sizeof(*ddraw))))
if (!(ddraw = calloc(1, sizeof(*ddraw))))
{
ERR("Out of memory when creating DirectDraw.\n");
return E_OUTOFMEMORY;
......@@ -320,7 +320,7 @@ static HRESULT DDRAW_Create(const GUID *guid, void **out, IUnknown *outer_unknow
if (FAILED(hr = ddraw_init(ddraw, flags, device_type)))
{
WARN("Failed to initialize ddraw object, hr %#lx.\n", hr);
heap_free(ddraw);
free(ddraw);
return hr;
}
......@@ -681,7 +681,7 @@ static ULONG WINAPI ddraw_class_factory_Release(IClassFactory *iface)
TRACE("%p decreasing refcount to %lu.\n", factory, ref);
if (!ref)
heap_free(factory);
free(factory);
return ref;
}
......@@ -765,7 +765,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **out)
return CLASS_E_CLASSNOTAVAILABLE;
}
if (!(factory = heap_alloc_zero(sizeof(*factory))))
if (!(factory = calloc(1, sizeof(*factory))))
return E_OUTOFMEMORY;
factory->IClassFactory_iface.lpVtbl = &IClassFactory_Vtbl;
......
......@@ -147,7 +147,7 @@ static ULONG WINAPI d3d_material3_Release(IDirect3DMaterial3 *iface)
wined3d_mutex_unlock();
}
heap_free(material);
free(material);
}
return ref;
......@@ -499,7 +499,7 @@ struct d3d_material *d3d_material_create(struct ddraw *ddraw)
{
struct d3d_material *material;
if (!(material = heap_alloc_zero(sizeof(*material))))
if (!(material = calloc(1, sizeof(*material))))
return NULL;
material->IDirect3DMaterial3_iface.lpVtbl = &d3d_material3_vtbl;
......
......@@ -97,7 +97,7 @@ static ULONG WINAPI ddraw_palette_Release(IDirectDrawPalette *iface)
IUnknown_Release(palette->ifaceToRelease);
wined3d_mutex_unlock();
heap_free(palette);
free(palette);
}
return ref;
......
......@@ -95,7 +95,7 @@ static ULONG WINAPI d3d_vertex_buffer7_Release(IDirect3DVertexBuffer7 *iface)
if (buffer->version == 7)
IDirectDraw7_Release(&buffer->ddraw->IDirectDraw7_iface);
heap_free(buffer);
free(buffer);
}
return ref;
......@@ -448,7 +448,7 @@ HRESULT d3d_vertex_buffer_create(struct d3d_vertex_buffer **vertex_buf,
TRACE(" FVF %#lx\n", desc->dwFVF);
TRACE(" dwNumVertices %lu\n", desc->dwNumVertices);
if (!(buffer = heap_alloc_zero(sizeof(*buffer))))
if (!(buffer = calloc(1, sizeof(*buffer))))
return DDERR_OUTOFMEMORY;
buffer->IDirect3DVertexBuffer7_iface.lpVtbl = &d3d_vertex_buffer7_vtbl;
......@@ -485,7 +485,7 @@ end:
if (hr == D3D_OK)
*vertex_buf = buffer;
else
heap_free(buffer);
free(buffer);
return hr;
}
......
......@@ -288,7 +288,7 @@ static ULONG WINAPI d3d_viewport_Release(IDirect3DViewport3 *iface)
TRACE("%p decreasing refcount to %lu.\n", viewport, ref);
if (!ref)
heap_free(viewport);
free(viewport);
return ref;
}
......
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