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