[PATCH 2/5] wined3d: Introduce a helper function to allocate arrays.
Henri Verbeet
hverbeet at codeweavers.com
Mon May 23 11:06:27 CDT 2016
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/wined3d/arb_program_shader.c | 5 ++---
dlls/wined3d/buffer.c | 23 +++++++++++------------
dlls/wined3d/context.c | 23 ++++++++---------------
dlls/wined3d/cs.c | 3 +--
dlls/wined3d/device.c | 10 ++++------
dlls/wined3d/directx.c | 4 ++--
dlls/wined3d/glsl_shader.c | 8 +++-----
dlls/wined3d/shader.c | 13 ++++++-------
dlls/wined3d/state.c | 6 +-----
dlls/wined3d/surface.c | 2 +-
dlls/wined3d/swapchain.c | 17 ++++++++---------
dlls/wined3d/texture.c | 5 +++--
dlls/wined3d/utils.c | 3 +--
dlls/wined3d/vertexdeclaration.c | 7 +++----
dlls/wined3d/volume.c | 2 +-
dlls/wined3d/wined3d_main.c | 6 ++++--
dlls/wined3d/wined3d_private.h | 7 +++++++
17 files changed, 66 insertions(+), 78 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 80702a2..1093a36 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -3994,7 +3994,7 @@ static void clone_sig(struct wined3d_shader_signature *new, const struct wined3d
char *name;
new->element_count = sig->element_count;
- new->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*new->elements) * new->element_count);
+ new->elements = wined3d_calloc(new->element_count, sizeof(*new->elements));
for (i = 0; i < sig->element_count; ++i)
{
new->elements[i] = sig->elements[i];
@@ -5484,8 +5484,7 @@ static void record_instruction(struct list *list, const struct wined3d_shader_in
}
rec->ins.dst = dst_param;
- src_param = HeapAlloc(GetProcessHeap(), 0, sizeof(*src_param) * ins->src_count);
- if (!src_param)
+ if (!(src_param = wined3d_calloc(ins->src_count, sizeof(*src_param))))
goto free;
for (i = 0; i < ins->src_count; ++i)
{
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index ce4d9d7..5ddf67d 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -211,7 +211,7 @@ fail:
buffer_clear_dirty_areas(This);
}
-static BOOL buffer_process_converted_attribute(struct wined3d_buffer *This,
+static BOOL buffer_process_converted_attribute(struct wined3d_buffer *buffer,
const enum wined3d_buffer_conversion_type conversion_type,
const struct wined3d_stream_info_element *attrib, DWORD *stride_this_run)
{
@@ -237,31 +237,30 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *This,
else
{
*stride_this_run = attrib->stride;
- if (This->stride != *stride_this_run)
+ if (buffer->stride != *stride_this_run)
{
/* We rely that this happens only on the first converted attribute that is found,
* if at all. See above check
*/
TRACE("Reconverting because converted attributes occur, and the stride changed\n");
- This->stride = *stride_this_run;
- HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, This->conversion_map);
- This->conversion_map = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof(*This->conversion_map) * This->stride);
+ buffer->stride = *stride_this_run;
+ HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, buffer->conversion_map);
+ buffer->conversion_map = wined3d_calloc(buffer->stride, sizeof(*buffer->conversion_map));
ret = TRUE;
}
}
- data = ((DWORD_PTR)attrib->data.addr) % This->stride;
+ data = ((DWORD_PTR)attrib->data.addr) % buffer->stride;
attrib_size = attrib->format->component_count * attrib->format->component_size;
for (i = 0; i < attrib_size; ++i)
{
- DWORD_PTR idx = (data + i) % This->stride;
- if (This->conversion_map[idx] != conversion_type)
+ DWORD_PTR idx = (data + i) % buffer->stride;
+ if (buffer->conversion_map[idx] != conversion_type)
{
- TRACE("Byte %ld in vertex changed\n", idx);
- TRACE("It was type %d, is %d now\n", This->conversion_map[idx], conversion_type);
+ TRACE("Byte %lu in vertex changed:\n", idx);
+ TRACE(" It was type %#x, is %#x now.\n", buffer->conversion_map[idx], conversion_type);
ret = TRUE;
- This->conversion_map[idx] = conversion_type;
+ buffer->conversion_map[idx] = conversion_type;
}
}
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index e741969..d5dfa61 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1636,14 +1636,10 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
if (!ret)
return NULL;
- ret->blit_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- gl_info->limits.buffers * sizeof(*ret->blit_targets));
- if (!ret->blit_targets)
+ if (!(ret->blit_targets = wined3d_calloc(gl_info->limits.buffers, sizeof(*ret->blit_targets))))
goto out;
- ret->draw_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- gl_info->limits.buffers * sizeof(*ret->draw_buffers));
- if (!ret->draw_buffers)
+ if (!(ret->draw_buffers = wined3d_calloc(gl_info->limits.buffers, sizeof(*ret->draw_buffers))))
goto out;
ret->fbo_key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
@@ -1652,24 +1648,21 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
goto out;
ret->free_timestamp_query_size = 4;
- ret->free_timestamp_queries = HeapAlloc(GetProcessHeap(), 0,
- ret->free_timestamp_query_size * sizeof(*ret->free_timestamp_queries));
- if (!ret->free_timestamp_queries)
+ if (!(ret->free_timestamp_queries = wined3d_calloc(ret->free_timestamp_query_size,
+ sizeof(*ret->free_timestamp_queries))))
goto out;
list_init(&ret->timestamp_queries);
ret->free_occlusion_query_size = 4;
- ret->free_occlusion_queries = HeapAlloc(GetProcessHeap(), 0,
- ret->free_occlusion_query_size * sizeof(*ret->free_occlusion_queries));
- if (!ret->free_occlusion_queries)
+ if (!(ret->free_occlusion_queries = wined3d_calloc(ret->free_occlusion_query_size,
+ sizeof(*ret->free_occlusion_queries))))
goto out;
list_init(&ret->occlusion_queries);
ret->free_event_query_size = 4;
- ret->free_event_queries = HeapAlloc(GetProcessHeap(), 0,
- ret->free_event_query_size * sizeof(*ret->free_event_queries));
- if (!ret->free_event_queries)
+ if (!(ret->free_event_queries = wined3d_calloc(ret->free_event_query_size,
+ sizeof(*ret->free_event_queries))))
goto out;
list_init(&ret->event_queries);
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 254a1f7..c91b114 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -1128,8 +1128,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
if (!(cs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cs))))
return NULL;
- if (!(cs->fb.render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof(*cs->fb.render_targets) * gl_info->limits.buffers)))
+ if (!(cs->fb.render_targets = wined3d_calloc(gl_info->limits.buffers, sizeof(*cs->fb.render_targets))))
{
HeapFree(GetProcessHeap(), 0, cs);
return NULL;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 5bac3d0..5171a8e 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1005,8 +1005,8 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
if (device->wined3d->flags & WINED3D_NO3D)
return WINED3DERR_INVALIDCALL;
- device->fb.render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof(*device->fb.render_targets) * gl_info->limits.buffers);
+ if (!(device->fb.render_targets = wined3d_calloc(gl_info->limits.buffers, sizeof(*device->fb.render_targets))))
+ return E_OUTOFMEMORY;
if (FAILED(hr = device->shader_backend->shader_alloc_private(device,
device->adapter->vertex_pipe, device->adapter->fragment_pipe)))
@@ -1047,8 +1047,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
}
device->swapchain_count = 1;
- device->swapchains = HeapAlloc(GetProcessHeap(), 0, device->swapchain_count * sizeof(*device->swapchains));
- if (!device->swapchains)
+ if (!(device->swapchains = wined3d_calloc(device->swapchain_count, sizeof(*device->swapchains))))
{
ERR("Out of memory!\n");
goto err_out;
@@ -1116,8 +1115,7 @@ HRESULT CDECL wined3d_device_init_gdi(struct wined3d_device *device,
}
device->swapchain_count = 1;
- device->swapchains = HeapAlloc(GetProcessHeap(), 0, device->swapchain_count * sizeof(*device->swapchains));
- if (!device->swapchains)
+ if (!(device->swapchains = wined3d_calloc(device->swapchain_count, sizeof(*device->swapchains))))
{
ERR("Out of memory!\n");
goto err_out;
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 711e171..4de3990 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -5846,7 +5846,7 @@ static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc
attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, 0, 0, 1, &attribute, &cfg_count));
- adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cfg_count * sizeof(*adapter->cfgs));
+ adapter->cfgs = wined3d_calloc(cfg_count, sizeof(*adapter->cfgs));
attribs[attrib_count++] = WGL_RED_BITS_ARB;
attribs[attrib_count++] = WGL_GREEN_BITS_ARB;
attribs[attrib_count++] = WGL_BLUE_BITS_ARB;
@@ -5911,7 +5911,7 @@ static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc
int cfg_count;
cfg_count = DescribePixelFormat(dc, 0, 0, 0);
- adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cfg_count * sizeof(*adapter->cfgs));
+ adapter->cfgs = wined3d_calloc(cfg_count, sizeof(*adapter->cfgs));
for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
{
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index d3a0ebf..8a6215f 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -442,8 +442,7 @@ static void shader_glsl_dump_program_source(const struct wined3d_gl_info *gl_inf
char *source = NULL;
GL_EXTCALL(glGetProgramiv(program, GL_ATTACHED_SHADERS, &shader_count));
- shaders = HeapAlloc(GetProcessHeap(), 0, shader_count * sizeof(*shaders));
- if (!shaders)
+ if (!(shaders = wined3d_calloc(shader_count, sizeof(*shaders))))
{
ERR("Failed to allocate shader array memory.\n");
return;
@@ -5217,7 +5216,7 @@ static void shader_glsl_setup_vs3_output(struct shader_glsl_priv *priv,
unsigned int i, j;
char reg_mask[6];
- set = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*set) * max_varyings);
+ set = wined3d_calloc(max_varyings, sizeof(*set));
for (i = 0; i < input_signature->element_count; ++i)
{
@@ -8234,8 +8233,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
goto fail;
}
- priv->stack = HeapAlloc(GetProcessHeap(), 0, stack_size * sizeof(*priv->stack));
- if (!priv->stack)
+ if (!(priv->stack = wined3d_calloc(stack_size, sizeof(*priv->stack))))
{
ERR("Failed to allocate memory.\n");
goto fail;
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 0a6c1b9..3c4d092 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -752,7 +752,7 @@ static void shader_record_sample(struct wined3d_shader_reg_maps *reg_maps,
if (!map->size)
{
- if (!(entries = HeapAlloc(GetProcessHeap(), 0, sizeof(*entries) * 4)))
+ if (!(entries = wined3d_calloc(4, sizeof(*entries))))
{
ERR("Failed to allocate sampler map entries.\n");
return;
@@ -823,9 +823,8 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
shader_set_limits(shader);
- reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof(*reg_maps->constf) * ((min(shader->limits->constant_float, constf_size) + 31) / 32));
- if (!reg_maps->constf)
+ if (!(reg_maps->constf = wined3d_calloc(((min(shader->limits->constant_float, constf_size) + 31) / 32),
+ sizeof(*reg_maps->constf))))
{
ERR("Failed to allocate constant map memory.\n");
return E_OUTOFMEMORY;
@@ -1255,7 +1254,7 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
struct wined3d_shader_signature_element *e;
unsigned int i;
- if (!(input_signature->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*input_signature->elements) * count)))
+ if (!(input_signature->elements = wined3d_calloc(count, sizeof(*input_signature->elements))))
return E_OUTOFMEMORY;
input_signature->element_count = count;
@@ -1281,7 +1280,7 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
unsigned int count = wined3d_popcount(reg_maps->output_registers);
struct wined3d_shader_signature_element *e;
- if (!(output_signature->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*output_signature->elements) * count)))
+ if (!(output_signature->elements = wined3d_calloc(count, sizeof(*output_signature->elements))))
return E_OUTOFMEMORY;
output_signature->element_count = count;
@@ -2742,7 +2741,7 @@ static HRESULT shader_signature_copy(struct wined3d_shader_signature *dst,
ptr = *signature_strings;
dst->element_count = src->element_count;
- if (!(dst->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*dst->elements) * dst->element_count)))
+ if (!(dst->elements = wined3d_calloc(dst->element_count, sizeof(*dst->elements))))
return E_OUTOFMEMORY;
for (i = 0; i < src->element_count; ++i)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 878de54..dabc5cf 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -5983,12 +5983,8 @@ HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_
break;
case 1:
StateTable[cur[i].state].apply = multistate_apply_2;
- dev_multistate_funcs[cur[i].state] = HeapAlloc(GetProcessHeap(),
- 0,
- sizeof(**dev_multistate_funcs) * 2);
- if (!dev_multistate_funcs[cur[i].state]) {
+ if (!(dev_multistate_funcs[cur[i].state] = wined3d_calloc(2, sizeof(**dev_multistate_funcs))))
goto out_of_mem;
- }
dev_multistate_funcs[cur[i].state][0] = multistate_funcs[cur[i].state][0];
dev_multistate_funcs[cur[i].state][1] = multistate_funcs[cur[i].state][1];
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 5534e73..781006f 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -790,7 +790,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
WARN_(d3d_perf)("Downloading all miplevel layers to get the surface data for a single sub-resource.\n");
- if (!(temporary_mem = HeapAlloc(GetProcessHeap(), 0, texture->layer_count * sub_resource->size)))
+ if (!(temporary_mem = wined3d_calloc(texture->layer_count, sub_resource->size)))
{
ERR("Out of memory.\n");
return;
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 7368cda..0df7023 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -980,9 +980,8 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
if (swapchain->desc.backbuffer_count > 0)
{
- swapchain->back_buffers = HeapAlloc(GetProcessHeap(), 0,
- sizeof(*swapchain->back_buffers) * swapchain->desc.backbuffer_count);
- if (!swapchain->back_buffers)
+ if (!(swapchain->back_buffers = wined3d_calloc(swapchain->desc.backbuffer_count,
+ sizeof(*swapchain->back_buffers))))
{
ERR("Failed to allocate backbuffer array memory.\n");
hr = E_OUTOFMEMORY;
@@ -1113,7 +1112,7 @@ HRESULT CDECL wined3d_swapchain_create(struct wined3d_device *device, struct win
static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain *swapchain)
{
- struct wined3d_context **newArray;
+ struct wined3d_context **ctx_array;
struct wined3d_context *ctx;
TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId());
@@ -1125,16 +1124,16 @@ static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain
}
context_release(ctx);
- newArray = HeapAlloc(GetProcessHeap(), 0, sizeof(*newArray) * (swapchain->num_contexts + 1));
- if(!newArray) {
+ if (!(ctx_array = wined3d_calloc(swapchain->num_contexts + 1, sizeof(*ctx_array))))
+ {
ERR("Out of memory when trying to allocate a new context array\n");
context_destroy(swapchain->device, ctx);
return NULL;
}
- memcpy(newArray, swapchain->context, sizeof(*newArray) * swapchain->num_contexts);
+ memcpy(ctx_array, swapchain->context, sizeof(*ctx_array) * swapchain->num_contexts);
HeapFree(GetProcessHeap(), 0, swapchain->context);
- newArray[swapchain->num_contexts] = ctx;
- swapchain->context = newArray;
+ ctx_array[swapchain->num_contexts] = ctx;
+ swapchain->context = ctx_array;
swapchain->num_contexts++;
TRACE("Returning context %p\n", ctx);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index e0bb82f..a7f28d5 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1938,7 +1938,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
if (wined3d_texture_use_pbo(texture, gl_info))
texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
- if (!(surfaces = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*surfaces) * level_count * layer_count)))
+ if (level_count > ~(SIZE_T)0 / layer_count
+ || !(surfaces = wined3d_calloc(level_count * layer_count, sizeof(*surfaces))))
{
wined3d_texture_cleanup(texture);
return E_OUTOFMEMORY;
@@ -2205,7 +2206,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
}
- if (!(volumes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*volumes) * level_count)))
+ if (!(volumes = wined3d_calloc(level_count, sizeof(*volumes))))
{
wined3d_texture_cleanup(texture);
return E_OUTOFMEMORY;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 370acce..5c781cd 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -1580,8 +1580,7 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
unsigned int i, j;
gl_info->format_count = WINED3D_FORMAT_COUNT;
- if (!(gl_info->formats = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- gl_info->format_count * sizeof(*gl_info->formats))))
+ if (!(gl_info->formats = wined3d_calloc(gl_info->format_count, sizeof(*gl_info->formats))))
{
ERR("Failed to allocate memory.\n");
return FALSE;
diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c
index 9eb5907..febd695 100644
--- a/dlls/wined3d/vertexdeclaration.c
+++ b/dlls/wined3d/vertexdeclaration.c
@@ -180,8 +180,7 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara
declaration->parent = parent;
declaration->parent_ops = parent_ops;
declaration->device = device;
- declaration->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*declaration->elements) * element_count);
- if (!declaration->elements)
+ if (!(declaration->elements = wined3d_calloc(element_count, sizeof(*declaration->elements))))
{
ERR("Failed to allocate elements memory.\n");
return E_OUTOFMEMORY;
@@ -339,8 +338,8 @@ static unsigned int convert_fvf_to_declaration(const struct wined3d_gl_info *gl_
has_psize + has_diffuse + has_specular + num_textures;
state.gl_info = gl_info;
- state.elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(*state.elements));
- if (!state.elements) return ~0U;
+ if (!(state.elements = wined3d_calloc(size, sizeof(*state.elements))))
+ return ~0u;
state.offset = 0;
state.idx = 0;
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index f59f963..98e184d 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -62,7 +62,7 @@ void wined3d_volume_upload_data(struct wined3d_texture *texture, unsigned int su
wined3d_texture_get_pitch(texture, level, &src_row_pitch, &src_slice_pitch);
- converted_mem = HeapAlloc(GetProcessHeap(), 0, dst_slice_pitch * depth);
+ converted_mem = wined3d_calloc(depth, dst_slice_pitch);
format->convert(data->addr, converted_mem, src_row_pitch, src_slice_pitch,
dst_row_pitch, dst_slice_pitch, width, height, depth);
mem = converted_mem;
diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
index 9d1c11d..0a52528 100644
--- a/dlls/wined3d/wined3d_main.c
+++ b/dlls/wined3d/wined3d_main.c
@@ -452,8 +452,10 @@ BOOL wined3d_register_window(HWND window, struct wined3d_device *device)
unsigned int new_size = max(1, wndproc_table.size * 2);
struct wined3d_wndproc *new_entries;
- if (!wndproc_table.entries) new_entries = HeapAlloc(GetProcessHeap(), 0, new_size * sizeof(*new_entries));
- else new_entries = HeapReAlloc(GetProcessHeap(), 0, wndproc_table.entries, new_size * sizeof(*new_entries));
+ if (!wndproc_table.entries)
+ new_entries = wined3d_calloc(new_size, sizeof(*new_entries));
+ else
+ new_entries = HeapReAlloc(GetProcessHeap(), 0, wndproc_table.entries, new_size * sizeof(*new_entries));
if (!new_entries)
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 8c19aa8..f3ad8ef 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3533,6 +3533,13 @@ void wined3d_format_get_float_color_key(const struct wined3d_format *format,
const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;
+static inline void *wined3d_calloc(SIZE_T count, SIZE_T size)
+{
+ if (count > ~(SIZE_T)0 / size)
+ return NULL;
+ return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * size);
+}
+
static inline BOOL use_vs(const struct wined3d_state *state)
{
/* Check state->vertex_declaration to allow this to be used before the
--
2.1.4
More information about the wine-patches
mailing list