wined3d: Introduce a helper function to allocate arrays.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2016-05-23 18:06:27 +02:00 committed by Alexandre Julliard
parent 10e601ba3c
commit 8ae3a9b624
17 changed files with 66 additions and 78 deletions

View File

@ -3994,7 +3994,7 @@ static void clone_sig(struct wined3d_shader_signature *new, const struct wined3d
char *name; char *name;
new->element_count = sig->element_count; 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) for (i = 0; i < sig->element_count; ++i)
{ {
new->elements[i] = sig->elements[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; rec->ins.dst = dst_param;
src_param = HeapAlloc(GetProcessHeap(), 0, sizeof(*src_param) * ins->src_count); if (!(src_param = wined3d_calloc(ins->src_count, sizeof(*src_param))))
if (!src_param)
goto free; goto free;
for (i = 0; i < ins->src_count; ++i) for (i = 0; i < ins->src_count; ++i)
{ {

View File

@ -211,7 +211,7 @@ fail:
buffer_clear_dirty_areas(This); 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 enum wined3d_buffer_conversion_type conversion_type,
const struct wined3d_stream_info_element *attrib, DWORD *stride_this_run) 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 else
{ {
*stride_this_run = attrib->stride; *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, /* We rely that this happens only on the first converted attribute that is found,
* if at all. See above check * if at all. See above check
*/ */
TRACE("Reconverting because converted attributes occur, and the stride changed\n"); TRACE("Reconverting because converted attributes occur, and the stride changed\n");
This->stride = *stride_this_run; buffer->stride = *stride_this_run;
HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, This->conversion_map); HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, buffer->conversion_map);
This->conversion_map = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buffer->conversion_map = wined3d_calloc(buffer->stride, sizeof(*buffer->conversion_map));
sizeof(*This->conversion_map) * This->stride);
ret = TRUE; 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; attrib_size = attrib->format->component_count * attrib->format->component_size;
for (i = 0; i < attrib_size; ++i) for (i = 0; i < attrib_size; ++i)
{ {
DWORD_PTR idx = (data + i) % This->stride; DWORD_PTR idx = (data + i) % buffer->stride;
if (This->conversion_map[idx] != conversion_type) if (buffer->conversion_map[idx] != conversion_type)
{ {
TRACE("Byte %ld in vertex changed\n", idx); TRACE("Byte %lu in vertex changed:\n", idx);
TRACE("It was type %d, is %d now\n", This->conversion_map[idx], conversion_type); TRACE(" It was type %#x, is %#x now.\n", buffer->conversion_map[idx], conversion_type);
ret = TRUE; ret = TRUE;
This->conversion_map[idx] = conversion_type; buffer->conversion_map[idx] = conversion_type;
} }
} }

View File

@ -1636,14 +1636,10 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
if (!ret) if (!ret)
return NULL; return NULL;
ret->blit_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, if (!(ret->blit_targets = wined3d_calloc(gl_info->limits.buffers, sizeof(*ret->blit_targets))))
gl_info->limits.buffers * sizeof(*ret->blit_targets));
if (!ret->blit_targets)
goto out; goto out;
ret->draw_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, if (!(ret->draw_buffers = wined3d_calloc(gl_info->limits.buffers, sizeof(*ret->draw_buffers))))
gl_info->limits.buffers * sizeof(*ret->draw_buffers));
if (!ret->draw_buffers)
goto out; goto out;
ret->fbo_key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ret->fbo_key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
@ -1652,24 +1648,21 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
goto out; goto out;
ret->free_timestamp_query_size = 4; ret->free_timestamp_query_size = 4;
ret->free_timestamp_queries = HeapAlloc(GetProcessHeap(), 0, if (!(ret->free_timestamp_queries = wined3d_calloc(ret->free_timestamp_query_size,
ret->free_timestamp_query_size * sizeof(*ret->free_timestamp_queries)); sizeof(*ret->free_timestamp_queries))))
if (!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;
ret->free_occlusion_queries = HeapAlloc(GetProcessHeap(), 0, if (!(ret->free_occlusion_queries = wined3d_calloc(ret->free_occlusion_query_size,
ret->free_occlusion_query_size * sizeof(*ret->free_occlusion_queries)); sizeof(*ret->free_occlusion_queries))))
if (!ret->free_occlusion_queries)
goto out; goto out;
list_init(&ret->occlusion_queries); list_init(&ret->occlusion_queries);
ret->free_event_query_size = 4; ret->free_event_query_size = 4;
ret->free_event_queries = HeapAlloc(GetProcessHeap(), 0, if (!(ret->free_event_queries = wined3d_calloc(ret->free_event_query_size,
ret->free_event_query_size * sizeof(*ret->free_event_queries)); sizeof(*ret->free_event_queries))))
if (!ret->free_event_queries)
goto out; goto out;
list_init(&ret->event_queries); list_init(&ret->event_queries);

View File

@ -1128,8 +1128,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
if (!(cs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cs)))) if (!(cs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cs))))
return NULL; return NULL;
if (!(cs->fb.render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, if (!(cs->fb.render_targets = wined3d_calloc(gl_info->limits.buffers, sizeof(*cs->fb.render_targets))))
sizeof(*cs->fb.render_targets) * gl_info->limits.buffers)))
{ {
HeapFree(GetProcessHeap(), 0, cs); HeapFree(GetProcessHeap(), 0, cs);
return NULL; return NULL;

View File

@ -1005,8 +1005,8 @@ 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;
device->fb.render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, if (!(device->fb.render_targets = wined3d_calloc(gl_info->limits.buffers, sizeof(*device->fb.render_targets))))
sizeof(*device->fb.render_targets) * gl_info->limits.buffers); return E_OUTOFMEMORY;
if (FAILED(hr = device->shader_backend->shader_alloc_private(device, if (FAILED(hr = device->shader_backend->shader_alloc_private(device,
device->adapter->vertex_pipe, device->adapter->fragment_pipe))) 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->swapchain_count = 1;
device->swapchains = HeapAlloc(GetProcessHeap(), 0, device->swapchain_count * sizeof(*device->swapchains)); if (!(device->swapchains = wined3d_calloc(device->swapchain_count, sizeof(*device->swapchains))))
if (!device->swapchains)
{ {
ERR("Out of memory!\n"); ERR("Out of memory!\n");
goto err_out; goto err_out;
@ -1116,8 +1115,7 @@ HRESULT CDECL wined3d_device_init_gdi(struct wined3d_device *device,
} }
device->swapchain_count = 1; device->swapchain_count = 1;
device->swapchains = HeapAlloc(GetProcessHeap(), 0, device->swapchain_count * sizeof(*device->swapchains)); if (!(device->swapchains = wined3d_calloc(device->swapchain_count, sizeof(*device->swapchains))))
if (!device->swapchains)
{ {
ERR("Out of memory!\n"); ERR("Out of memory!\n");
goto err_out; goto err_out;

View File

@ -5846,7 +5846,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 = 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_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;
@ -5911,7 +5911,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 = 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) for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
{ {

View File

@ -442,8 +442,7 @@ static void shader_glsl_dump_program_source(const struct wined3d_gl_info *gl_inf
char *source = NULL; char *source = NULL;
GL_EXTCALL(glGetProgramiv(program, GL_ATTACHED_SHADERS, &shader_count)); GL_EXTCALL(glGetProgramiv(program, GL_ATTACHED_SHADERS, &shader_count));
shaders = HeapAlloc(GetProcessHeap(), 0, shader_count * sizeof(*shaders)); if (!(shaders = wined3d_calloc(shader_count, sizeof(*shaders))))
if (!shaders)
{ {
ERR("Failed to allocate shader array memory.\n"); ERR("Failed to allocate shader array memory.\n");
return; return;
@ -5217,7 +5216,7 @@ static void shader_glsl_setup_vs3_output(struct shader_glsl_priv *priv,
unsigned int i, j; unsigned int i, j;
char reg_mask[6]; 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) 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; goto fail;
} }
priv->stack = HeapAlloc(GetProcessHeap(), 0, stack_size * sizeof(*priv->stack)); if (!(priv->stack = wined3d_calloc(stack_size, sizeof(*priv->stack))))
if (!priv->stack)
{ {
ERR("Failed to allocate memory.\n"); ERR("Failed to allocate memory.\n");
goto fail; goto fail;

View File

@ -752,7 +752,7 @@ static void shader_record_sample(struct wined3d_shader_reg_maps *reg_maps,
if (!map->size) 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"); ERR("Failed to allocate sampler map entries.\n");
return; return;
@ -823,9 +823,8 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
shader_set_limits(shader); shader_set_limits(shader);
reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, if (!(reg_maps->constf = wined3d_calloc(((min(shader->limits->constant_float, constf_size) + 31) / 32),
sizeof(*reg_maps->constf) * ((min(shader->limits->constant_float, constf_size) + 31) / 32)); sizeof(*reg_maps->constf))))
if (!reg_maps->constf)
{ {
ERR("Failed to allocate constant map memory.\n"); ERR("Failed to allocate constant map memory.\n");
return E_OUTOFMEMORY; 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; struct wined3d_shader_signature_element *e;
unsigned int i; 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; return E_OUTOFMEMORY;
input_signature->element_count = count; 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); unsigned int count = wined3d_popcount(reg_maps->output_registers);
struct wined3d_shader_signature_element *e; 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; return E_OUTOFMEMORY;
output_signature->element_count = count; output_signature->element_count = count;
@ -2742,7 +2741,7 @@ static HRESULT shader_signature_copy(struct wined3d_shader_signature *dst,
ptr = *signature_strings; ptr = *signature_strings;
dst->element_count = src->element_count; 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; return E_OUTOFMEMORY;
for (i = 0; i < src->element_count; ++i) for (i = 0; i < src->element_count; ++i)

View File

@ -5983,12 +5983,8 @@ 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;
dev_multistate_funcs[cur[i].state] = HeapAlloc(GetProcessHeap(), if (!(dev_multistate_funcs[cur[i].state] = wined3d_calloc(2, sizeof(**dev_multistate_funcs))))
0,
sizeof(**dev_multistate_funcs) * 2);
if (!dev_multistate_funcs[cur[i].state]) {
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];
dev_multistate_funcs[cur[i].state][1] = multistate_funcs[cur[i].state][1]; dev_multistate_funcs[cur[i].state][1] = multistate_funcs[cur[i].state][1];

View File

@ -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"); 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"); ERR("Out of memory.\n");
return; return;

View File

@ -980,9 +980,8 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
if (swapchain->desc.backbuffer_count > 0) if (swapchain->desc.backbuffer_count > 0)
{ {
swapchain->back_buffers = HeapAlloc(GetProcessHeap(), 0, if (!(swapchain->back_buffers = wined3d_calloc(swapchain->desc.backbuffer_count,
sizeof(*swapchain->back_buffers) * swapchain->desc.backbuffer_count); sizeof(*swapchain->back_buffers))))
if (!swapchain->back_buffers)
{ {
ERR("Failed to allocate backbuffer array memory.\n"); ERR("Failed to allocate backbuffer array memory.\n");
hr = E_OUTOFMEMORY; 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) static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain *swapchain)
{ {
struct wined3d_context **newArray; struct wined3d_context **ctx_array;
struct wined3d_context *ctx; struct wined3d_context *ctx;
TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId()); 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); context_release(ctx);
newArray = HeapAlloc(GetProcessHeap(), 0, sizeof(*newArray) * (swapchain->num_contexts + 1)); if (!(ctx_array = wined3d_calloc(swapchain->num_contexts + 1, sizeof(*ctx_array))))
if(!newArray) { {
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(newArray, swapchain->context, sizeof(*newArray) * swapchain->num_contexts); memcpy(ctx_array, swapchain->context, sizeof(*ctx_array) * swapchain->num_contexts);
HeapFree(GetProcessHeap(), 0, swapchain->context); HeapFree(GetProcessHeap(), 0, swapchain->context);
newArray[swapchain->num_contexts] = ctx; ctx_array[swapchain->num_contexts] = ctx;
swapchain->context = newArray; swapchain->context = ctx_array;
swapchain->num_contexts++; swapchain->num_contexts++;
TRACE("Returning context %p\n", ctx); TRACE("Returning context %p\n", ctx);

View File

@ -1938,7 +1938,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
if (wined3d_texture_use_pbo(texture, gl_info)) if (wined3d_texture_use_pbo(texture, gl_info))
texture->resource.map_binding = WINED3D_LOCATION_BUFFER; 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); wined3d_texture_cleanup(texture);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -2205,7 +2206,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
texture->resource.map_binding = WINED3D_LOCATION_BUFFER; 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); wined3d_texture_cleanup(texture);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;

View File

@ -1580,8 +1580,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 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, if (!(gl_info->formats = wined3d_calloc(gl_info->format_count, sizeof(*gl_info->formats))))
gl_info->format_count * sizeof(*gl_info->formats))))
{ {
ERR("Failed to allocate memory.\n"); ERR("Failed to allocate memory.\n");
return FALSE; return FALSE;

View File

@ -180,8 +180,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;
declaration->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*declaration->elements) * element_count); if (!(declaration->elements = wined3d_calloc(element_count, sizeof(*declaration->elements))))
if (!declaration->elements)
{ {
ERR("Failed to allocate elements memory.\n"); ERR("Failed to allocate elements memory.\n");
return E_OUTOFMEMORY; 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; has_psize + has_diffuse + has_specular + num_textures;
state.gl_info = gl_info; state.gl_info = gl_info;
state.elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(*state.elements)); if (!(state.elements = wined3d_calloc(size, sizeof(*state.elements))))
if (!state.elements) return ~0U; return ~0u;
state.offset = 0; state.offset = 0;
state.idx = 0; state.idx = 0;

View File

@ -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); 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, format->convert(data->addr, converted_mem, src_row_pitch, src_slice_pitch,
dst_row_pitch, dst_slice_pitch, width, height, depth); dst_row_pitch, dst_slice_pitch, width, height, depth);
mem = converted_mem; mem = converted_mem;

View File

@ -452,8 +452,10 @@ BOOL wined3d_register_window(HWND window, struct wined3d_device *device)
unsigned int new_size = max(1, wndproc_table.size * 2); unsigned int new_size = max(1, wndproc_table.size * 2);
struct wined3d_wndproc *new_entries; struct wined3d_wndproc *new_entries;
if (!wndproc_table.entries) new_entries = HeapAlloc(GetProcessHeap(), 0, new_size * sizeof(*new_entries)); if (!wndproc_table.entries)
else new_entries = HeapReAlloc(GetProcessHeap(), 0, wndproc_table.entries, new_size * sizeof(*new_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) if (!new_entries)
{ {

View File

@ -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_color_key_conversion * wined3d_format_get_color_key_conversion(
const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN; 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) 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