Commit f08342f5 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Use the global memory allocation helpers.

parent 4e37d1c0
......@@ -1025,8 +1025,9 @@ static void set_tex_op_atifs(struct wined3d_context *context, const struct wined
desc = (const struct atifs_ffp_desc *)find_ffp_frag_shader(&priv->fragment_shaders, &settings);
if (!desc)
{
struct atifs_ffp_desc *new_desc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*new_desc));
if (!new_desc)
struct atifs_ffp_desc *new_desc;
if (!(new_desc = heap_alloc_zero(sizeof(*new_desc))))
{
ERR("Out of memory\n");
return;
......@@ -1320,7 +1321,7 @@ static void *atifs_alloc(const struct wined3d_shader_backend_ops *shader_backend
{
struct atifs_private_data *priv;
if (!(priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*priv))))
if (!(priv = heap_alloc_zero(sizeof(*priv))))
return NULL;
wine_rb_init(&priv->fragment_shaders, wined3d_ffp_frag_program_key_compare);
......@@ -1335,7 +1336,7 @@ static void atifs_free_ffpshader(struct wine_rb_entry *entry, void *cb_ctx)
GL_EXTCALL(glDeleteFragmentShaderATI(entry_ati->shader));
checkGLcall("glDeleteFragmentShaderATI(entry->shader)");
HeapFree(GetProcessHeap(), 0, entry_ati);
heap_free(entry_ati);
}
/* Context activation is done by the caller. */
......@@ -1345,7 +1346,7 @@ static void atifs_free(struct wined3d_device *device)
wine_rb_destroy(&priv->fragment_shaders, atifs_free_ffpshader, &device->adapter->gl_info);
HeapFree(GetProcessHeap(), 0, priv);
heap_free(priv);
device->fragment_priv = NULL;
}
......@@ -1358,8 +1359,9 @@ static BOOL atifs_color_fixup_supported(struct color_fixup_desc fixup)
static BOOL atifs_alloc_context_data(struct wined3d_context *context)
{
struct atifs_context_private_data *priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*priv));
if (!priv)
struct atifs_context_private_data *priv;
if (!(priv = heap_alloc_zero(sizeof(*priv))))
return FALSE;
context->fragment_pipe_data = priv;
return TRUE;
......@@ -1367,7 +1369,7 @@ static BOOL atifs_alloc_context_data(struct wined3d_context *context)
static void atifs_free_context_data(struct wined3d_context *context)
{
HeapFree(GetProcessHeap(), 0, context->fragment_pipe_data);
heap_free(context->fragment_pipe_data);
}
const struct fragment_pipeline atifs_fragment_pipeline = {
......
......@@ -302,8 +302,8 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *buffer,
*/
TRACE("Reconverting because converted attributes occur, and the stride changed.\n");
buffer->stride = *stride_this_run;
HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, buffer->conversion_map);
buffer->conversion_map = wined3d_calloc(buffer->stride, sizeof(*buffer->conversion_map));
heap_free(buffer->conversion_map);
buffer->conversion_map = heap_calloc(buffer->stride, sizeof(*buffer->conversion_map));
ret = TRUE;
}
}
......@@ -385,7 +385,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This, const struct wined3d_s
TRACE("No fixup required.\n");
if(This->conversion_map)
{
HeapFree(GetProcessHeap(), 0, This->conversion_map);
heap_free(This->conversion_map);
This->conversion_map = NULL;
This->stride = 0;
return TRUE;
......@@ -474,8 +474,9 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This, const struct wined3d_s
if (!stride_this_run && This->conversion_map)
{
/* Sanity test */
if (!ret) ERR("no converted attributes found, old conversion map exists, and no declaration change?\n");
HeapFree(GetProcessHeap(), 0, This->conversion_map);
if (!ret)
ERR("no converted attributes found, old conversion map exists, and no declaration change?\n");
heap_free(This->conversion_map);
This->conversion_map = NULL;
This->stride = 0;
}
......@@ -563,7 +564,7 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined
/* Now for each vertex in the buffer that needs conversion. */
vertex_count = buffer->resource.size / buffer->stride;
if (!(data = HeapAlloc(GetProcessHeap(), 0, buffer->resource.size)))
if (!(data = heap_alloc(buffer->resource.size)))
{
ERR("Out of memory.\n");
return;
......@@ -601,7 +602,7 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined
wined3d_buffer_upload_ranges(buffer, context, data, 0, buffer->modified_areas, buffer->maps);
HeapFree(GetProcessHeap(), 0, data);
heap_free(data);
}
static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
......@@ -753,7 +754,7 @@ static void buffer_unload(struct wined3d_resource *resource)
context_release(context);
HeapFree(GetProcessHeap(), 0, buffer->conversion_map);
heap_free(buffer->conversion_map);
buffer->conversion_map = NULL;
buffer->stride = 0;
buffer->conversion_stride = 0;
......@@ -780,11 +781,11 @@ static void wined3d_buffer_destroy_object(void *object)
buffer_destroy_buffer_object(buffer, context);
context_release(context);
HeapFree(GetProcessHeap(), 0, buffer->conversion_map);
heap_free(buffer->conversion_map);
}
HeapFree(GetProcessHeap(), 0, buffer->maps);
HeapFree(GetProcessHeap(), 0, buffer);
heap_free(buffer->maps);
heap_free(buffer);
}
ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
......@@ -1396,7 +1397,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
buffer->flags |= WINED3D_BUFFER_USE_BO;
}
if (!(buffer->maps = HeapAlloc(GetProcessHeap(), 0, sizeof(*buffer->maps))))
if (!(buffer->maps = heap_alloc(sizeof(*buffer->maps))))
{
ERR("Out of memory.\n");
buffer_unload(&buffer->resource);
......@@ -1423,14 +1424,14 @@ HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct
TRACE("device %p, desc %p, data %p, parent %p, parent_ops %p, buffer %p.\n",
device, desc, data, parent, parent_ops, buffer);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = buffer_init(object, device, desc->byte_width, desc->usage, WINED3DFMT_UNKNOWN,
desc->access, desc->bind_flags, data, parent, parent_ops)))
{
WARN("Failed to initialize buffer, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
object->desc = *desc;
......
......@@ -523,8 +523,7 @@ static struct fbo_entry *context_create_fbo_entry(const struct wined3d_context *
unsigned int object_count = gl_info->limits.buffers + 1;
struct fbo_entry *entry;
entry = HeapAlloc(GetProcessHeap(), 0,
FIELD_OFFSET(struct fbo_entry, key.objects[object_count]));
entry = heap_alloc(FIELD_OFFSET(struct fbo_entry, key.objects[object_count]));
memset(&entry->key, 0, FIELD_OFFSET(struct wined3d_fbo_entry_key, objects[object_count]));
context_generate_fbo_key(context, &entry->key, render_targets, depth_stencil, color_location, ds_location);
entry->flags = 0;
......@@ -574,7 +573,7 @@ static void context_destroy_fbo_entry(struct wined3d_context *context, struct fb
}
--context->fbo_entry_count;
list_remove(&entry->entry);
HeapFree(GetProcessHeap(), 0, entry);
heap_free(entry);
}
/* Context activation is done by the caller. */
......@@ -1435,11 +1434,11 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
checkGLcall("context cleanup");
}
HeapFree(GetProcessHeap(), 0, context->free_so_statistics_queries);
HeapFree(GetProcessHeap(), 0, context->free_pipeline_statistics_queries);
HeapFree(GetProcessHeap(), 0, context->free_timestamp_queries);
HeapFree(GetProcessHeap(), 0, context->free_occlusion_queries);
HeapFree(GetProcessHeap(), 0, context->free_fences);
heap_free(context->free_so_statistics_queries);
heap_free(context->free_pipeline_statistics_queries);
heap_free(context->free_timestamp_queries);
heap_free(context->free_occlusion_queries);
heap_free(context->free_fences);
context_restore_pixel_format(context);
if (restore_ctx)
......@@ -1491,8 +1490,8 @@ BOOL context_set_current(struct wined3d_context *ctx)
{
TRACE("Switching away from destroyed context %p.\n", old);
context_destroy_gl_resources(old);
HeapFree(GetProcessHeap(), 0, (void *)old->gl_info);
HeapFree(GetProcessHeap(), 0, old);
heap_free((void *)old->gl_info);
heap_free(old);
}
else
{
......@@ -1863,35 +1862,33 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
wined3d_from_cs(device->cs);
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
if (!ret)
if (!(ret = heap_alloc_zero(sizeof(*ret))))
return NULL;
if (!(ret->blit_targets = wined3d_calloc(gl_info->limits.buffers, sizeof(*ret->blit_targets))))
if (!(ret->blit_targets = heap_calloc(gl_info->limits.buffers, sizeof(*ret->blit_targets))))
goto out;
if (!(ret->draw_buffers = wined3d_calloc(gl_info->limits.buffers, sizeof(*ret->draw_buffers))))
if (!(ret->draw_buffers = heap_calloc(gl_info->limits.buffers, sizeof(*ret->draw_buffers))))
goto out;
ret->fbo_key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
FIELD_OFFSET(struct wined3d_fbo_entry_key, objects[gl_info->limits.buffers + 1]));
if (!ret->fbo_key)
if (!(ret->fbo_key = heap_alloc_zero(FIELD_OFFSET(struct wined3d_fbo_entry_key,
objects[gl_info->limits.buffers + 1]))))
goto out;
ret->free_timestamp_query_size = 4;
if (!(ret->free_timestamp_queries = wined3d_calloc(ret->free_timestamp_query_size,
if (!(ret->free_timestamp_queries = heap_calloc(ret->free_timestamp_query_size,
sizeof(*ret->free_timestamp_queries))))
goto out;
list_init(&ret->timestamp_queries);
ret->free_occlusion_query_size = 4;
if (!(ret->free_occlusion_queries = wined3d_calloc(ret->free_occlusion_query_size,
if (!(ret->free_occlusion_queries = heap_calloc(ret->free_occlusion_query_size,
sizeof(*ret->free_occlusion_queries))))
goto out;
list_init(&ret->occlusion_queries);
ret->free_fence_size = 4;
if (!(ret->free_fences = wined3d_calloc(ret->free_fence_size, sizeof(*ret->free_fences))))
if (!(ret->free_fences = heap_calloc(ret->free_fence_size, sizeof(*ret->free_fences))))
goto out;
list_init(&ret->fences);
......@@ -1947,7 +1944,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
}
}
if (!(ret->texture_type = wined3d_calloc(gl_info->limits.combined_samplers,
if (!(ret->texture_type = heap_calloc(gl_info->limits.combined_samplers,
sizeof(*ret->texture_type))))
goto out;
......@@ -2248,14 +2245,14 @@ out:
wined3d_release_dc(swapchain->win_handle, ret->hdc);
device->shader_backend->shader_free_context_data(ret);
device->adapter->fragment_pipe->free_context_data(ret);
HeapFree(GetProcessHeap(), 0, ret->texture_type);
HeapFree(GetProcessHeap(), 0, ret->free_fences);
HeapFree(GetProcessHeap(), 0, ret->free_occlusion_queries);
HeapFree(GetProcessHeap(), 0, ret->free_timestamp_queries);
HeapFree(GetProcessHeap(), 0, ret->fbo_key);
HeapFree(GetProcessHeap(), 0, ret->draw_buffers);
HeapFree(GetProcessHeap(), 0, ret->blit_targets);
HeapFree(GetProcessHeap(), 0, ret);
heap_free(ret->texture_type);
heap_free(ret->free_fences);
heap_free(ret->free_occlusion_queries);
heap_free(ret->free_timestamp_queries);
heap_free(ret->fbo_key);
heap_free(ret->draw_buffers);
heap_free(ret->blit_targets);
heap_free(ret);
return NULL;
}
......@@ -2288,7 +2285,7 @@ void context_destroy(struct wined3d_device *device, struct wined3d_context *cont
{
/* Make a copy of gl_info for context_destroy_gl_resources use, the one
in wined3d_adapter may go away in the meantime */
struct wined3d_gl_info *gl_info = HeapAlloc(GetProcessHeap(), 0, sizeof(*gl_info));
struct wined3d_gl_info *gl_info = heap_alloc(sizeof(*gl_info));
*gl_info = *context->gl_info;
context->gl_info = gl_info;
context->destroyed = 1;
......@@ -2297,12 +2294,13 @@ void context_destroy(struct wined3d_device *device, struct wined3d_context *cont
device->shader_backend->shader_free_context_data(context);
device->adapter->fragment_pipe->free_context_data(context);
HeapFree(GetProcessHeap(), 0, context->texture_type);
HeapFree(GetProcessHeap(), 0, context->fbo_key);
HeapFree(GetProcessHeap(), 0, context->draw_buffers);
HeapFree(GetProcessHeap(), 0, context->blit_targets);
heap_free(context->texture_type);
heap_free(context->fbo_key);
heap_free(context->draw_buffers);
heap_free(context->blit_targets);
device_context_remove(device, context);
if (destroy) HeapFree(GetProcessHeap(), 0, context);
if (destroy)
heap_free(context);
}
const DWORD *context_get_tex_unit_mapping(const struct wined3d_context *context,
......
......@@ -1697,7 +1697,7 @@ static void wined3d_cs_exec_set_light(struct wined3d_cs *cs, const void *data)
if (!(light_info = wined3d_state_get_light(&cs->state, light_idx)))
{
TRACE("Adding new light.\n");
if (!(light_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*light_info))))
if (!(light_info = heap_alloc_zero(sizeof(*light_info))))
{
ERR("Failed to allocate light info.\n");
return;
......@@ -2459,9 +2459,9 @@ static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, enu
new_size = max(size, cs->data_size * 2);
if (!cs->end)
new_data = HeapReAlloc(GetProcessHeap(), 0, cs->data, new_size);
new_data = heap_realloc(cs->data, new_size);
else
new_data = HeapAlloc(GetProcessHeap(), 0, new_size);
new_data = heap_alloc(new_size);
if (!new_data)
return NULL;
......@@ -2494,7 +2494,7 @@ static void wined3d_cs_st_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id
if (cs->data == data)
cs->start = cs->end = start;
else if (!start)
HeapFree(GetProcessHeap(), 0, data);
heap_free(data);
}
static void wined3d_cs_st_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
......@@ -2728,15 +2728,15 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_cs *cs;
if (!(cs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cs))))
if (!(cs = heap_alloc_zero(sizeof(*cs))))
return NULL;
cs->ops = &wined3d_cs_st_ops;
cs->device = device;
if (!(cs->fb.render_targets = wined3d_calloc(gl_info->limits.buffers, sizeof(*cs->fb.render_targets))))
if (!(cs->fb.render_targets = heap_calloc(gl_info->limits.buffers, sizeof(*cs->fb.render_targets))))
{
HeapFree(GetProcessHeap(), 0, cs);
heap_free(cs);
return NULL;
}
......@@ -2744,7 +2744,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT);
cs->data_size = WINED3D_INITIAL_CS_SIZE;
if (!(cs->data = HeapAlloc(GetProcessHeap(), 0, cs->data_size)))
if (!(cs->data = heap_alloc(cs->data_size)))
goto fail;
if (wined3d_settings.cs_multithreaded
......@@ -2755,7 +2755,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
if (!(cs->event = CreateEventW(NULL, FALSE, FALSE, NULL)))
{
ERR("Failed to create command stream event.\n");
HeapFree(GetProcessHeap(), 0, cs->data);
heap_free(cs->data);
goto fail;
}
......@@ -2764,7 +2764,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
{
ERR("Failed to get wined3d module handle.\n");
CloseHandle(cs->event);
HeapFree(GetProcessHeap(), 0, cs->data);
heap_free(cs->data);
goto fail;
}
......@@ -2773,7 +2773,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
ERR("Failed to create wined3d command stream thread.\n");
FreeLibrary(cs->wined3d_module);
CloseHandle(cs->event);
HeapFree(GetProcessHeap(), 0, cs->data);
heap_free(cs->data);
goto fail;
}
}
......@@ -2782,8 +2782,8 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
fail:
state_cleanup(&cs->state);
HeapFree(GetProcessHeap(), 0, cs->fb.render_targets);
HeapFree(GetProcessHeap(), 0, cs);
heap_free(cs->fb.render_targets);
heap_free(cs);
return NULL;
}
......@@ -2798,7 +2798,7 @@ void wined3d_cs_destroy(struct wined3d_cs *cs)
}
state_cleanup(&cs->state);
HeapFree(GetProcessHeap(), 0, cs->fb.render_targets);
HeapFree(GetProcessHeap(), 0, cs->data);
HeapFree(GetProcessHeap(), 0, cs);
heap_free(cs->fb.render_targets);
heap_free(cs->data);
heap_free(cs);
}
......@@ -149,11 +149,7 @@ BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *c
TRACE("Adding context %p.\n", context);
if (!device->contexts) new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_array));
else new_array = HeapReAlloc(GetProcessHeap(), 0, device->contexts,
sizeof(*new_array) * (device->context_count + 1));
if (!new_array)
if (!(new_array = heap_realloc(device->contexts, sizeof(*new_array) * (device->context_count + 1))))
{
ERR("Failed to grow the context array.\n");
return FALSE;
......@@ -189,14 +185,13 @@ void device_context_remove(struct wined3d_device *device, struct wined3d_context
if (!--device->context_count)
{
HeapFree(GetProcessHeap(), 0, device->contexts);
heap_free(device->contexts);
device->contexts = NULL;
return;
}
memmove(&device->contexts[i], &device->contexts[i + 1], (device->context_count - i) * sizeof(*device->contexts));
new_array = HeapReAlloc(GetProcessHeap(), 0, device->contexts, device->context_count * sizeof(*device->contexts));
if (!new_array)
if (!(new_array = heap_realloc(device->contexts, device->context_count * sizeof(*device->contexts))))
{
ERR("Failed to shrink context array. Oh well.\n");
return;
......@@ -491,7 +486,7 @@ ULONG CDECL wined3d_device_decref(struct wined3d_device *device)
for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
{
HeapFree(GetProcessHeap(), 0, device->multistate_funcs[i]);
heap_free(device->multistate_funcs[i]);
device->multistate_funcs[i] = NULL;
}
......@@ -518,7 +513,7 @@ ULONG CDECL wined3d_device_decref(struct wined3d_device *device)
wined3d_decref(device->wined3d);
device->wined3d = NULL;
HeapFree(GetProcessHeap(), 0, device);
heap_free(device);
TRACE("Freed device %p.\n", device);
}
......@@ -1066,7 +1061,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
if (device->wined3d->flags & WINED3D_NO3D)
return WINED3DERR_INVALIDCALL;
if (!(device->fb.render_targets = wined3d_calloc(gl_info->limits.buffers, sizeof(*device->fb.render_targets))))
if (!(device->fb.render_targets = heap_calloc(gl_info->limits.buffers, sizeof(*device->fb.render_targets))))
return E_OUTOFMEMORY;
/* Setup the implicit swapchain. This also initializes a context. */
......@@ -1099,7 +1094,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
}
device->swapchain_count = 1;
if (!(device->swapchains = wined3d_calloc(device->swapchain_count, sizeof(*device->swapchains))))
if (!(device->swapchains = heap_calloc(device->swapchain_count, sizeof(*device->swapchains))))
{
ERR("Out of memory!\n");
goto err_out;
......@@ -1129,13 +1124,13 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
return WINED3D_OK;
err_out:
HeapFree(GetProcessHeap(), 0, device->swapchains);
heap_free(device->swapchains);
device->swapchain_count = 0;
if (device->back_buffer_view)
wined3d_rendertarget_view_decref(device->back_buffer_view);
if (swapchain)
wined3d_swapchain_decref(swapchain);
HeapFree(GetProcessHeap(), 0, device->fb.render_targets);
heap_free(device->fb.render_targets);
return hr;
}
......@@ -1159,7 +1154,7 @@ HRESULT CDECL wined3d_device_init_gdi(struct wined3d_device *device,
}
device->swapchain_count = 1;
if (!(device->swapchains = wined3d_calloc(device->swapchain_count, sizeof(*device->swapchains))))
if (!(device->swapchains = heap_calloc(device->swapchain_count, sizeof(*device->swapchains))))
{
ERR("Out of memory!\n");
goto err_out;
......@@ -1169,7 +1164,7 @@ HRESULT CDECL wined3d_device_init_gdi(struct wined3d_device *device,
if (!(device->blitter = wined3d_cpu_blitter_create()))
{
ERR("Failed to create CPU blitter.\n");
HeapFree(GetProcessHeap(), 0, device->swapchains);
heap_free(device->swapchains);
device->swapchain_count = 0;
goto err_out;
}
......@@ -1246,11 +1241,11 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
FIXME("Something's still holding the implicit swapchain.\n");
}
HeapFree(GetProcessHeap(), 0, device->swapchains);
heap_free(device->swapchains);
device->swapchains = NULL;
device->swapchain_count = 0;
HeapFree(GetProcessHeap(), 0, device->fb.render_targets);
heap_free(device->fb.render_targets);
device->fb.render_targets = NULL;
device->d3d_initialized = FALSE;
......@@ -1271,7 +1266,7 @@ HRESULT CDECL wined3d_device_uninit_gdi(struct wined3d_device *device)
FIXME("Something's still holding the implicit swapchain.\n");
}
HeapFree(GetProcessHeap(), 0, device->swapchains);
heap_free(device->swapchains);
device->swapchains = NULL;
device->swapchain_count = 0;
return WINED3D_OK;
......@@ -1589,8 +1584,7 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
if (!(object = wined3d_state_get_light(device->update_state, light_idx)))
{
TRACE("Adding new light\n");
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
list_add_head(&device->update_state->light_map[hash_idx], &object->entry);
......@@ -4608,7 +4602,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
/* 32-bit user32 cursors ignore the alpha channel if it's all
* zeroes, and use the mask instead. Fill the mask with all ones
* to ensure we still get a fully transparent cursor. */
if (!(mask_bits = HeapAlloc(GetProcessHeap(), 0, mask_size)))
if (!(mask_bits = heap_alloc(mask_size)))
return E_OUTOFMEMORY;
memset(mask_bits, 0xff, mask_size);
......@@ -4633,7 +4627,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
if (device->bCursorVisible)
SetCursor(cursor);
HeapFree(GetProcessHeap(), 0, mask_bits);
heap_free(mask_bits);
}
TRACE("New cursor dimensions are %ux%u.\n", cursor_width, cursor_height);
......@@ -5208,7 +5202,7 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
err:
for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
{
HeapFree(GetProcessHeap(), 0, device->multistate_funcs[i]);
heap_free(device->multistate_funcs[i]);
}
wine_rb_destroy(&device->samplers, NULL, NULL);
wined3d_decref(device->wined3d);
......
......@@ -448,8 +448,8 @@ UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount)
static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
{
HeapFree(GetProcessHeap(), 0, adapter->gl_info.formats);
HeapFree(GetProcessHeap(), 0, adapter->cfgs);
heap_free(adapter->gl_info.formats);
heap_free(adapter->cfgs);
}
ULONG CDECL wined3d_incref(struct wined3d *wined3d)
......@@ -475,7 +475,7 @@ ULONG CDECL wined3d_decref(struct wined3d *wined3d)
{
wined3d_adapter_cleanup(&wined3d->adapters[i]);
}
HeapFree(GetProcessHeap(), 0, wined3d);
heap_free(wined3d);
}
return refcount;
......@@ -4638,11 +4638,11 @@ HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *w
return E_FAIL;
}
if (!(modes = wined3d_calloc(mode_count, sizeof(*modes))))
if (!(modes = heap_calloc(mode_count, sizeof(*modes))))
return E_OUTOFMEMORY;
if (!(matching_modes = wined3d_calloc(mode_count, sizeof(*matching_modes))))
if (!(matching_modes = heap_calloc(mode_count, sizeof(*matching_modes))))
{
HeapFree(GetProcessHeap(), 0, modes);
heap_free(modes);
return E_OUTOFMEMORY;
}
......@@ -4651,8 +4651,8 @@ HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *w
if (FAILED(hr = wined3d_enum_adapter_modes(wined3d, adapter_idx,
mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN, i, &modes[i])))
{
HeapFree(GetProcessHeap(), 0, matching_modes);
HeapFree(GetProcessHeap(), 0, modes);
heap_free(matching_modes);
heap_free(modes);
return hr;
}
matching_modes[i] = &modes[i];
......@@ -4688,8 +4688,8 @@ HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *w
if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx,
&current_mode, NULL)))
{
HeapFree(GetProcessHeap(), 0, matching_modes);
HeapFree(GetProcessHeap(), 0, modes);
heap_free(matching_modes);
heap_free(modes);
return hr;
}
mode->width = current_mode.width;
......@@ -4711,8 +4711,8 @@ HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *w
*mode = *matching_modes[j];
HeapFree(GetProcessHeap(), 0, matching_modes);
HeapFree(GetProcessHeap(), 0, modes);
heap_free(matching_modes);
heap_free(modes);
TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
mode->refresh_rate, debug_d3dformat(mode->format_id),
......@@ -6191,8 +6191,7 @@ HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, e
if (wined3d->adapter_count && adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = device_init(object, wined3d, adapter_idx, device_type,
......@@ -6200,7 +6199,7 @@ HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, e
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
......@@ -6440,7 +6439,7 @@ static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc
attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, 0, 0, 1, &attribute, &cfg_count));
adapter->cfgs = wined3d_calloc(cfg_count, sizeof(*adapter->cfgs));
adapter->cfgs = heap_calloc(cfg_count, sizeof(*adapter->cfgs));
attribs[attrib_count++] = WGL_RED_BITS_ARB;
attribs[attrib_count++] = WGL_GREEN_BITS_ARB;
attribs[attrib_count++] = WGL_BLUE_BITS_ARB;
......@@ -6505,7 +6504,7 @@ static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc
int cfg_count;
cfg_count = DescribePixelFormat(dc, 0, 0, 0);
adapter->cfgs = wined3d_calloc(cfg_count, sizeof(*adapter->cfgs));
adapter->cfgs = heap_calloc(cfg_count, sizeof(*adapter->cfgs));
for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
{
......@@ -6666,7 +6665,7 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal,
{
WARN("No suitable pixel formats found.\n");
wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
HeapFree(GetProcessHeap(), 0, adapter->cfgs);
heap_free(adapter->cfgs);
return FALSE;
}
......@@ -6674,7 +6673,7 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal,
{
ERR("Failed to initialize GL format info.\n");
wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
HeapFree(GetProcessHeap(), 0, adapter->cfgs);
heap_free(adapter->cfgs);
return FALSE;
}
......
......@@ -35,7 +35,7 @@ ULONG CDECL wined3d_palette_incref(struct wined3d_palette *palette)
static void wined3d_palette_destroy_object(void *object)
{
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
}
ULONG CDECL wined3d_palette_decref(struct wined3d_palette *palette)
......@@ -160,14 +160,13 @@ HRESULT CDECL wined3d_palette_create(struct wined3d_device *device, DWORD flags,
TRACE("device %p, flags %#x, entry_count %u, entries %p, palette %p.\n",
device, flags, entry_count, entries, palette);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = wined3d_palette_init(object, device, flags, entry_count, entries)))
{
WARN("Failed to initialize palette, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
......
......@@ -286,7 +286,7 @@ static void wined3d_fence_free(struct wined3d_fence *fence)
void wined3d_fence_destroy(struct wined3d_fence *fence)
{
wined3d_fence_free(fence);
HeapFree(GetProcessHeap(), 0, fence);
heap_free(fence);
}
static HRESULT wined3d_fence_init(struct wined3d_fence *fence, const struct wined3d_gl_info *gl_info)
......@@ -308,12 +308,12 @@ HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence
TRACE("device %p, fence %p.\n", device, fence);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = wined3d_fence_init(object, gl_info)))
{
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
......@@ -918,7 +918,7 @@ static void wined3d_event_query_ops_destroy(struct wined3d_query *query)
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
wined3d_fence_free(&event_query->fence);
HeapFree(GetProcessHeap(), 0, event_query);
heap_free(event_query);
}
static const struct wined3d_query_ops event_query_ops =
......@@ -939,13 +939,13 @@ static HRESULT wined3d_event_query_create(struct wined3d_device *device,
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
device, type, parent, parent_ops, query);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = wined3d_fence_init(&object->fence, gl_info)))
{
WARN("Event queries not supported.\n");
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
......@@ -964,7 +964,7 @@ static void wined3d_occlusion_query_ops_destroy(struct wined3d_query *query)
if (oq->context)
context_free_occlusion_query(oq);
HeapFree(GetProcessHeap(), 0, oq);
heap_free(oq);
}
static const struct wined3d_query_ops occlusion_query_ops =
......@@ -990,7 +990,7 @@ static HRESULT wined3d_occlusion_query_create(struct wined3d_device *device,
return WINED3DERR_NOTAVAILABLE;
}
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
wined3d_query_init(&object->query, device, type, &object->samples,
......@@ -1008,7 +1008,7 @@ static void wined3d_timestamp_query_ops_destroy(struct wined3d_query *query)
if (tq->context)
context_free_timestamp_query(tq);
HeapFree(GetProcessHeap(), 0, tq);
heap_free(tq);
}
static const struct wined3d_query_ops timestamp_query_ops =
......@@ -1034,7 +1034,7 @@ static HRESULT wined3d_timestamp_query_create(struct wined3d_device *device,
return WINED3DERR_NOTAVAILABLE;
}
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
wined3d_query_init(&object->query, device, type, &object->timestamp,
......@@ -1048,7 +1048,7 @@ static HRESULT wined3d_timestamp_query_create(struct wined3d_device *device,
static void wined3d_timestamp_disjoint_query_ops_destroy(struct wined3d_query *query)
{
HeapFree(GetProcessHeap(), 0, query);
heap_free(query);
}
static const struct wined3d_query_ops timestamp_disjoint_query_ops =
......@@ -1074,7 +1074,7 @@ static HRESULT wined3d_timestamp_disjoint_query_create(struct wined3d_device *de
return WINED3DERR_NOTAVAILABLE;
}
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (type == WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT)
......@@ -1104,7 +1104,7 @@ static void wined3d_so_statistics_query_ops_destroy(struct wined3d_query *query)
if (pq->context)
context_free_so_statistics_query(pq);
HeapFree(GetProcessHeap(), 0, pq);
heap_free(pq);
}
static const struct wined3d_query_ops so_statistics_query_ops =
......@@ -1141,7 +1141,7 @@ static HRESULT wined3d_so_statistics_query_create(struct wined3d_device *device,
return WINED3DERR_NOTAVAILABLE;
}
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
wined3d_query_init(&object->query, device, type, &object->statistics,
......@@ -1159,7 +1159,7 @@ static void wined3d_pipeline_query_ops_destroy(struct wined3d_query *query)
struct wined3d_pipeline_statistics_query *pq = wined3d_pipeline_statistics_query_from_query(query);
if (pq->context)
context_free_pipeline_statistics_query(pq);
HeapFree(GetProcessHeap(), 0, pq);
heap_free(pq);
}
static const struct wined3d_query_ops pipeline_query_ops =
......@@ -1185,7 +1185,7 @@ static HRESULT wined3d_pipeline_query_create(struct wined3d_device *device,
return WINED3DERR_NOTAVAILABLE;
}
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
wined3d_query_init(&object->query, device, type, &object->statistics,
......
......@@ -374,7 +374,7 @@ BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
SIZE_T align = RESOURCE_ALIGNMENT - 1 + sizeof(*p);
void *mem;
if (!(mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, resource->size + align)))
if (!(mem = heap_alloc_zero(resource->size + align)))
return FALSE;
p = (void **)(((ULONG_PTR)mem + align) & ~(RESOURCE_ALIGNMENT - 1)) - 1;
......@@ -392,7 +392,7 @@ void wined3d_resource_free_sysmem(struct wined3d_resource *resource)
if (!p)
return;
HeapFree(GetProcessHeap(), 0, *(--p));
heap_free(*(--p));
resource->heap_memory = NULL;
}
......
......@@ -47,7 +47,7 @@ static void wined3d_sampler_destroy_object(void *object)
context_release(context);
}
HeapFree(GetProcessHeap(), 0, sampler);
heap_free(sampler);
}
ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
......@@ -144,7 +144,7 @@ HRESULT CDECL wined3d_sampler_create(struct wined3d_device *device, const struct
|| desc->mip_filter > WINED3D_TEXF_LINEAR)
return WINED3DERR_INVALIDCALL;
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
wined3d_sampler_init(object, device, desc, parent, parent_ops);
......
......@@ -549,7 +549,7 @@ static void *shader_sm1_init(const DWORD *byte_code, size_t byte_code_size,
return NULL;
}
if (!(priv = HeapAlloc(GetProcessHeap(), 0, sizeof(*priv))))
if (!(priv = heap_alloc(sizeof(*priv))))
return NULL;
if (output_signature->element_count)
......@@ -569,7 +569,7 @@ static void *shader_sm1_init(const DWORD *byte_code, size_t byte_code_size,
default:
FIXME("Unrecognized shader type %#x.\n", *byte_code >> 16);
HeapFree(GetProcessHeap(), 0, priv);
heap_free(priv);
return NULL;
}
priv->shader_version.major = WINED3D_SM1_VERSION_MAJOR(*byte_code);
......@@ -582,7 +582,7 @@ static void *shader_sm1_init(const DWORD *byte_code, size_t byte_code_size,
static void shader_sm1_free(void *data)
{
HeapFree(GetProcessHeap(), 0, data);
heap_free(data);
}
static void shader_sm1_read_header(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version)
......
......@@ -1242,7 +1242,7 @@ static void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
return NULL;
}
if (!(priv = HeapAlloc(GetProcessHeap(), 0, sizeof(*priv))))
if (!(priv = heap_alloc(sizeof(*priv))))
{
ERR("Failed to allocate private data\n");
return NULL;
......@@ -1311,9 +1311,9 @@ static void shader_sm4_free(void *data)
list_move_head(&priv->src_free, &priv->src);
LIST_FOR_EACH_ENTRY_SAFE(e1, e2, &priv->src_free, struct wined3d_shader_src_param_entry, entry)
{
HeapFree(GetProcessHeap(), 0, e1);
heap_free(e1);
}
HeapFree(GetProcessHeap(), 0, priv);
heap_free(priv);
}
static struct wined3d_shader_src_param *get_src_param(struct wined3d_sm4_data *priv)
......@@ -1328,7 +1328,7 @@ static struct wined3d_shader_src_param *get_src_param(struct wined3d_sm4_data *p
}
else
{
if (!(e = HeapAlloc(GetProcessHeap(), 0, sizeof(*e))))
if (!(e = heap_alloc(sizeof(*e))))
return NULL;
elem = &e->entry;
}
......
......@@ -49,7 +49,7 @@ ULONG CDECL wined3d_blend_state_incref(struct wined3d_blend_state *state)
static void wined3d_blend_state_destroy_object(void *object)
{
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
}
ULONG CDECL wined3d_blend_state_decref(struct wined3d_blend_state *state)
......@@ -84,7 +84,7 @@ HRESULT CDECL wined3d_blend_state_create(struct wined3d_device *device,
TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
device, desc, parent, parent_ops, state);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
object->refcount = 1;
......@@ -110,7 +110,7 @@ ULONG CDECL wined3d_rasterizer_state_incref(struct wined3d_rasterizer_state *sta
static void wined3d_rasterizer_state_destroy_object(void *object)
{
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
}
ULONG CDECL wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state *state)
......@@ -145,7 +145,7 @@ HRESULT CDECL wined3d_rasterizer_state_create(struct wined3d_device *device,
TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
device, desc, parent, parent_ops, state);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
object->refcount = 1;
......@@ -6170,7 +6170,7 @@ HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_
break;
case 1:
StateTable[cur[i].state].apply = multistate_apply_2;
if (!(dev_multistate_funcs[cur[i].state] = wined3d_calloc(2, sizeof(**dev_multistate_funcs))))
if (!(dev_multistate_funcs[cur[i].state] = heap_calloc(2, sizeof(**dev_multistate_funcs))))
goto out_of_mem;
dev_multistate_funcs[cur[i].state][0] = multistate_funcs[cur[i].state][0];
......@@ -6178,13 +6178,9 @@ HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_
break;
case 2:
StateTable[cur[i].state].apply = multistate_apply_3;
funcs_array = HeapReAlloc(GetProcessHeap(),
0,
dev_multistate_funcs[cur[i].state],
sizeof(**dev_multistate_funcs) * 3);
if (!funcs_array) {
if (!(funcs_array = heap_realloc(dev_multistate_funcs[cur[i].state],
sizeof(**dev_multistate_funcs) * 3)))
goto out_of_mem;
}
dev_multistate_funcs[cur[i].state] = funcs_array;
dev_multistate_funcs[cur[i].state][2] = multistate_funcs[cur[i].state][2];
......@@ -6210,8 +6206,9 @@ HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_
return WINED3D_OK;
out_of_mem:
for (i = 0; i <= STATE_HIGHEST; ++i) {
HeapFree(GetProcessHeap(), 0, dev_multistate_funcs[i]);
for (i = 0; i <= STATE_HIGHEST; ++i)
{
heap_free(dev_multistate_funcs[i]);
}
memset(dev_multistate_funcs, 0, (STATE_HIGHEST + 1)*sizeof(*dev_multistate_funcs));
......
......@@ -404,7 +404,7 @@ static void stateblock_init_lights(struct wined3d_stateblock *stateblock, struct
LIST_FOR_EACH_ENTRY(src_light, &light_map[i], struct wined3d_light_info, entry)
{
struct wined3d_light_info *dst_light = HeapAlloc(GetProcessHeap(), 0, sizeof(*dst_light));
struct wined3d_light_info *dst_light = heap_alloc(sizeof(*dst_light));
*dst_light = *src_light;
list_add_tail(&stateblock->state.light_map[i], &dst_light->entry);
......@@ -539,7 +539,7 @@ void state_cleanup(struct wined3d_state *state)
{
struct wined3d_light_info *light = LIST_ENTRY(e1, struct wined3d_light_info, entry);
list_remove(&light->entry);
HeapFree(GetProcessHeap(), 0, light);
heap_free(light);
}
}
}
......@@ -553,7 +553,7 @@ ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
if (!refcount)
{
state_cleanup(&stateblock->state);
HeapFree(GetProcessHeap(), 0, stateblock);
heap_free(stateblock);
}
return refcount;
......@@ -1372,15 +1372,14 @@ HRESULT CDECL wined3d_stateblock_create(struct wined3d_device *device,
TRACE("device %p, type %#x, stateblock %p.\n",
device, type, stateblock);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = stateblock_init(object, device, type);
if (FAILED(hr))
{
WARN("Failed to initialize stateblock, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
......
......@@ -571,7 +571,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
WARN_(d3d_perf)("Downloading all miplevel layers to get the surface data for a single sub-resource.\n");
if (!(temporary_mem = wined3d_calloc(texture->layer_count, sub_resource->size)))
if (!(temporary_mem = heap_calloc(texture->layer_count, sub_resource->size)))
{
ERR("Out of memory.\n");
return;
......@@ -593,7 +593,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
wined3d_texture_get_level_pow2_width(texture, surface->texture_level),
wined3d_texture_get_level_pow2_height(texture, surface->texture_level),
&src_row_pitch, &src_slice_pitch);
if (!(temporary_mem = HeapAlloc(GetProcessHeap(), 0, src_slice_pitch)))
if (!(temporary_mem = heap_alloc(src_slice_pitch)))
{
ERR("Out of memory.\n");
return;
......@@ -622,7 +622,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
wined3d_texture_get_level_height(texture, surface->texture_level),
&src_row_pitch, &src_slice_pitch);
if (!(temporary_mem = HeapAlloc(GetProcessHeap(), 0, src_slice_pitch)))
if (!(temporary_mem = heap_alloc(src_slice_pitch)))
{
ERR("Failed to allocate memory.\n");
return;
......@@ -751,7 +751,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
checkGLcall("glBindBuffer");
}
HeapFree(GetProcessHeap(), 0, temporary_mem);
heap_free(temporary_mem);
}
/* This call just uploads data, the caller is responsible for binding the
......@@ -1016,7 +1016,7 @@ void surface_set_compatible_renderbuffer(struct wined3d_surface *surface, const
gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER,
surface->container->resource.format->glInternal, width, height);
entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
entry = heap_alloc(sizeof(*entry));
entry->width = width;
entry->height = height;
entry->id = renderbuffer;
......@@ -1470,7 +1470,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
/* glReadPixels returns the image upside down, and there is no way to
* prevent this. Flip the lines in software. */
if (!(row = HeapAlloc(GetProcessHeap(), 0, row_pitch)))
if (!(row = heap_alloc(row_pitch)))
goto error;
if (data.buffer_object)
......@@ -1491,7 +1491,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
top += row_pitch;
bottom -= row_pitch;
}
HeapFree(GetProcessHeap(), 0, row);
heap_free(row);
if (data.buffer_object)
GL_EXTCALL(glUnmapBuffer(GL_PIXEL_PACK_BUFFER));
......@@ -2317,7 +2317,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
src_mem = context_map_bo_address(context, &data, src_slice_pitch,
GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READONLY);
if (!(dst_mem = HeapAlloc(GetProcessHeap(), 0, dst_slice_pitch)))
if (!(dst_mem = heap_alloc(dst_slice_pitch)))
{
ERR("Out of memory (%u).\n", dst_slice_pitch);
context_release(context);
......@@ -2341,7 +2341,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
src_mem = context_map_bo_address(context, &data, src_slice_pitch,
GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READONLY);
if (!(dst_mem = HeapAlloc(GetProcessHeap(), 0, dst_slice_pitch)))
if (!(dst_mem = heap_alloc(dst_slice_pitch)))
{
ERR("Out of memory (%u).\n", dst_slice_pitch);
context_release(context);
......@@ -2361,7 +2361,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
wined3d_surface_upload_data(surface, gl_info, &format, &src_rect,
src_row_pitch, &dst_point, srgb, wined3d_const_bo_address(&data));
HeapFree(GetProcessHeap(), 0, dst_mem);
heap_free(dst_mem);
return TRUE;
}
......@@ -2437,7 +2437,7 @@ static void fbo_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_
if ((next = blitter->next))
next->ops->blitter_destroy(next, context);
HeapFree(GetProcessHeap(), 0, blitter);
heap_free(blitter);
}
static void fbo_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_device *device,
......@@ -2511,7 +2511,7 @@ void wined3d_fbo_blitter_create(struct wined3d_blitter **next, const struct wine
if ((wined3d_settings.offscreen_rendering_mode != ORM_FBO) || !gl_info->fbo_ops.glBlitFramebuffer)
return;
if (!(blitter = HeapAlloc(GetProcessHeap(), 0, sizeof(*blitter))))
if (!(blitter = heap_alloc(sizeof(*blitter))))
return;
TRACE("Created blitter %p.\n", blitter);
......@@ -2529,7 +2529,7 @@ static void raw_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_
if ((next = blitter->next))
next->ops->blitter_destroy(next, context);
HeapFree(GetProcessHeap(), 0, blitter);
heap_free(blitter);
}
/* Context activation is done by the caller. */
......@@ -2643,7 +2643,7 @@ void wined3d_raw_blitter_create(struct wined3d_blitter **next, const struct wine
if (!gl_info->supported[ARB_COPY_IMAGE])
return;
if (!(blitter = HeapAlloc(GetProcessHeap(), 0, sizeof(*blitter))))
if (!(blitter = heap_alloc(sizeof(*blitter))))
return;
TRACE("Created blitter %p.\n", blitter);
......@@ -2661,7 +2661,7 @@ static void ffp_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_
if ((next = blitter->next))
next->ops->blitter_destroy(next, context);
HeapFree(GetProcessHeap(), 0, blitter);
heap_free(blitter);
}
static BOOL ffp_blit_supported(enum wined3d_blit_op blit_op, const struct wined3d_context *context,
......@@ -2938,7 +2938,7 @@ void wined3d_ffp_blitter_create(struct wined3d_blitter **next, const struct wine
{
struct wined3d_blitter *blitter;
if (!(blitter = HeapAlloc(GetProcessHeap(), 0, sizeof(*blitter))))
if (!(blitter = heap_alloc(sizeof(*blitter))))
return;
TRACE("Created blitter %p.\n", blitter);
......@@ -2956,7 +2956,7 @@ static void cpu_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_
if ((next = blitter->next))
next->ops->blitter_destroy(next, context);
HeapFree(GetProcessHeap(), 0, blitter);
heap_free(blitter);
}
static HRESULT surface_cpu_blt_compressed(const BYTE *src_data, BYTE *dst_data,
......@@ -3749,7 +3749,7 @@ struct wined3d_blitter *wined3d_cpu_blitter_create(void)
{
struct wined3d_blitter *blitter;
if (!(blitter = HeapAlloc(GetProcessHeap(), 0, sizeof(*blitter))))
if (!(blitter = heap_alloc(sizeof(*blitter))))
return NULL;
TRACE("Created blitter %p.\n", blitter);
......
......@@ -61,7 +61,7 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
if (wined3d_texture_decref(swapchain->back_buffers[i]))
WARN("Something's still holding back buffer %u (%p).\n", i, swapchain->back_buffers[i]);
}
HeapFree(GetProcessHeap(), 0, swapchain->back_buffers);
heap_free(swapchain->back_buffers);
swapchain->back_buffers = NULL;
}
......@@ -120,7 +120,7 @@ ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain)
swapchain_cleanup(swapchain);
swapchain->parent_ops->wined3d_object_destroyed(swapchain->parent);
HeapFree(GetProcessHeap(), 0, swapchain);
heap_free(swapchain);
}
return refcount;
......@@ -885,8 +885,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
if (!(device->wined3d->flags & WINED3D_NO3D))
{
swapchain->context = HeapAlloc(GetProcessHeap(), 0, sizeof(*swapchain->context));
if (!swapchain->context)
if (!(swapchain->context = heap_alloc(sizeof(*swapchain->context))))
{
ERR("Failed to create the context array.\n");
hr = E_OUTOFMEMORY;
......@@ -905,7 +904,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
if (swapchain->desc.backbuffer_count > 0)
{
if (!(swapchain->back_buffers = wined3d_calloc(swapchain->desc.backbuffer_count,
if (!(swapchain->back_buffers = heap_calloc(swapchain->desc.backbuffer_count,
sizeof(*swapchain->back_buffers))))
{
ERR("Failed to allocate backbuffer array memory.\n");
......@@ -987,7 +986,7 @@ err:
wined3d_texture_decref(swapchain->back_buffers[i]);
}
}
HeapFree(GetProcessHeap(), 0, swapchain->back_buffers);
heap_free(swapchain->back_buffers);
}
wined3d_cs_destroy_object(swapchain->device->cs, wined3d_swapchain_destroy_object, swapchain);
......@@ -1011,15 +1010,14 @@ HRESULT CDECL wined3d_swapchain_create(struct wined3d_device *device, struct win
TRACE("device %p, desc %p, parent %p, parent_ops %p, swapchain %p.\n",
device, desc, parent, parent_ops, swapchain);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = swapchain_init(object, device, desc, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize swapchain, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
......@@ -1043,14 +1041,14 @@ static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain
}
context_release(ctx);
if (!(ctx_array = wined3d_calloc(swapchain->num_contexts + 1, sizeof(*ctx_array))))
if (!(ctx_array = heap_calloc(swapchain->num_contexts + 1, sizeof(*ctx_array))))
{
ERR("Out of memory when trying to allocate a new context array\n");
context_destroy(swapchain->device, ctx);
return NULL;
}
memcpy(ctx_array, swapchain->context, sizeof(*ctx_array) * swapchain->num_contexts);
HeapFree(GetProcessHeap(), 0, swapchain->context);
heap_free(swapchain->context);
ctx_array[swapchain->num_contexts] = ctx;
swapchain->context = ctx_array;
swapchain->num_contexts++;
......@@ -1067,7 +1065,7 @@ void swapchain_destroy_contexts(struct wined3d_swapchain *swapchain)
{
context_destroy(swapchain->device, swapchain->context[i]);
}
HeapFree(GetProcessHeap(), 0, swapchain->context);
heap_free(swapchain->context);
swapchain->num_contexts = 0;
swapchain->context = NULL;
}
......
......@@ -962,7 +962,7 @@ static void wined3d_texture_cleanup_sync(struct wined3d_texture *texture)
static void wined3d_texture_destroy_object(void *object)
{
wined3d_texture_cleanup(object);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
}
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
......@@ -1752,7 +1752,7 @@ static void texture2d_cleanup_sub_resources(struct wined3d_texture *texture)
TRACE("Deleting renderbuffer %u.\n", entry->id);
context_gl_resource_released(device, entry->id, TRUE);
gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
HeapFree(GetProcessHeap(), 0, entry);
heap_free(entry);
}
if (surface->dc)
......@@ -1769,7 +1769,7 @@ static void texture2d_cleanup_sub_resources(struct wined3d_texture *texture)
}
if (context)
context_release(context);
HeapFree(GetProcessHeap(), 0, texture->sub_resources[0].u.surface);
heap_free(texture->sub_resources[0].u.surface);
}
static const struct wined3d_texture_ops texture2d_ops =
......@@ -1854,7 +1854,7 @@ static void wined3d_texture_unload(struct wined3d_resource *resource)
context_gl_resource_released(device, entry->id, TRUE);
gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
list_remove(&entry->entry);
HeapFree(GetProcessHeap(), 0, entry);
heap_free(entry);
}
list_init(&surface->renderbuffers);
surface->current_renderbuffer = NULL;
......@@ -2223,7 +2223,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
if (level_count > ~(SIZE_T)0 / layer_count
|| !(surfaces = wined3d_calloc(level_count * layer_count, sizeof(*surfaces))))
|| !(surfaces = heap_calloc(level_count * layer_count, sizeof(*surfaces))))
{
wined3d_texture_cleanup_sync(texture);
return E_OUTOFMEMORY;
......@@ -2344,7 +2344,7 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int
dst_row_pitch = update_w * format->conv_byte_count;
dst_slice_pitch = dst_row_pitch * update_h;
converted_mem = wined3d_calloc(update_d, dst_slice_pitch);
converted_mem = heap_calloc(update_d, dst_slice_pitch);
format->upload(data->addr, converted_mem, row_pitch, slice_pitch,
dst_row_pitch, dst_slice_pitch, update_w, update_h, update_d);
mem = converted_mem;
......@@ -2372,7 +2372,7 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int
checkGLcall("glBindBuffer");
}
HeapFree(GetProcessHeap(), 0, converted_mem);
heap_free(converted_mem);
}
/* Context activation is done by the caller. */
......@@ -2423,7 +2423,7 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in
* for DEFAULT pool surfaces. */
WARN_(d3d_perf)("Performing slow rgb/srgb volume transfer.\n");
data.buffer_object = 0;
if (!(data.addr = HeapAlloc(GetProcessHeap(), 0, sub_resource->size)))
if (!(data.addr = heap_alloc(sub_resource->size)))
return;
wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
......@@ -2433,7 +2433,7 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in
texture3d_upload_data(texture, sub_resource_idx, context,
NULL, wined3d_const_bo_address(&data), row_pitch, slice_pitch);
HeapFree(GetProcessHeap(), 0, data.addr);
heap_free(data.addr);
}
/* Context activation is done by the caller. */
......@@ -2988,8 +2988,8 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
}
}
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
FIELD_OFFSET(struct wined3d_texture, sub_resources[level_count * layer_count]))))
if (!(object = heap_alloc_zero(FIELD_OFFSET(struct wined3d_texture,
sub_resources[level_count * layer_count]))))
return E_OUTOFMEMORY;
switch (desc->resource_type)
......@@ -3011,7 +3011,7 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
if (FAILED(hr))
{
WARN("Failed to initialize texture, returning %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
......@@ -3028,7 +3028,7 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
{
WARN("Invalid sub-resource data specified for sub-resource %u.\n", i);
wined3d_texture_cleanup_sync(object);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return E_INVALIDARG;
}
}
......
......@@ -1828,7 +1828,7 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
unsigned int i, j;
gl_info->format_count = WINED3D_FORMAT_COUNT;
if (!(gl_info->formats = wined3d_calloc(gl_info->format_count
if (!(gl_info->formats = heap_calloc(gl_info->format_count
+ ARRAY_SIZE(typeless_depth_stencil_formats), sizeof(*gl_info->formats))))
{
ERR("Failed to allocate memory.\n");
......@@ -1922,7 +1922,7 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
return TRUE;
fail:
HeapFree(GetProcessHeap(), 0, gl_info->formats);
heap_free(gl_info->formats);
return FALSE;
}
......@@ -3806,7 +3806,7 @@ BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, struct wi
return TRUE;
fail:
HeapFree(GetProcessHeap(), 0, gl_info->formats);
heap_free(gl_info->formats);
gl_info->formats = NULL;
return FALSE;
}
......@@ -6159,7 +6159,7 @@ BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE
new_capacity = count;
if (!*elements)
new_elements = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, new_capacity * size);
new_elements = heap_alloc_zero(new_capacity * size);
else
new_elements = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *elements, new_capacity * size);
if (!new_elements)
......
......@@ -54,8 +54,8 @@ static void wined3d_vertex_declaration_destroy_object(void *object)
{
struct wined3d_vertex_declaration *declaration = object;
HeapFree(GetProcessHeap(), 0, declaration->elements);
HeapFree(GetProcessHeap(), 0, declaration);
heap_free(declaration->elements);
heap_free(declaration);
}
ULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration)
......@@ -188,7 +188,7 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara
declaration->parent = parent;
declaration->parent_ops = parent_ops;
declaration->device = device;
if (!(declaration->elements = wined3d_calloc(element_count, sizeof(*declaration->elements))))
if (!(declaration->elements = heap_calloc(element_count, sizeof(*declaration->elements))))
{
ERR("Failed to allocate elements memory.\n");
return E_OUTOFMEMORY;
......@@ -223,7 +223,7 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara
{
FIXME("The application tries to use an unsupported format (%s), returning E_FAIL.\n",
debug_d3dformat(elements[i].format));
HeapFree(GetProcessHeap(), 0, declaration->elements);
heap_free(declaration->elements);
return E_FAIL;
}
......@@ -247,7 +247,7 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara
if (e->offset & 0x3)
{
WARN("Declaration element %u is not 4 byte aligned(%u), returning E_FAIL.\n", i, e->offset);
HeapFree(GetProcessHeap(), 0, declaration->elements);
heap_free(declaration->elements);
return E_FAIL;
}
......@@ -270,15 +270,14 @@ HRESULT CDECL wined3d_vertex_declaration_create(struct wined3d_device *device,
TRACE("device %p, elements %p, element_count %u, parent %p, parent_ops %p, declaration %p.\n",
device, elements, element_count, parent, parent_ops, declaration);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if(!object)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = vertexdeclaration_init(object, device, elements, element_count, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return hr;
}
......@@ -346,7 +345,7 @@ static unsigned int convert_fvf_to_declaration(const struct wined3d_gl_info *gl_
has_psize + has_diffuse + has_specular + num_textures;
state.gl_info = gl_info;
if (!(state.elements = wined3d_calloc(size, sizeof(*state.elements))))
if (!(state.elements = heap_calloc(size, sizeof(*state.elements))))
return ~0u;
state.offset = 0;
state.idx = 0;
......@@ -445,6 +444,6 @@ HRESULT CDECL wined3d_vertex_declaration_create_from_fvf(struct wined3d_device *
if (size == ~0U) return E_OUTOFMEMORY;
hr = wined3d_vertex_declaration_create(device, elements, size, parent, parent_ops, declaration);
HeapFree(GetProcessHeap(), 0, elements);
heap_free(elements);
return hr;
}
......@@ -337,7 +337,7 @@ static void wined3d_rendertarget_view_destroy_object(void *object)
context_release(context);
}
HeapFree(GetProcessHeap(), 0, view);
heap_free(view);
}
ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view)
......@@ -600,12 +600,12 @@ HRESULT CDECL wined3d_rendertarget_view_create(const struct wined3d_view_desc *d
TRACE("desc %p, resource %p, parent %p, parent_ops %p, view %p.\n",
desc, resource, parent, parent_ops, view);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = wined3d_rendertarget_view_init(object, desc, resource, parent, parent_ops)))
{
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
WARN("Failed to initialise view, hr %#x.\n", hr);
return hr;
}
......@@ -660,7 +660,7 @@ static void wined3d_shader_resource_view_destroy_object(void *object)
context_release(context);
}
HeapFree(GetProcessHeap(), 0, view);
heap_free(view);
}
ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view)
......@@ -776,12 +776,12 @@ HRESULT CDECL wined3d_shader_resource_view_create(const struct wined3d_view_desc
TRACE("desc %p, resource %p, parent %p, parent_ops %p, view %p.\n",
desc, resource, parent, parent_ops, view);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = wined3d_shader_resource_view_init(object, desc, resource, parent, parent_ops)))
{
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
WARN("Failed to initialise view, hr %#x.\n", hr);
return hr;
}
......@@ -952,7 +952,7 @@ static void wined3d_unordered_access_view_destroy_object(void *object)
context_release(context);
}
HeapFree(GetProcessHeap(), 0, view);
heap_free(view);
}
ULONG CDECL wined3d_unordered_access_view_decref(struct wined3d_unordered_access_view *view)
......@@ -1144,12 +1144,12 @@ HRESULT CDECL wined3d_unordered_access_view_create(const struct wined3d_view_des
TRACE("desc %p, resource %p, parent %p, parent_ops %p, view %p.\n",
desc, resource, parent, parent_ops, view);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = wined3d_unordered_access_view_init(object, desc, resource, parent, parent_ops)))
{
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
WARN("Failed to initialise view, hr %#x.\n", hr);
return hr;
}
......
......@@ -99,8 +99,7 @@ struct wined3d * CDECL wined3d_create(DWORD flags)
struct wined3d *object;
HRESULT hr;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(struct wined3d, adapters[1]));
if (!object)
if (!(object = heap_alloc_zero(FIELD_OFFSET(struct wined3d, adapters[1]))))
{
ERR("Failed to allocate wined3d object memory.\n");
return NULL;
......@@ -113,7 +112,7 @@ struct wined3d * CDECL wined3d_create(DWORD flags)
if (FAILED(hr))
{
WARN("Failed to initialize wined3d object, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
heap_free(object);
return NULL;
}
......@@ -281,9 +280,10 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
{
size_t len = strlen(buffer) + 1;
wined3d_settings.logo = HeapAlloc(GetProcessHeap(), 0, len);
if (!wined3d_settings.logo) ERR("Failed to allocate logo path memory.\n");
else memcpy(wined3d_settings.logo, buffer, len);
if (!(wined3d_settings.logo = heap_alloc(len)))
ERR("Failed to allocate logo path memory.\n");
else
memcpy(wined3d_settings.logo, buffer, len);
}
if (!get_config_key_dword(hkey, appkey, "MultisampleTextures", &wined3d_settings.multisample_textures))
ERR_(winediag)("Setting multisample textures to %#x.\n", wined3d_settings.multisample_textures);
......@@ -350,9 +350,9 @@ static BOOL wined3d_dll_destroy(HINSTANCE hInstDLL)
* these entries. */
WARN("Leftover wndproc table entry %p.\n", &wndproc_table.entries[i]);
}
HeapFree(GetProcessHeap(), 0, wndproc_table.entries);
heap_free(wndproc_table.entries);
HeapFree(GetProcessHeap(), 0, wined3d_settings.logo);
heap_free(wined3d_settings.logo);
UnregisterClassA(WINED3D_OPENGL_WINDOW_CLASS_NAME, hInstDLL);
DeleteCriticalSection(&wined3d_wndproc_cs);
......
......@@ -48,6 +48,7 @@
#include "winternl.h"
#include "ddk/d3dkmthk.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/unicode.h"
#include "objbase.h"
......@@ -4294,13 +4295,6 @@ static inline BOOL wined3d_format_is_typeless(const struct wined3d_format *forma
return format->id == format->typeless_id && format->id != WINED3DFMT_UNKNOWN;
}
static inline void *wined3d_calloc(SIZE_T count, SIZE_T size)
{
if (count > ~(SIZE_T)0 / size)
return NULL;
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * size);
}
static inline BOOL use_vs(const struct wined3d_state *state)
{
/* Check state->vertex_declaration to allow this to be used before the
......
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