d3dx9: Use CRT allocation functions.

This commit is contained in:
Alex Henrie 2023-12-04 01:04:32 -07:00 committed by Alexandre Julliard
parent 3b3a65ad37
commit 17da2665e2
17 changed files with 423 additions and 506 deletions

View file

@ -75,7 +75,7 @@ static ULONG WINAPI d3dx9_animation_controller_Release(ID3DXAnimationController
if (!refcount)
{
HeapFree(GetProcessHeap(), 0, animation);
free(animation);
}
return refcount;
@ -452,7 +452,7 @@ HRESULT WINAPI D3DXCreateAnimationController(UINT max_outputs, UINT max_sets,
if (!max_outputs || !max_sets || !max_tracks || !max_events || !controller)
return D3D_OK;
object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -524,8 +524,8 @@ static ULONG WINAPI d3dx9_keyframed_animation_Release(ID3DXKeyframedAnimationSet
if (!refcount)
{
heap_free((char *)set->name);
heap_free(set);
free((char *)set->name);
free(set);
}
return refcount;
@ -860,7 +860,6 @@ HRESULT WINAPI D3DXCreateKeyframedAnimationSet(const char *name, double ticks_pe
const D3DXKEY_CALLBACK *callback_keys, ID3DXKeyframedAnimationSet **animation_set)
{
struct d3dx9_keyframed_animation_set *object;
char *string;
TRACE("name %s, ticks_per_second %.16e, playback_type %u, animation_count %u, "
"callback_key_count %u, callback_keys %p, animation_set %p.\n",
@ -870,18 +869,16 @@ HRESULT WINAPI D3DXCreateKeyframedAnimationSet(const char *name, double ticks_pe
if (!animation_count)
return D3DERR_INVALIDCALL;
if (!(object = heap_alloc(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->ID3DXKeyframedAnimationSet_iface.lpVtbl = &d3dx9_keyframed_animation_vtbl;
object->ref = 1;
if (!(string = heap_alloc(strlen(name) + 1)))
if (!(object->name = strdup(name)))
{
heap_free(object);
free(object);
return E_OUTOFMEMORY;
}
strcpy(string, name);
object->name = string;
object->ticks_per_second = ticks_per_second;
object->playback_type = playback_type;
object->animation_count = animation_count;

View file

@ -72,8 +72,8 @@ static ULONG WINAPI ID3DXBufferImpl_Release(ID3DXBuffer *iface)
if (ref == 0)
{
HeapFree(GetProcessHeap(), 0, This->buffer);
HeapFree(GetProcessHeap(), 0, This);
free(This->buffer);
free(This);
}
return ref;
@ -114,7 +114,7 @@ static HRESULT d3dx9_buffer_init(struct ID3DXBufferImpl *buffer, DWORD size)
buffer->ref = 1;
buffer->size = size;
buffer->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
buffer->buffer = calloc(1, size);
if (!buffer->buffer)
{
ERR("Failed to allocate buffer memory\n");
@ -137,7 +137,7 @@ HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
return D3DERR_INVALIDCALL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -145,7 +145,7 @@ HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
if (FAILED(hr))
{
WARN("Failed to initialize buffer, hr %#lx.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
free(object);
return hr;
}

View file

@ -24,7 +24,6 @@
#include <stdint.h>
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/rbtree.h"
#define COBJMACROS

View file

@ -541,7 +541,7 @@ static void free_state(struct d3dx_state *state)
static void free_object(struct d3dx_object *object)
{
HeapFree(GetProcessHeap(), 0, object->data);
free(object->data);
}
static void free_sampler(struct d3dx_sampler *sampler)
@ -552,7 +552,7 @@ static void free_sampler(struct d3dx_sampler *sampler)
{
free_state(&sampler->states[i]);
}
heap_free(sampler->states);
free(sampler->states);
}
static void d3dx_pool_release_shared_parameter(struct d3dx_top_level_parameter *param);
@ -571,7 +571,7 @@ static void free_parameter_object_data(struct d3dx_parameter *param, const void
switch (param->type)
{
case D3DXPT_STRING:
heap_free(((char **)data)[i]);
free(((char **)data)[i]);
break;
case D3DXPT_TEXTURE:
@ -610,7 +610,7 @@ static void free_parameter_data(struct d3dx_parameter *param, BOOL child)
free_parameter_object_data(param, param->data, param->bytes);
if (!child || is_param_type_sampler(param->type))
heap_free(param->data);
free(param->data);
}
static void free_parameter(struct d3dx_parameter *param, BOOL element, BOOL child)
@ -629,17 +629,17 @@ static void free_parameter(struct d3dx_parameter *param, BOOL element, BOOL chil
for (i = 0; i < count; ++i)
free_parameter(&param->members[i], param->element_count != 0, TRUE);
HeapFree(GetProcessHeap(), 0, param->members);
free(param->members);
}
heap_free(param->full_name);
free(param->full_name);
free_parameter_data(param, child);
/* only the parent has to release name and semantic */
if (!element)
{
HeapFree(GetProcessHeap(), 0, param->name);
HeapFree(GetProcessHeap(), 0, param->semantic);
free(param->name);
free(param->semantic);
}
}
@ -651,7 +651,7 @@ static void free_top_level_parameter(struct d3dx_top_level_parameter *param)
for (i = 0; i < param->annotation_count; ++i)
free_parameter(&param->annotations[i], FALSE, FALSE);
HeapFree(GetProcessHeap(), 0, param->annotations);
free(param->annotations);
}
d3dx_pool_release_shared_parameter(param);
free_parameter(&param->param, FALSE, FALSE);
@ -670,7 +670,7 @@ static void free_pass(struct d3dx_pass *pass)
{
for (i = 0; i < pass->annotation_count; ++i)
free_parameter(&pass->annotations[i], FALSE, FALSE);
HeapFree(GetProcessHeap(), 0, pass->annotations);
free(pass->annotations);
pass->annotations = NULL;
}
@ -678,11 +678,11 @@ static void free_pass(struct d3dx_pass *pass)
{
for (i = 0; i < pass->state_count; ++i)
free_state(&pass->states[i]);
HeapFree(GetProcessHeap(), 0, pass->states);
free(pass->states);
pass->states = NULL;
}
HeapFree(GetProcessHeap(), 0, pass->name);
free(pass->name);
pass->name = NULL;
}
@ -705,7 +705,7 @@ static void free_technique(struct d3dx_technique *technique)
{
for (i = 0; i < technique->annotation_count; ++i)
free_parameter(&technique->annotations[i], FALSE, FALSE);
HeapFree(GetProcessHeap(), 0, technique->annotations);
free(technique->annotations);
technique->annotations = NULL;
}
@ -713,11 +713,11 @@ static void free_technique(struct d3dx_technique *technique)
{
for (i = 0; i < technique->pass_count; ++i)
free_pass(&technique->passes[i]);
HeapFree(GetProcessHeap(), 0, technique->passes);
free(technique->passes);
technique->passes = NULL;
}
HeapFree(GetProcessHeap(), 0, technique->name);
free(technique->name);
technique->name = NULL;
}
@ -741,8 +741,8 @@ static void free_parameter_block(struct d3dx_parameter_block *block)
}
assert((BYTE *)record == block->buffer + block->offset);
heap_free(block->buffer);
heap_free(block);
free(block->buffer);
free(block);
}
static int param_rb_compare(const void *key, const struct wine_rb_entry *entry)
@ -758,7 +758,7 @@ HRESULT d3dx_init_parameters_store(struct d3dx_parameters_store *store, unsigned
store->count = count;
wine_rb_init(&store->tree, param_rb_compare);
if (store->count && !(store->parameters = heap_alloc_zero(sizeof(*store->parameters) * store->count)))
if (store->count && !(store->parameters = calloc(store->count, sizeof(*store->parameters))))
return E_OUTOFMEMORY;
return S_OK;
@ -768,13 +768,13 @@ void d3dx_parameters_store_cleanup(struct d3dx_parameters_store *store)
{
unsigned int i;
heap_free(store->full_name_tmp);
free(store->full_name_tmp);
if (store->parameters)
{
for (i = 0; i < store->count; ++i)
free_top_level_parameter(&store->parameters[i]);
heap_free(store->parameters);
free(store->parameters);
store->parameters = NULL;
}
}
@ -800,14 +800,14 @@ static void d3dx_effect_cleanup(struct d3dx_effect *effect)
{
for (i = 0; i < effect->technique_count; ++i)
free_technique(&effect->techniques[i]);
heap_free(effect->techniques);
free(effect->techniques);
}
if (effect->objects)
{
for (i = 0; i < effect->object_count; ++i)
free_object(&effect->objects[i]);
heap_free(effect->objects);
free(effect->objects);
}
if (effect->pool)
@ -820,7 +820,7 @@ static void d3dx_effect_cleanup(struct d3dx_effect *effect)
IUnknown_Release(effect->manager);
IDirect3DDevice9_Release(effect->device);
heap_free(effect);
free(effect);
}
static void get_vector(struct d3dx_parameter *param, D3DXVECTOR4 *vector)
@ -904,14 +904,13 @@ static void set_matrix_transpose(struct d3dx_parameter *param, const D3DXMATRIX
static HRESULT set_string(char **param_data, const char *string)
{
heap_free(*param_data);
*param_data = heap_alloc(strlen(string) + 1);
free(*param_data);
*param_data = strdup(string);
if (!*param_data)
{
ERR("Out of memory.\n");
return E_OUTOFMEMORY;
}
strcpy(*param_data, string);
return D3D_OK;
}
@ -1081,7 +1080,7 @@ struct d3dx_parameter *get_parameter_by_name(struct d3dx_parameters_store *store
full_name_size = name_len + param_name_len + 2;
if (store->full_name_tmp_size < full_name_size)
{
if (!(full_name = heap_realloc(store->full_name_tmp, full_name_size)))
if (!(full_name = realloc(store->full_name_tmp, full_name_size)))
{
ERR("Out of memory.\n");
return NULL;
@ -1322,11 +1321,7 @@ static void *record_parameter(struct d3dx_effect *effect, struct d3dx_parameter
BYTE *new_alloc;
alloc_size = max(block->size * 2, max(new_size, INITIAL_PARAM_BLOCK_SIZE));
if (block->size)
new_alloc = heap_realloc(block->buffer, alloc_size);
else
new_alloc = heap_alloc(alloc_size);
new_alloc = realloc(block->buffer, alloc_size);
if (!new_alloc)
{
ERR("Out of memory.\n");
@ -1527,7 +1522,7 @@ static HRESULT d3dx_set_shader_const_state(struct d3dx_effect *effect, enum SHAD
if (element_count > 1)
{
WARN("Setting %u elements.\n", element_count);
buffer = HeapAlloc(GetProcessHeap(), 0, const_tbl[op].elem_size * element_count);
buffer = calloc(element_count, const_tbl[op].elem_size);
if (!buffer)
{
ERR("Out of memory.\n");
@ -1542,8 +1537,6 @@ static HRESULT d3dx_set_shader_const_state(struct d3dx_effect *effect, enum SHAD
}
param_data_size = min(param->bytes, const_tbl[op].elem_size);
memcpy(buffer, value_ptr, param_data_size);
memset((unsigned char *)buffer + param_data_size, 0,
const_tbl[op].elem_size * element_count - param_data_size);
}
switch (op)
@ -1572,7 +1565,7 @@ static HRESULT d3dx_set_shader_const_state(struct d3dx_effect *effect, enum SHAD
}
if (is_heap_buffer)
HeapFree(GetProcessHeap(), 0, buffer);
free(buffer);
return ret;
}
@ -1874,24 +1867,16 @@ static HRESULT d3dx_pool_sync_shared_parameter(struct d3dx_effect_pool *pool, st
if (!pool->size)
{
new_size = INITIAL_POOL_SIZE;
new_alloc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*pool->shared_data) * new_size);
new_alloc = calloc(new_size, sizeof(*pool->shared_data));
if (!new_alloc)
{
ERR("Out of memory.\n");
return E_OUTOFMEMORY;
}
goto oom;
}
else
{
new_size = pool->size * 2;
new_alloc = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pool->shared_data,
sizeof(*pool->shared_data) * new_size);
new_alloc = _recalloc(pool->shared_data, new_size, sizeof(*pool->shared_data));
if (!new_alloc)
{
ERR("Out of memory.\n");
return E_OUTOFMEMORY;
}
goto oom;
if (new_alloc != pool->shared_data)
{
unsigned int j, k;
@ -1913,19 +1898,13 @@ static HRESULT d3dx_pool_sync_shared_parameter(struct d3dx_effect_pool *pool, st
new_count = ++pool->shared_data[i].count;
if (new_count >= pool->shared_data[i].size)
{
if (!pool->shared_data[i].size)
{
new_size = INITIAL_SHARED_DATA_SIZE;
pool->shared_data[i].parameters = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*pool->shared_data[i].parameters) * INITIAL_SHARED_DATA_SIZE);
}
else
{
new_size = pool->shared_data[i].size * 2;
pool->shared_data[i].parameters = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
pool->shared_data[i].parameters,
sizeof(*pool->shared_data[i].parameters) * new_size);
}
struct d3dx_top_level_parameter **new_alloc;
new_size = pool->shared_data[i].size ? pool->shared_data[i].size * 2 : INITIAL_SHARED_DATA_SIZE;
new_alloc = _recalloc(pool->shared_data[i].parameters, new_size, sizeof(*pool->shared_data[i].parameters));
if (!new_alloc)
goto oom;
pool->shared_data[i].parameters = new_alloc;
pool->shared_data[i].size = new_size;
}
@ -1936,6 +1915,10 @@ static HRESULT d3dx_pool_sync_shared_parameter(struct d3dx_effect_pool *pool, st
new_count);
return D3D_OK;
oom:
ERR("Out of memory.\n");
return E_OUTOFMEMORY;
}
static BOOL param_zero_data_func(void *dummy, struct d3dx_parameter *param)
@ -1972,7 +1955,7 @@ static void d3dx_pool_release_shared_parameter(struct d3dx_top_level_parameter *
}
else
{
HeapFree(GetProcessHeap(), 0, param->shared_data->parameters);
free(param->shared_data->parameters);
/* Zeroing table size is required as the entry in pool parameters table can be reused. */
param->shared_data->size = 0;
param->shared_data = NULL;
@ -4260,7 +4243,7 @@ static HRESULT WINAPI d3dx_effect_BeginParameterBlock(ID3DXEffect *iface)
return D3DERR_INVALIDCALL;
}
effect->current_parameter_block = heap_alloc_zero(sizeof(*effect->current_parameter_block));
effect->current_parameter_block = calloc(1, sizeof(*effect->current_parameter_block));
memcpy(effect->current_parameter_block->magic_string, parameter_block_magic_string,
sizeof(parameter_block_magic_string));
effect->current_parameter_block->effect = effect;
@ -4272,6 +4255,7 @@ static D3DXHANDLE WINAPI d3dx_effect_EndParameterBlock(ID3DXEffect *iface)
{
struct d3dx_effect *effect = impl_from_ID3DXEffect(iface);
struct d3dx_parameter_block *ret;
BYTE *new_buffer;
TRACE("iface %p.\n", iface);
@ -4282,7 +4266,9 @@ static D3DXHANDLE WINAPI d3dx_effect_EndParameterBlock(ID3DXEffect *iface)
}
ret = effect->current_parameter_block;
ret->buffer = heap_realloc(ret->buffer, ret->offset);
new_buffer = realloc(ret->buffer, ret->offset);
if (new_buffer)
ret->buffer = new_buffer;
ret->size = ret->offset;
effect->current_parameter_block = NULL;
@ -4341,10 +4327,7 @@ static HRESULT WINAPI d3dx_effect_DeleteParameterBlock(ID3DXEffect *iface, D3DXH
static bool copy_parameter(struct d3dx_effect *dst_effect, const struct d3dx_effect *src_effect,
struct d3dx_parameter *dst, const struct d3dx_parameter *src)
{
const char *src_string;
char *dst_string;
IUnknown *iface;
size_t len;
if ((src->flags & PARAMETER_FLAG_SHARED) && dst_effect->pool)
return true;
@ -4359,12 +4342,9 @@ static bool copy_parameter(struct d3dx_effect *dst_effect, const struct d3dx_eff
break;
case D3DXPT_STRING:
src_string = *(char **)src->data;
len = strlen(src_string);
if (!(dst_string = heap_realloc(*(char **)dst->data, len + 1)))
free(*(char **)dst->data);
if (!(*(char **)dst->data = strdup(*(char **)src->data)))
return false;
*(char **)dst->data = dst_string;
memcpy(dst_string, src_string, len + 1);
break;
case D3DXPT_TEXTURE:
@ -4418,13 +4398,13 @@ static HRESULT WINAPI d3dx_effect_CloneEffect(ID3DXEffect *iface, IDirect3DDevic
if (!device)
return D3DERR_INVALIDCALL;
if (!(dst = heap_alloc_zero(sizeof(*dst))))
if (!(dst = calloc(1, sizeof(*dst))))
return E_OUTOFMEMORY;
if (FAILED(hr = d3dx9_effect_init_from_binary(dst, device, src->source, src->source_size,
src->flags, &src->pool->ID3DXEffectPool_iface, src->skip_constants_string)))
{
heap_free(dst);
free(dst);
return hr;
}
@ -4605,7 +4585,7 @@ static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
if (!refcount)
{
heap_free(compiler);
free(compiler);
}
return refcount;
@ -5142,7 +5122,7 @@ static HRESULT d3dx_parse_sampler(struct d3dx_effect *effect, struct d3dx_sample
sampler->state_count = read_u32(ptr);
TRACE("Count: %u\n", sampler->state_count);
sampler->states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler->states) * sampler->state_count);
sampler->states = calloc(sampler->state_count, sizeof(*sampler->states));
if (!sampler->states)
{
ERR("Out of memory\n");
@ -5167,7 +5147,7 @@ err_out:
{
free_state(&sampler->states[i]);
}
HeapFree(GetProcessHeap(), 0, sampler->states);
free(sampler->states);
sampler->states = NULL;
return hr;
@ -5253,14 +5233,14 @@ static HRESULT d3dx_parse_value(struct d3dx_effect *effect, struct d3dx_paramete
{
struct d3dx_sampler *sampler;
sampler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler));
sampler = calloc(1, sizeof(*sampler));
if (!sampler)
return E_OUTOFMEMORY;
hr = d3dx_parse_sampler(effect, sampler, data, ptr, objects);
if (hr != D3D_OK)
{
HeapFree(GetProcessHeap(), 0, sampler);
free(sampler);
WARN("Failed to parse sampler\n");
return hr;
}
@ -5294,7 +5274,7 @@ static HRESULT d3dx_parse_init_value(struct d3dx_effect *effect, struct d3dx_par
if (size)
{
value = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
value = calloc(1, size);
if (!value)
{
ERR("Failed to allocate data memory.\n");
@ -5325,7 +5305,7 @@ static HRESULT d3dx_parse_init_value(struct d3dx_effect *effect, struct d3dx_par
if (hr != D3D_OK)
{
WARN("Failed to parse value\n");
HeapFree(GetProcessHeap(), 0, value);
free(value);
return hr;
}
@ -5344,7 +5324,7 @@ static HRESULT d3dx9_parse_name(char **name, const char *ptr)
return D3D_OK;
}
*name = HeapAlloc(GetProcessHeap(), 0, size);
*name = malloc(size);
if (!*name)
{
ERR("Failed to allocate name memory.\n");
@ -5368,7 +5348,7 @@ static HRESULT d3dx9_copy_data(struct d3dx_effect *effect, unsigned int object_i
else
TRACE("Overwriting object id 0.\n");
HeapFree(GetProcessHeap(), 0, object->data);
free(object->data);
object->data = NULL;
}
@ -5378,7 +5358,7 @@ static HRESULT d3dx9_copy_data(struct d3dx_effect *effect, unsigned int object_i
if (!object->size)
return D3D_OK;
object->data = HeapAlloc(GetProcessHeap(), 0, object->size);
object->data = malloc(object->size);
if (!object->data)
{
ERR("Failed to allocate object memory.\n");
@ -5429,7 +5409,7 @@ static void add_param_to_tree(struct d3dx_effect *effect, struct d3dx_parameter
}
len = parent_name_len + part_str_len + name_len + 1;
if (!(param->full_name = heap_alloc(len)))
if (!(param->full_name = malloc(len)))
{
ERR("Out of memory.\n");
return;
@ -5442,15 +5422,11 @@ static void add_param_to_tree(struct d3dx_effect *effect, struct d3dx_parameter
}
else
{
unsigned int len = strlen(param->name) + 1;
if (!(param->full_name = heap_alloc(len)))
if (!(param->full_name = strdup(param->name)))
{
ERR("Out of memory.\n");
return;
}
memcpy(param->full_name, param->name, len);
}
TRACE("Full name is %s.\n", param->full_name);
wine_rb_put(&effect->params.tree, param->full_name, &param->rb_entry);
@ -5588,7 +5564,7 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx
unsigned int param_bytes = 0;
const char *save_ptr = *ptr;
param->members = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*param->members) * param->element_count);
param->members = calloc(param->element_count, sizeof(*param->members));
if (!param->members)
{
ERR("Out of memory\n");
@ -5615,7 +5591,7 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx
}
else if (param->member_count)
{
param->members = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*param->members) * param->member_count);
param->members = calloc(param->member_count, sizeof(*param->members));
if (!param->members)
{
ERR("Out of memory\n");
@ -5646,14 +5622,14 @@ err_out:
for (i = 0; i < count; ++i)
free_parameter(&param->members[i], param->element_count != 0, TRUE);
HeapFree(GetProcessHeap(), 0, param->members);
free(param->members);
param->members = NULL;
}
if (!parent)
{
HeapFree(GetProcessHeap(), 0, param->name);
HeapFree(GetProcessHeap(), 0, param->semantic);
free(param->name);
free(param->semantic);
}
param->name = NULL;
param->semantic = NULL;
@ -5746,7 +5722,7 @@ static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *s
goto err_out;
}
new_data = heap_realloc(param->data, sizeof(void *));
new_data = realloc(param->data, sizeof(void *));
if (!new_data)
{
ERR("Out of memory.\n");
@ -5804,8 +5780,7 @@ static HRESULT d3dx_parse_effect_parameter(struct d3dx_effect *effect, struct d3
if (param->annotation_count)
{
param->annotations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*param->annotations) * param->annotation_count);
param->annotations = calloc(param->annotation_count, sizeof(*param->annotations));
if (!param->annotations)
{
ERR("Out of memory.\n");
@ -5833,7 +5808,7 @@ err_out:
{
for (i = 0; i < param->annotation_count; ++i)
free_parameter(&param->annotations[i], FALSE, FALSE);
HeapFree(GetProcessHeap(), 0, param->annotations);
free(param->annotations);
param->annotations = NULL;
}
@ -5866,8 +5841,7 @@ static HRESULT d3dx_parse_effect_pass(struct d3dx_effect *effect, struct d3dx_pa
if (pass->annotation_count)
{
pass->annotations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*pass->annotations) * pass->annotation_count);
pass->annotations = calloc(pass->annotation_count, sizeof(*pass->annotations));
if (!pass->annotations)
{
ERR("Out of memory\n");
@ -5889,7 +5863,7 @@ static HRESULT d3dx_parse_effect_pass(struct d3dx_effect *effect, struct d3dx_pa
if (pass->state_count)
{
states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*states) * pass->state_count);
states = calloc(pass->state_count, sizeof(*states));
if (!states)
{
ERR("Out of memory\n");
@ -5919,7 +5893,7 @@ err_out:
{
for (i = 0; i < pass->annotation_count; ++i)
free_parameter(&pass->annotations[i], FALSE, FALSE);
HeapFree(GetProcessHeap(), 0, pass->annotations);
free(pass->annotations);
pass->annotations = NULL;
}
@ -5929,10 +5903,10 @@ err_out:
{
free_state(&states[i]);
}
HeapFree(GetProcessHeap(), 0, states);
free(states);
}
HeapFree(GetProcessHeap(), 0, name);
free(name);
return hr;
}
@ -5962,8 +5936,7 @@ static HRESULT d3dx_parse_effect_technique(struct d3dx_effect *effect, struct d3
if (technique->annotation_count)
{
technique->annotations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*technique->annotations) * technique->annotation_count);
technique->annotations = calloc(technique->annotation_count, sizeof(*technique->annotations));
if (!technique->annotations)
{
ERR("Out of memory\n");
@ -5985,8 +5958,7 @@ static HRESULT d3dx_parse_effect_technique(struct d3dx_effect *effect, struct d3
if (technique->pass_count)
{
technique->passes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*technique->passes) * technique->pass_count);
technique->passes = calloc(technique->pass_count, sizeof(*technique->passes));
if (!technique->passes)
{
ERR("Out of memory\n");
@ -6015,7 +5987,7 @@ err_out:
{
for (i = 0; i < technique->pass_count; ++i)
free_pass(&technique->passes[i]);
HeapFree(GetProcessHeap(), 0, technique->passes);
free(technique->passes);
technique->passes = NULL;
}
@ -6023,11 +5995,11 @@ err_out:
{
for (i = 0; i < technique->annotation_count; ++i)
free_parameter(&technique->annotations[i], FALSE, FALSE);
HeapFree(GetProcessHeap(), 0, technique->annotations);
free(technique->annotations);
technique->annotations = NULL;
}
HeapFree(GetProcessHeap(), 0, name);
free(name);
return hr;
}
@ -6044,7 +6016,7 @@ static HRESULT d3dx9_create_object(struct d3dx_effect *effect, struct d3dx_objec
switch (param->type)
{
case D3DXPT_STRING:
*(char **)param->data = HeapAlloc(GetProcessHeap(), 0, object->size);
*(char **)param->data = malloc(object->size);
if (!*(char **)param->data)
{
ERR("Out of memory.\n");
@ -6336,8 +6308,7 @@ static HRESULT d3dx_parse_effect(struct d3dx_effect *effect, const char *data, U
effect->object_count = read_u32(&ptr);
TRACE("Object count: %u.\n", effect->object_count);
effect->objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*effect->objects) * effect->object_count);
effect->objects = calloc(effect->object_count, sizeof(*effect->objects));
if (!effect->objects)
{
ERR("Out of memory.\n");
@ -6366,7 +6337,7 @@ static HRESULT d3dx_parse_effect(struct d3dx_effect *effect, const char *data, U
if (effect->technique_count)
{
effect->techniques = heap_alloc_zero(sizeof(*effect->techniques) * effect->technique_count);
effect->techniques = calloc(effect->technique_count, sizeof(*effect->techniques));
if (!effect->techniques)
{
ERR("Out of memory.\n");
@ -6436,7 +6407,7 @@ err_out:
{
for (i = 0; i < effect->technique_count; ++i)
free_technique(&effect->techniques[i]);
heap_free(effect->techniques);
free(effect->techniques);
effect->techniques = NULL;
}
@ -6448,7 +6419,7 @@ err_out:
{
free_object(&effect->objects[i]);
}
HeapFree(GetProcessHeap(), 0, effect->objects);
free(effect->objects);
effect->objects = NULL;
}
@ -6483,7 +6454,7 @@ static const char **parse_skip_constants_string(char *skip_constants_string, uns
char *s;
unsigned int size = INITIAL_CONST_NAMES_SIZE;
names = HeapAlloc(GetProcessHeap(), 0, sizeof(*names) * size);
names = malloc(sizeof(*names) * size);
if (!names)
return NULL;
@ -6494,17 +6465,17 @@ static const char **parse_skip_constants_string(char *skip_constants_string, uns
if (*names_count == size)
{
size *= 2;
new_alloc = HeapReAlloc(GetProcessHeap(), 0, names, sizeof(*names) * size);
new_alloc = realloc(names, sizeof(*names) * size);
if (!new_alloc)
{
HeapFree(GetProcessHeap(), 0, names);
free(names);
return NULL;
}
names = new_alloc;
}
names[(*names_count)++] = name;
}
new_alloc = HeapReAlloc(GetProcessHeap(), 0, names, *names_count * sizeof(*names));
new_alloc = realloc(names, *names_count * sizeof(*names));
if (!new_alloc)
return names;
return new_alloc;
@ -6557,18 +6528,15 @@ static HRESULT d3dx9_effect_init_from_binary(struct d3dx_effect *effect,
goto fail;
}
skip_constants_buffer = HeapAlloc(GetProcessHeap(), 0,
sizeof(*skip_constants_buffer) * (strlen(skip_constants_string) + 1));
if (!skip_constants_buffer)
if (!(skip_constants_buffer = strdup(skip_constants_string)))
{
hr = E_OUTOFMEMORY;
goto fail;
}
strcpy(skip_constants_buffer, skip_constants_string);
if (!(skip_constants = parse_skip_constants_string(skip_constants_buffer, &skip_constants_count)))
{
HeapFree(GetProcessHeap(), 0, skip_constants_buffer);
free(skip_constants_buffer);
hr = E_OUTOFMEMORY;
goto fail;
}
@ -6580,8 +6548,8 @@ static HRESULT d3dx9_effect_init_from_binary(struct d3dx_effect *effect,
if (hr != D3D_OK)
{
FIXME("Failed to parse effect.\n");
HeapFree(GetProcessHeap(), 0, skip_constants_buffer);
HeapFree(GetProcessHeap(), 0, skip_constants);
free(skip_constants_buffer);
free(skip_constants);
goto fail;
}
@ -6597,8 +6565,8 @@ static HRESULT d3dx9_effect_init_from_binary(struct d3dx_effect *effect,
{
WARN("skip_constants parameter %s is used in technique %u.\n",
debugstr_a(skip_constants[i]), j);
HeapFree(GetProcessHeap(), 0, skip_constants_buffer);
HeapFree(GetProcessHeap(), 0, skip_constants);
free(skip_constants_buffer);
free(skip_constants);
hr = D3DERR_INVALIDCALL;
goto fail;
}
@ -6611,8 +6579,8 @@ static HRESULT d3dx9_effect_init_from_binary(struct d3dx_effect *effect,
}
}
HeapFree(GetProcessHeap(), 0, skip_constants_buffer);
HeapFree(GetProcessHeap(), 0, skip_constants);
free(skip_constants_buffer);
free(skip_constants);
/* initialize defaults - check because of unsupported ascii effects */
if (effect->techniques)
@ -6628,21 +6596,21 @@ fail:
{
for (i = 0; i < effect->technique_count; ++i)
free_technique(&effect->techniques[i]);
heap_free(effect->techniques);
free(effect->techniques);
}
if (effect->params.parameters)
{
for (i = 0; i < effect->params.count; ++i)
free_top_level_parameter(&effect->params.parameters[i]);
heap_free(effect->params.parameters);
free(effect->params.parameters);
}
if (effect->objects)
{
for (i = 0; i < effect->object_count; ++i)
free_object(&effect->objects[i]);
heap_free(effect->objects);
free(effect->objects);
}
IDirect3DDevice9_Release(effect->device);
@ -6750,7 +6718,7 @@ HRESULT WINAPI D3DXCreateEffectEx(struct IDirect3DDevice9 *device, const void *s
if (!effect)
return D3D_OK;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -6810,7 +6778,7 @@ HRESULT WINAPI D3DXCreateEffectCompiler(const char *data, UINT data_size, const
return D3DERR_INVALIDCALL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -6819,7 +6787,7 @@ HRESULT WINAPI D3DXCreateEffectCompiler(const char *data, UINT data_size, const
if (FAILED(hr))
{
WARN("Failed to initialize effect compiler\n");
HeapFree(GetProcessHeap(), 0, object);
free(object);
return hr;
}
@ -6878,11 +6846,11 @@ static void free_effect_pool(struct d3dx_effect_pool *pool)
walk_parameter_tree(&pool->shared_data[i].parameters[j]->param, param_zero_data_func, NULL);
pool->shared_data[i].parameters[j]->shared_data = NULL;
}
HeapFree(GetProcessHeap(), 0, pool->shared_data[i].parameters);
free(pool->shared_data[i].parameters);
}
}
HeapFree(GetProcessHeap(), 0, pool->shared_data);
HeapFree(GetProcessHeap(), 0, pool);
free(pool->shared_data);
free(pool);
}
static ULONG WINAPI d3dx_effect_pool_Release(ID3DXEffectPool *iface)
@ -6924,7 +6892,7 @@ HRESULT WINAPI D3DXCreateEffectPool(ID3DXEffectPool **pool)
if (!pool)
return D3DERR_INVALIDCALL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -6961,7 +6929,7 @@ HRESULT WINAPI D3DXCreateEffectFromFileExW(struct IDirect3DDevice9 *device, cons
}
size = WideCharToMultiByte(CP_ACP, 0, srcfile, -1, NULL, 0, NULL, NULL);
filename_a = heap_alloc(size);
filename_a = malloc(size);
if (!filename_a)
return E_OUTOFMEMORY;
WideCharToMultiByte(CP_ACP, 0, srcfile, -1, filename_a, size, NULL, NULL);
@ -6971,7 +6939,7 @@ HRESULT WINAPI D3DXCreateEffectFromFileExW(struct IDirect3DDevice9 *device, cons
if (FAILED(ret))
{
LeaveCriticalSection(&from_file_mutex);
heap_free(filename_a);
free(filename_a);
return D3DXERR_INVALIDDATA;
}
@ -6980,7 +6948,7 @@ HRESULT WINAPI D3DXCreateEffectFromFileExW(struct IDirect3DDevice9 *device, cons
ID3DXInclude_Close(include, buffer);
LeaveCriticalSection(&from_file_mutex);
heap_free(filename_a);
free(filename_a);
return ret;
}
@ -7001,11 +6969,11 @@ HRESULT WINAPI D3DXCreateEffectFromFileExA(struct IDirect3DDevice9 *device, cons
return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
srcfileW = malloc(len * sizeof(*srcfileW));
MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, messages);
HeapFree(GetProcessHeap(), 0, srcfileW);
free(srcfileW);
return ret;
}
@ -7137,11 +7105,11 @@ HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(const char *srcfile, const D3DX
return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
srcfileW = malloc(len * sizeof(*srcfileW));
MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, compiler, messages);
HeapFree(GetProcessHeap(), 0, srcfileW);
free(srcfileW);
return ret;
}

View file

@ -66,7 +66,7 @@ static void glyph_rb_free(struct wine_rb_entry *entry, void *context)
{
struct d3dx_glyph *glyph = WINE_RB_ENTRY_VALUE(entry, struct d3dx_glyph, entry);
heap_free(glyph);
free(glyph);
}
static inline struct d3dx_font *impl_from_ID3DXFont(ID3DXFont *iface)
@ -114,14 +114,14 @@ static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface)
for (i = 0; i < font->texture_count; ++i)
IDirect3DTexture9_Release(font->textures[i]);
heap_free(font->textures);
free(font->textures);
wine_rb_destroy(&font->glyph_tree, glyph_rb_free, NULL);
DeleteObject(font->hfont);
DeleteDC(font->hdc);
IDirect3DDevice9_Release(font->device);
heap_free(font);
free(font);
}
return ref;
}
@ -233,14 +233,14 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT fir
return D3D_OK;
count = last - first + 1;
indices = heap_alloc(count * sizeof(*indices));
indices = calloc(count, sizeof(*indices));
if (!indices)
return E_OUTOFMEMORY;
chars = heap_alloc(count * sizeof(*chars));
chars = calloc(count, sizeof(*chars));
if (!chars)
{
heap_free(indices);
free(indices);
return E_OUTOFMEMORY;
}
@ -262,8 +262,8 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT fir
}
ID3DXFont_PreloadGlyphs(iface, start, end);
heap_free(chars);
heap_free(indices);
free(chars);
free(indices);
return D3D_OK;
}
@ -322,7 +322,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
if (wine_rb_get(&font->glyph_tree, ULongToPtr(glyph)))
continue;
current_glyph = heap_alloc(sizeof(*current_glyph));
current_glyph = malloc(sizeof(*current_glyph));
if (!current_glyph)
{
if (mapped)
@ -343,7 +343,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
if (!size)
continue;
buffer = heap_alloc(size);
buffer = malloc(size);
if (!buffer)
{
if (mapped)
@ -361,10 +361,10 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
if (mapped)
IDirect3DTexture9_UnlockRect(current_texture, 0);
mapped = FALSE;
new_textures = heap_realloc(font->textures, new_texture_count * sizeof(*new_textures));
new_textures = realloc(font->textures, new_texture_count * sizeof(*new_textures));
if (!new_textures)
{
heap_free(buffer);
free(buffer);
return E_OUTOFMEMORY;
}
font->textures = new_textures;
@ -373,7 +373,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
font->texture_size, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
&font->textures[font->texture_count], NULL)))
{
heap_free(buffer);
free(buffer);
return hr;
}
@ -385,7 +385,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
{
if (FAILED(hr = IDirect3DTexture9_LockRect(current_texture, 0, &lockrect, NULL, 0)))
{
heap_free(buffer);
free(buffer);
return hr;
}
mapped = TRUE;
@ -411,7 +411,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
+ current_glyph->black_box.left + x] =
(buffer[y * stride + x] * 255 / 64 << 24) | 0x00ffffffu;
heap_free(buffer);
free(buffer);
++font->texture_pos;
}
if (mapped)
@ -436,7 +436,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *s
countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0);
wstr = heap_alloc(countW * sizeof(*wstr));
wstr = malloc(countW * sizeof(*wstr));
if (!wstr)
return E_OUTOFMEMORY;
@ -444,7 +444,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *s
hr = ID3DXFont_PreloadTextW(iface, wstr, count < 0 ? countW - 1 : countW);
heap_free(wstr);
free(wstr);
return hr;
}
@ -466,7 +466,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR *
if (count < 0)
count = lstrlenW(string);
indices = heap_alloc(count * sizeof(*indices));
indices = malloc(count * sizeof(*indices));
if (!indices)
return E_OUTOFMEMORY;
@ -475,7 +475,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR *
for (i = 0; i < count; ++i)
ID3DXFont_PreloadGlyphs(iface, indices[i], indices[i]);
heap_free(indices);
free(indices);
return D3D_OK;
}
@ -497,7 +497,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite,
if (!countW)
return 0;
wstr = heap_alloc_zero(countW * sizeof(*wstr));
wstr = calloc(countW, sizeof(*wstr));
if (!wstr)
return 0;
@ -506,7 +506,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite,
ret = ID3DXFont_DrawTextW(iface, sprite, wstr, count < 0 ? countW - 1 : countW,
rect, format, color);
heap_free(wstr);
free(wstr);
return ret;
}
@ -520,7 +520,7 @@ static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len,
*chars_used = 0;
sla = heap_alloc(*str_len * sizeof(*sla));
sla = malloc(*str_len * sizeof(*sla));
if (!sla)
return;
@ -549,7 +549,7 @@ static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len,
/* Remeasure the string */
GetTextExtentExPointW(hdc, str, *str_len, 0, NULL, NULL, size);
heap_free(sla);
free(sla);
}
static const WCHAR *read_line(HDC hdc, const WCHAR *str, unsigned int *count,
@ -675,7 +675,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
if (format & DT_SINGLELINE)
format &= ~DT_WORDBREAK;
line = heap_alloc(count * sizeof(*line));
line = malloc(count * sizeof(*line));
if (!line)
return 0;
@ -731,14 +731,14 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
memset(&results, 0, sizeof(results));
results.nGlyphs = line_len;
results.lpCaretPos = heap_alloc(line_len * sizeof(*results.lpCaretPos));
results.lpCaretPos = malloc(line_len * sizeof(*results.lpCaretPos));
if (!results.lpCaretPos)
goto cleanup;
results.lpGlyphs = heap_alloc(line_len * sizeof(*results.lpGlyphs));
results.lpGlyphs = malloc(line_len * sizeof(*results.lpGlyphs));
if (!results.lpGlyphs)
{
heap_free(results.lpCaretPos);
free(results.lpCaretPos);
goto cleanup;
}
@ -779,8 +779,8 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
IDirect3DTexture9_Release(texture);
}
heap_free(results.lpCaretPos);
heap_free(results.lpGlyphs);
free(results.lpCaretPos);
free(results.lpGlyphs);
y += lh;
if (!(DT_NOCLIP & format) && (y > rect->bottom))
@ -796,7 +796,7 @@ cleanup:
ID3DXSprite_Release(target);
}
heap_free(line);
free(line);
return ret;
}
@ -925,7 +925,7 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_
}
IDirect3D9_Release(d3d);
object = heap_alloc_zero(sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
{
*font = NULL;
@ -939,7 +939,7 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_
object->hdc = CreateCompatibleDC(NULL);
if (!object->hdc)
{
heap_free(object);
free(object);
return D3DXERR_INVALIDDATA;
}
@ -948,7 +948,7 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_
if (!object->hfont)
{
DeleteDC(object->hdc);
heap_free(object);
free(object);
return D3DXERR_INVALIDDATA;
}
SelectObject(object->hdc, object->hfont);
@ -959,7 +959,7 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_
{
DeleteObject(object->hfont);
DeleteDC(object->hdc);
heap_free(object);
free(object);
return D3DXERR_INVALIDDATA;
}

View file

@ -75,7 +75,7 @@ static ULONG WINAPI d3dx9_line_Release(ID3DXLine *iface)
if (!refcount)
{
IDirect3DDevice9_Release(line->device);
HeapFree(GetProcessHeap(), 0, line);
free(line);
}
return refcount;
@ -309,7 +309,7 @@ HRESULT WINAPI D3DXCreateLine(struct IDirect3DDevice9 *device, struct ID3DXLine
if (!device || !line)
return D3DERR_INVALIDCALL;
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->ID3DXLine_iface.lpVtbl = &d3dx9_line_vtbl;

View file

@ -928,8 +928,8 @@ static ULONG WINAPI ID3DXMatrixStackImpl_Release(ID3DXMatrixStack *iface)
TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
if (!refcount)
{
HeapFree(GetProcessHeap(), 0, stack->stack);
HeapFree(GetProcessHeap(), 0, stack);
free(stack->stack);
free(stack);
}
return refcount;
}
@ -1002,7 +1002,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_Pop(ID3DXMatrixStack *iface)
D3DXMATRIX *new_stack;
new_size = This->stack_size / 2;
new_stack = HeapReAlloc(GetProcessHeap(), 0, This->stack, new_size * sizeof(*new_stack));
new_stack = realloc(This->stack, new_size * sizeof(*new_stack));
if (new_stack)
{
This->stack_size = new_size;
@ -1029,7 +1029,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_Push(ID3DXMatrixStack *iface)
if (This->stack_size > UINT_MAX / 2) return E_OUTOFMEMORY;
new_size = This->stack_size * 2;
new_stack = HeapReAlloc(GetProcessHeap(), 0, This->stack, new_size * sizeof(*new_stack));
new_stack = realloc(This->stack, new_size * sizeof(*new_stack));
if (!new_stack) return E_OUTOFMEMORY;
This->stack_size = new_size;
@ -1174,7 +1174,7 @@ HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, ID3DXMatrixStack **stack)
TRACE("flags %#lx, stack %p.\n", flags, stack);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
{
*stack = NULL;
return E_OUTOFMEMORY;
@ -1182,9 +1182,9 @@ HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, ID3DXMatrixStack **stack)
object->ID3DXMatrixStack_iface.lpVtbl = &ID3DXMatrixStack_Vtbl;
object->ref = 1;
if (!(object->stack = HeapAlloc(GetProcessHeap(), 0, INITIAL_STACK_SIZE * sizeof(*object->stack))))
if (!(object->stack = malloc(INITIAL_STACK_SIZE * sizeof(*object->stack))))
{
HeapFree(GetProcessHeap(), 0, object);
free(object);
*stack = NULL;
return E_OUTOFMEMORY;
}

View file

@ -132,9 +132,9 @@ static ULONG WINAPI d3dx9_mesh_Release(ID3DXMesh *iface)
if (mesh->vertex_declaration)
IDirect3DVertexDeclaration9_Release(mesh->vertex_declaration);
IDirect3DDevice9_Release(mesh->device);
HeapFree(GetProcessHeap(), 0, mesh->attrib_buffer);
HeapFree(GetProcessHeap(), 0, mesh->attrib_table);
HeapFree(GetProcessHeap(), 0, mesh);
free(mesh->attrib_buffer);
free(mesh->attrib_table);
free(mesh);
}
return refcount;
@ -755,7 +755,7 @@ static HRESULT WINAPI d3dx9_mesh_CloneMesh(struct ID3DXMesh *iface, DWORD option
if (This->attrib_table_size)
{
cloned_this->attrib_table_size = This->attrib_table_size;
cloned_this->attrib_table = HeapAlloc(GetProcessHeap(), 0, This->attrib_table_size * sizeof(*This->attrib_table));
cloned_this->attrib_table = malloc(This->attrib_table_size * sizeof(*This->attrib_table));
if (!cloned_this->attrib_table) {
hr = E_OUTOFMEMORY;
goto error;
@ -885,10 +885,10 @@ static HRESULT init_edge_face_map(struct edge_face_map *edge_face_map, const DWO
DWORD face, edge;
DWORD i;
edge_face_map->lists = HeapAlloc(GetProcessHeap(), 0, 3 * num_faces * sizeof(*edge_face_map->lists));
edge_face_map->lists = malloc(3 * num_faces * sizeof(*edge_face_map->lists));
if (!edge_face_map->lists) return E_OUTOFMEMORY;
edge_face_map->entries = HeapAlloc(GetProcessHeap(), 0, 3 * num_faces * sizeof(*edge_face_map->entries));
edge_face_map->entries = malloc(3 * num_faces * sizeof(*edge_face_map->entries));
if (!edge_face_map->entries) return E_OUTOFMEMORY;
@ -938,7 +938,7 @@ static DWORD *generate_identity_point_reps(DWORD num_vertices)
DWORD *id_point_reps;
DWORD i;
id_point_reps = HeapAlloc(GetProcessHeap(), 0, num_vertices * sizeof(*id_point_reps));
id_point_reps = malloc(num_vertices * sizeof(*id_point_reps));
if (!id_point_reps)
return NULL;
@ -994,7 +994,7 @@ static HRESULT WINAPI d3dx9_mesh_ConvertPointRepsToAdjacency(ID3DXMesh *iface,
/* Widen 16 bit to 32 bit */
DWORD i;
WORD *ib_16bit = ib_ptr;
ib = HeapAlloc(GetProcessHeap(), 0, 3 * num_faces * sizeof(DWORD));
ib = malloc(3 * num_faces * sizeof(DWORD));
if (!ib)
{
hr = E_OUTOFMEMORY;
@ -1031,10 +1031,10 @@ static HRESULT WINAPI d3dx9_mesh_ConvertPointRepsToAdjacency(ID3DXMesh *iface,
hr = D3D_OK;
cleanup:
HeapFree(GetProcessHeap(), 0, id_point_reps);
if (indices_are_16_bit) HeapFree(GetProcessHeap(), 0, ib);
HeapFree(GetProcessHeap(), 0, edge_face_map.lists);
HeapFree(GetProcessHeap(), 0, edge_face_map.entries);
free(id_point_reps);
if (indices_are_16_bit) free(ib);
free(edge_face_map.lists);
free(edge_face_map.entries);
if(ib_ptr) iface->lpVtbl->UnlockIndexBuffer(iface);
return hr;
}
@ -1131,7 +1131,7 @@ static HRESULT WINAPI d3dx9_mesh_ConvertAdjacencyToPointReps(ID3DXMesh *iface,
return D3DERR_INVALIDCALL;
}
if (!(new_indices = HeapAlloc(GetProcessHeap(), 0, 3 * mesh->numfaces * sizeof(*indices))))
if (!(new_indices = malloc(3 * mesh->numfaces * sizeof(*indices))))
return E_OUTOFMEMORY;
if (mesh->options & D3DXMESH_32BIT)
@ -1147,7 +1147,7 @@ static HRESULT WINAPI d3dx9_mesh_ConvertAdjacencyToPointReps(ID3DXMesh *iface,
if (FAILED(hr = iface->lpVtbl->LockIndexBuffer(iface, D3DLOCK_READONLY, (void **)&indices_16bit)))
goto cleanup;
if (!(indices = HeapAlloc(GetProcessHeap(), 0, 3 * mesh->numfaces * sizeof(*indices))))
if (!(indices = malloc(3 * mesh->numfaces * sizeof(*indices))))
{
hr = E_OUTOFMEMORY;
goto cleanup;
@ -1190,9 +1190,9 @@ static HRESULT WINAPI d3dx9_mesh_ConvertAdjacencyToPointReps(ID3DXMesh *iface,
{
if (indices_16bit)
iface->lpVtbl->UnlockIndexBuffer(iface);
HeapFree(GetProcessHeap(), 0, indices);
free(indices);
}
HeapFree(GetProcessHeap(), 0, new_indices);
free(new_indices);
return hr;
}
@ -1235,7 +1235,7 @@ static HRESULT WINAPI d3dx9_mesh_GenerateAdjacency(ID3DXMesh *iface, float epsil
buffer_size = This->numfaces * 3 * sizeof(*shared_indices) + This->numvertices * sizeof(*sorted_vertices);
if (!(This->options & D3DXMESH_32BIT))
buffer_size += This->numfaces * 3 * sizeof(*indices);
shared_indices = HeapAlloc(GetProcessHeap(), 0, buffer_size);
shared_indices = malloc(buffer_size);
if (!shared_indices)
return E_OUTOFMEMORY;
sorted_vertices = (struct vertex_metadata*)(shared_indices + This->numfaces * 3);
@ -1353,7 +1353,7 @@ static HRESULT WINAPI d3dx9_mesh_GenerateAdjacency(ID3DXMesh *iface, float epsil
cleanup:
if (indices) iface->lpVtbl->UnlockIndexBuffer(iface);
if (vertices) iface->lpVtbl->UnlockVertexBuffer(iface);
HeapFree(GetProcessHeap(), 0, shared_indices);
free(shared_indices);
return hr;
}
@ -1429,7 +1429,7 @@ static HRESULT WINAPI d3dx9_mesh_LockAttributeBuffer(ID3DXMesh *iface, DWORD fla
D3DXATTRIBUTERANGE *attrib_table = mesh->attrib_table;
mesh->attrib_table_size = 0;
mesh->attrib_table = NULL;
HeapFree(GetProcessHeap(), 0, attrib_table);
free(attrib_table);
}
*data = mesh->attrib_buffer;
@ -1600,14 +1600,14 @@ static HRESULT remap_faces_for_attrsort(struct d3dx9_mesh *This, const DWORD *in
DWORD **sorted_attrib_ptr_buffer = NULL;
DWORD i;
sorted_attrib_ptr_buffer = HeapAlloc(GetProcessHeap(), 0, This->numfaces * sizeof(*sorted_attrib_ptr_buffer));
sorted_attrib_ptr_buffer = malloc(This->numfaces * sizeof(*sorted_attrib_ptr_buffer));
if (!sorted_attrib_ptr_buffer)
return E_OUTOFMEMORY;
*face_remap = HeapAlloc(GetProcessHeap(), 0, This->numfaces * sizeof(**face_remap));
*face_remap = malloc(This->numfaces * sizeof(**face_remap));
if (!*face_remap)
{
HeapFree(GetProcessHeap(), 0, sorted_attrib_ptr_buffer);
free(sorted_attrib_ptr_buffer);
return E_OUTOFMEMORY;
}
@ -1674,7 +1674,7 @@ static HRESULT WINAPI d3dx9_mesh_OptimizeInplace(ID3DXMesh *iface, DWORD flags,
hr = iface->lpVtbl->LockIndexBuffer(iface, 0, &indices);
if (FAILED(hr)) goto cleanup;
dword_indices = HeapAlloc(GetProcessHeap(), 0, This->numfaces * 3 * sizeof(DWORD));
dword_indices = malloc(This->numfaces * 3 * sizeof(DWORD));
if (!dword_indices) return E_OUTOFMEMORY;
if (This->options & D3DXMESH_32BIT) {
memcpy(dword_indices, indices, This->numfaces * 3 * sizeof(DWORD));
@ -1746,7 +1746,7 @@ static HRESULT WINAPI d3dx9_mesh_OptimizeInplace(ID3DXMesh *iface, DWORD flags,
DWORD attrib_table_size;
attrib_table_size = count_attributes(sorted_attrib_buffer, This->numfaces);
attrib_table = HeapAlloc(GetProcessHeap(), 0, attrib_table_size * sizeof(*attrib_table));
attrib_table = malloc(attrib_table_size * sizeof(*attrib_table));
if (!attrib_table) {
hr = E_OUTOFMEMORY;
goto cleanup;
@ -1772,7 +1772,7 @@ static HRESULT WINAPI d3dx9_mesh_OptimizeInplace(ID3DXMesh *iface, DWORD flags,
fill_attribute_table(attrib_buffer, This->numfaces, indices,
This->options & D3DXMESH_32BIT, attrib_table);
HeapFree(GetProcessHeap(), 0, This->attrib_table);
free(This->attrib_table);
This->attrib_table = attrib_table;
This->attrib_table_size = attrib_table_size;
} else {
@ -1821,9 +1821,9 @@ static HRESULT WINAPI d3dx9_mesh_OptimizeInplace(ID3DXMesh *iface, DWORD flags,
hr = D3D_OK;
cleanup:
HeapFree(GetProcessHeap(), 0, sorted_attrib_buffer);
HeapFree(GetProcessHeap(), 0, face_remap);
HeapFree(GetProcessHeap(), 0, dword_indices);
free(sorted_attrib_buffer);
free(face_remap);
free(dword_indices);
if (vertex_remap) ID3DXBuffer_Release(vertex_remap);
if (vertex_buffer) IDirect3DVertexBuffer9_Release(vertex_buffer);
if (attrib_buffer) iface->lpVtbl->UnlockAttributeBuffer(iface);
@ -1842,7 +1842,7 @@ static HRESULT WINAPI d3dx9_mesh_SetAttributeTable(ID3DXMesh *iface,
if (attrib_table_size) {
size_t size = attrib_table_size * sizeof(*attrib_table);
new_table = HeapAlloc(GetProcessHeap(), 0, size);
new_table = malloc(size);
if (!new_table)
return E_OUTOFMEMORY;
@ -1850,7 +1850,7 @@ static HRESULT WINAPI d3dx9_mesh_SetAttributeTable(ID3DXMesh *iface,
} else if (attrib_table) {
return D3DERR_INVALIDCALL;
}
HeapFree(GetProcessHeap(), 0, mesh->attrib_table);
free(mesh->attrib_table);
mesh->attrib_table = new_table;
mesh->attrib_table_size = attrib_table_size;
@ -2536,12 +2536,12 @@ HRESULT WINAPI D3DXCreateMesh(DWORD numfaces, DWORD numvertices, DWORD options,
return hr;
}
attrib_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, numfaces * sizeof(*attrib_buffer));
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
attrib_buffer = calloc(numfaces, sizeof(*attrib_buffer));
object = calloc(1, sizeof(*object));
if (object == NULL || attrib_buffer == NULL)
{
HeapFree(GetProcessHeap(), 0, object);
HeapFree(GetProcessHeap(), 0, attrib_buffer);
free(object);
free(attrib_buffer);
IDirect3DIndexBuffer9_Release(index_buffer);
IDirect3DVertexBuffer9_Release(vertex_buffer);
IDirect3DVertexDeclaration9_Release(vertex_declaration);
@ -2625,14 +2625,13 @@ static HRESULT parse_texture_filename(ID3DXFileData *filedata, char **filename_o
SIZE_T data_size;
BYTE *data;
char *filename_in;
char *filename = NULL;
/* template TextureFilename {
* STRING filename;
* }
*/
HeapFree(GetProcessHeap(), 0, *filename_out);
free(*filename_out);
*filename_out = NULL;
hr = filedata->lpVtbl->Lock(filedata, &data_size, (const void**)&data);
@ -2647,15 +2646,11 @@ static HRESULT parse_texture_filename(ID3DXFileData *filedata, char **filename_o
}
filename_in = *(char **)data;
filename = HeapAlloc(GetProcessHeap(), 0, strlen(filename_in) + 1);
if (!filename) {
if (!(*filename_out = strdup(filename_in))) {
filedata->lpVtbl->Unlock(filedata);
return E_OUTOFMEMORY;
}
strcpy(filename, filename_in);
*filename_out = filename;
filedata->lpVtbl->Unlock(filedata);
return D3D_OK;
@ -2750,9 +2745,9 @@ static void destroy_materials(struct mesh_data *mesh)
unsigned int i;
for (i = 0; i < mesh->num_materials; ++i)
HeapFree(GetProcessHeap(), 0, mesh->materials[i].pTextureFilename);
HeapFree(GetProcessHeap(), 0, mesh->materials);
HeapFree(GetProcessHeap(), 0, mesh->material_indices);
free(mesh->materials[i].pTextureFilename);
free(mesh->materials);
free(mesh->material_indices);
mesh->num_materials = 0;
mesh->materials = NULL;
mesh->material_indices = NULL;
@ -2826,8 +2821,8 @@ static HRESULT parse_material_list(ID3DXFileData *filedata, struct mesh_data *me
}
}
mesh->materials = HeapAlloc(GetProcessHeap(), 0, material_count * sizeof(*mesh->materials));
mesh->material_indices = HeapAlloc(GetProcessHeap(), 0, mesh->num_poly_faces * sizeof(*mesh->material_indices));
mesh->materials = malloc(material_count * sizeof(*mesh->materials));
mesh->material_indices = malloc(mesh->num_poly_faces * sizeof(*mesh->material_indices));
if (!mesh->materials || !mesh->material_indices) {
hr = E_OUTOFMEMORY;
goto end;
@ -2882,7 +2877,7 @@ static HRESULT parse_texture_coords(ID3DXFileData *filedata, struct mesh_data *m
SIZE_T data_size;
HRESULT hr;
HeapFree(GetProcessHeap(), 0, mesh->tex_coords);
free(mesh->tex_coords);
mesh->tex_coords = NULL;
hr = filedata->lpVtbl->Lock(filedata, &data_size, (const void **)&data);
@ -2918,7 +2913,7 @@ static HRESULT parse_texture_coords(ID3DXFileData *filedata, struct mesh_data *m
goto end;
}
mesh->tex_coords = HeapAlloc(GetProcessHeap(), 0, mesh->num_vertices * sizeof(*mesh->tex_coords));
mesh->tex_coords = malloc(mesh->num_vertices * sizeof(*mesh->tex_coords));
if (!mesh->tex_coords) {
hr = E_OUTOFMEMORY;
goto end;
@ -2941,7 +2936,7 @@ static HRESULT parse_vertex_colors(ID3DXFileData *filedata, struct mesh_data *me
SIZE_T data_size;
HRESULT hr;
HeapFree(GetProcessHeap(), 0, mesh->vertex_colors);
free(mesh->vertex_colors);
mesh->vertex_colors = NULL;
hr = filedata->lpVtbl->Lock(filedata, &data_size, (const void **)&data);
@ -2972,7 +2967,7 @@ static HRESULT parse_vertex_colors(ID3DXFileData *filedata, struct mesh_data *me
goto end;
}
mesh->vertex_colors = HeapAlloc(GetProcessHeap(), 0, mesh->num_vertices * sizeof(uint32_t));
mesh->vertex_colors = malloc(mesh->num_vertices * sizeof(uint32_t));
if (!mesh->vertex_colors) {
hr = E_OUTOFMEMORY;
goto end;
@ -3022,7 +3017,7 @@ static HRESULT parse_normals(ID3DXFileData *filedata, struct mesh_data *mesh, DW
unsigned int i;
HRESULT hr;
HeapFree(GetProcessHeap(), 0, mesh->normals);
free(mesh->normals);
mesh->num_normals = 0;
mesh->normals = NULL;
mesh->normal_indices = NULL;
@ -3064,8 +3059,8 @@ static HRESULT parse_normals(ID3DXFileData *filedata, struct mesh_data *mesh, DW
goto end;
}
mesh->normals = HeapAlloc(GetProcessHeap(), 0, mesh->num_normals * sizeof(D3DXVECTOR3));
mesh->normal_indices = HeapAlloc(GetProcessHeap(), 0, num_face_indices * sizeof(uint32_t));
mesh->normals = malloc(mesh->num_normals * sizeof(D3DXVECTOR3));
mesh->normal_indices = malloc(num_face_indices * sizeof(uint32_t));
if (!mesh->normals || !mesh->normal_indices) {
hr = E_OUTOFMEMORY;
goto end;
@ -3317,12 +3312,9 @@ static HRESULT parse_mesh(ID3DXFileData *filedata, struct mesh_data *mesh_data,
mesh_data->fvf = D3DFVF_XYZ;
mesh_data->vertices = HeapAlloc(GetProcessHeap(), 0,
mesh_data->num_vertices * sizeof(*mesh_data->vertices));
mesh_data->num_tri_per_face = HeapAlloc(GetProcessHeap(), 0,
mesh_data->num_poly_faces * sizeof(*mesh_data->num_tri_per_face));
mesh_data->indices = HeapAlloc(GetProcessHeap(), 0,
(mesh_data->num_tri_faces + mesh_data->num_poly_faces * 2) * sizeof(*mesh_data->indices));
mesh_data->vertices = malloc(mesh_data->num_vertices * sizeof(*mesh_data->vertices));
mesh_data->num_tri_per_face = malloc(mesh_data->num_poly_faces * sizeof(*mesh_data->num_tri_per_face));
mesh_data->indices = malloc((mesh_data->num_tri_faces + mesh_data->num_poly_faces * 2) * sizeof(*mesh_data->indices));
if (!mesh_data->vertices || !mesh_data->num_tri_per_face || !mesh_data->indices) {
hr = E_OUTOFMEMORY;
goto end;
@ -3547,7 +3539,7 @@ HRESULT WINAPI D3DXLoadSkinMeshFromXof(struct ID3DXFileData *filedata, DWORD opt
if (mesh_data.fvf & D3DFVF_NORMAL) {
/* duplicate vertices with multiple normals */
DWORD num_face_indices = mesh_data.num_poly_faces * 2 + mesh_data.num_tri_faces;
duplications = HeapAlloc(GetProcessHeap(), 0, (mesh_data.num_vertices + num_face_indices) * sizeof(*duplications));
duplications = malloc((mesh_data.num_vertices + num_face_indices) * sizeof(*duplications));
if (!duplications) {
hr = E_OUTOFMEMORY;
goto cleanup;
@ -3739,15 +3731,15 @@ cleanup:
if (mesh_data.skin_info) mesh_data.skin_info->lpVtbl->Release(mesh_data.skin_info);
if (skin_info_out) *skin_info_out = NULL;
}
HeapFree(GetProcessHeap(), 0, mesh_data.vertices);
HeapFree(GetProcessHeap(), 0, mesh_data.num_tri_per_face);
HeapFree(GetProcessHeap(), 0, mesh_data.indices);
HeapFree(GetProcessHeap(), 0, mesh_data.normals);
HeapFree(GetProcessHeap(), 0, mesh_data.normal_indices);
free(mesh_data.vertices);
free(mesh_data.num_tri_per_face);
free(mesh_data.indices);
free(mesh_data.normals);
free(mesh_data.normal_indices);
destroy_materials(&mesh_data);
HeapFree(GetProcessHeap(), 0, mesh_data.tex_coords);
HeapFree(GetProcessHeap(), 0, mesh_data.vertex_colors);
HeapFree(GetProcessHeap(), 0, duplications);
free(mesh_data.tex_coords);
free(mesh_data.vertex_colors);
free(duplications);
return hr;
}
@ -3768,13 +3760,13 @@ HRESULT WINAPI D3DXLoadMeshHierarchyFromXA(const char *filename, DWORD options,
return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
filenameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filenameW = malloc(len * sizeof(WCHAR));
if (!filenameW) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, len);
hr = D3DXLoadMeshHierarchyFromXW(filenameW, options, device,
alloc_hier, load_user_data, frame_hierarchy, anim_controller);
HeapFree(GetProcessHeap(), 0, filenameW);
free(filenameW);
return hr;
}
@ -3817,12 +3809,12 @@ static HRESULT filedata_get_name(ID3DXFileData *filedata, char **name)
if (!name_len)
name_len++;
*name = HeapAlloc(GetProcessHeap(), 0, name_len);
*name = malloc(name_len);
if (!*name) return E_OUTOFMEMORY;
hr = filedata->lpVtbl->GetName(filedata, *name, &name_len);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, *name);
free(*name);
else if (!name_len)
(*name)[0] = 0;
@ -3894,7 +3886,7 @@ cleanup:
if (adjacency) ID3DXBuffer_Release(adjacency);
if (skin_info) IUnknown_Release(skin_info);
if (mesh_data.pMesh) IUnknown_Release(mesh_data.pMesh);
HeapFree(GetProcessHeap(), 0, name);
free(name);
return hr;
}
@ -3945,7 +3937,7 @@ static HRESULT load_frame(struct ID3DXFileData *filedata, DWORD options, struct
if (FAILED(hr)) return hr;
hr = alloc_hier->lpVtbl->CreateFrame(alloc_hier, name, frame_out);
HeapFree(GetProcessHeap(), 0, name);
free(name);
if (FAILED(hr)) return E_FAIL;
frame = *frame_out;
@ -4165,13 +4157,13 @@ HRESULT WINAPI D3DXLoadMeshFromXA(const char *filename, DWORD options, struct ID
return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
filenameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filenameW = malloc(len * sizeof(WCHAR));
if (!filenameW) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, len);
hr = D3DXLoadMeshFromXW(filenameW, options, device, adjacency, materials,
effect_instances, num_materials, mesh);
HeapFree(GetProcessHeap(), 0, filenameW);
free(filenameW);
return hr;
}
@ -4262,7 +4254,7 @@ static HRESULT parse_frame(struct ID3DXFileData *filedata, DWORD options, struct
goto err;
if (IsEqualGUID(&type, &TID_D3DRMMesh)) {
struct mesh_container *container = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*container));
struct mesh_container *container = calloc(1, sizeof(*container));
if (!container)
{
hr = E_OUTOFMEMORY;
@ -4281,7 +4273,7 @@ static HRESULT parse_frame(struct ID3DXFileData *filedata, DWORD options, struct
}
else
{
HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, container);
free(container);
}
} else if (IsEqualGUID(&type, &TID_D3DRMFrameTransformMatrix)) {
D3DXMATRIX new_transform;
@ -4365,7 +4357,7 @@ HRESULT WINAPI D3DXLoadMeshFromXInMemory(const void *memory, DWORD memory_size,
hr = filedata->lpVtbl->GetType(filedata, &guid);
if (SUCCEEDED(hr)) {
if (IsEqualGUID(&guid, &TID_D3DRMMesh)) {
container_ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*container_ptr));
container_ptr = calloc(1, sizeof(*container_ptr));
if (!container_ptr) {
hr = E_OUTOFMEMORY;
goto cleanup;
@ -4382,7 +4374,7 @@ HRESULT WINAPI D3DXLoadMeshFromXInMemory(const void *memory, DWORD memory_size,
}
else
{
HeapFree(GetProcessHeap(), 0, container_ptr);
free(container_ptr);
}
} else if (IsEqualGUID(&guid, &TID_D3DRMFrame)) {
hr = parse_frame(filedata, options, device, &identity, &container_list, provide_flags);
@ -4664,7 +4656,7 @@ cleanup:
if (container_ptr->adjacency) ID3DXBuffer_Release(container_ptr->adjacency);
if (container_ptr->materials) ID3DXBuffer_Release(container_ptr->materials);
if (container_ptr->effects) ID3DXBuffer_Release(container_ptr->effects);
HeapFree(GetProcessHeap(), 0, container_ptr);
free(container_ptr);
}
return hr;
}
@ -4869,8 +4861,8 @@ struct sincos_table
static void free_sincos_table(struct sincos_table *sincos_table)
{
HeapFree(GetProcessHeap(), 0, sincos_table->cos);
HeapFree(GetProcessHeap(), 0, sincos_table->sin);
free(sincos_table->cos);
free(sincos_table->sin);
}
/* pre compute sine and cosine tables; caller must free */
@ -4879,15 +4871,15 @@ static BOOL compute_sincos_table(struct sincos_table *sincos_table, float angle_
float angle;
int i;
sincos_table->sin = HeapAlloc(GetProcessHeap(), 0, n * sizeof(*sincos_table->sin));
sincos_table->sin = malloc(n * sizeof(*sincos_table->sin));
if (!sincos_table->sin)
{
return FALSE;
}
sincos_table->cos = HeapAlloc(GetProcessHeap(), 0, n * sizeof(*sincos_table->cos));
sincos_table->cos = malloc(n * sizeof(*sincos_table->cos));
if (!sincos_table->cos)
{
HeapFree(GetProcessHeap(), 0, sincos_table->sin);
free(sincos_table->sin);
return FALSE;
}
@ -5303,12 +5295,12 @@ HRESULT WINAPI D3DXCreateTextA(struct IDirect3DDevice9 *device, HDC hdc, const c
return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, text, -1, NULL, 0);
textW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
textW = malloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, text, -1, textW, len);
hr = D3DXCreateTextW(device, hdc, textW, deviation, extrusion,
mesh, adjacency, glyphmetrics);
HeapFree(GetProcessHeap(), 0, textW);
free(textW);
return hr;
}
@ -5508,14 +5500,8 @@ static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
{
if (count > array->capacity) {
void *new_buffer;
int new_capacity;
if (array->items && array->capacity) {
new_capacity = max(array->capacity * 2, count);
new_buffer = HeapReAlloc(GetProcessHeap(), 0, array->items, new_capacity * itemsize);
} else {
new_capacity = max(16, count);
new_buffer = HeapAlloc(GetProcessHeap(), 0, new_capacity * itemsize);
}
int new_capacity = max(array->capacity ? array->capacity * 2 : 16, count);
new_buffer = realloc(array->items, new_capacity * itemsize);
if (!new_buffer)
return FALSE;
array->items = new_buffer;
@ -5857,7 +5843,7 @@ static D3DXVECTOR2 *get_ordered_vertex(struct glyphinfo *glyph, WORD index)
static void remove_triangulation(struct triangulation_array *array, struct triangulation *item)
{
HeapFree(GetProcessHeap(), 0, item->vertex_stack.items);
free(item->vertex_stack.items);
MoveMemory(item, item + 1, (char*)&array->items[array->count] - (char*)(item + 1));
array->count--;
}
@ -5986,8 +5972,7 @@ static HRESULT triangulate(struct triangulation_array *triangulations)
for (i = 0; i < glyph->outlines.count; i++)
nb_vertices += glyph->outlines.items[i].count;
glyph->ordered_vertices.items = HeapAlloc(GetProcessHeap(), 0,
nb_vertices * sizeof(*glyph->ordered_vertices.items));
glyph->ordered_vertices.items = malloc(nb_vertices * sizeof(*glyph->ordered_vertices.items));
if (!glyph->ordered_vertices.items)
return E_OUTOFMEMORY;
@ -6034,8 +6019,7 @@ static HRESULT triangulate(struct triangulation_array *triangulations)
}
if (ccw <= 0)
{
glyph->faces.items = HeapAlloc(GetProcessHeap(), 0,
(outline->count - 2) * sizeof(glyph->faces.items[0]));
glyph->faces.items = malloc((outline->count - 2) * sizeof(glyph->faces.items[0]));
if (!glyph->faces.items)
return E_OUTOFMEMORY;
@ -6060,8 +6044,7 @@ static HRESULT triangulate(struct triangulation_array *triangulations)
* # faces for outer outlines = outline->count - 2
* # faces for inner outlines = outline->count + 2
* There must be at least 1 outer outline. */
glyph->faces.items = HeapAlloc(GetProcessHeap(), 0,
(nb_vertices + glyph->outlines.count * 2 - 4) * sizeof(glyph->faces.items[0]));
glyph->faces.items = malloc((nb_vertices + glyph->outlines.count * 2 - 4) * sizeof(glyph->faces.items[0]));
if (!glyph->faces.items)
return E_OUTOFMEMORY;
@ -6282,8 +6265,8 @@ HRESULT WINAPI D3DXCreateTextW(struct IDirect3DDevice9 *device, HDC hdc, const W
goto error;
}
glyphs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, textlen * sizeof(*glyphs));
raw_outline = HeapAlloc(GetProcessHeap(), 0, bufsize);
glyphs = calloc(textlen, sizeof(*glyphs));
raw_outline = malloc(bufsize);
if (!glyphs || !raw_outline) {
hr = E_OUTOFMEMORY;
goto error;
@ -6525,20 +6508,20 @@ error:
{
int j;
for (j = 0; j < glyphs[i].outlines.count; j++)
HeapFree(GetProcessHeap(), 0, glyphs[i].outlines.items[j].items);
HeapFree(GetProcessHeap(), 0, glyphs[i].outlines.items);
HeapFree(GetProcessHeap(), 0, glyphs[i].faces.items);
HeapFree(GetProcessHeap(), 0, glyphs[i].ordered_vertices.items);
free(glyphs[i].outlines.items[j].items);
free(glyphs[i].outlines.items);
free(glyphs[i].faces.items);
free(glyphs[i].ordered_vertices.items);
}
HeapFree(GetProcessHeap(), 0, glyphs);
free(glyphs);
}
if (triangulations.items) {
int i;
for (i = 0; i < triangulations.count; i++)
HeapFree(GetProcessHeap(), 0, triangulations.items[i].vertex_stack.items);
HeapFree(GetProcessHeap(), 0, triangulations.items);
free(triangulations.items[i].vertex_stack.items);
free(triangulations.items);
}
HeapFree(GetProcessHeap(), 0, raw_outline);
free(raw_outline);
if (oldfont) SelectObject(hdc, oldfont);
if (font) DeleteObject(font);
@ -7151,7 +7134,7 @@ HRESULT WINAPI D3DXWeldVertices(ID3DXMesh *mesh, DWORD flags, const D3DXWELDEPSI
}
else /* Adjacency has to be generated. */
{
adjacency_generated = HeapAlloc(GetProcessHeap(), 0, 3 * This->numfaces * sizeof(*adjacency_generated));
adjacency_generated = malloc(3 * This->numfaces * sizeof(*adjacency_generated));
if (!adjacency_generated)
{
ERR("Couldn't allocate memory for adjacency_generated.\n");
@ -7168,7 +7151,7 @@ HRESULT WINAPI D3DXWeldVertices(ID3DXMesh *mesh, DWORD flags, const D3DXWELDEPSI
}
/* Point representation says which vertices can be replaced. */
point_reps = HeapAlloc(GetProcessHeap(), 0, This->numvertices * sizeof(*point_reps));
point_reps = malloc(This->numvertices * sizeof(*point_reps));
if (!point_reps)
{
hr = E_OUTOFMEMORY;
@ -7195,7 +7178,7 @@ HRESULT WINAPI D3DXWeldVertices(ID3DXMesh *mesh, DWORD flags, const D3DXWELDEPSI
ERR("Couldn't lock attribute buffer.\n");
goto cleanup;
}
vertex_face_map = HeapAlloc(GetProcessHeap(), 0, This->numvertices * sizeof(*vertex_face_map));
vertex_face_map = malloc(This->numvertices * sizeof(*vertex_face_map));
if (!vertex_face_map)
{
hr = E_OUTOFMEMORY;
@ -7295,9 +7278,9 @@ HRESULT WINAPI D3DXWeldVertices(ID3DXMesh *mesh, DWORD flags, const D3DXWELDEPSI
hr = D3D_OK;
cleanup:
HeapFree(GetProcessHeap(), 0, adjacency_generated);
HeapFree(GetProcessHeap(), 0, point_reps);
HeapFree(GetProcessHeap(), 0, vertex_face_map);
free(adjacency_generated);
free(point_reps);
free(vertex_face_map);
if (attributes) mesh->lpVtbl->UnlockAttributeBuffer(mesh);
if (indices) mesh->lpVtbl->UnlockIndexBuffer(mesh);
if (vertices) mesh->lpVtbl->UnlockVertexBuffer(mesh);
@ -7509,7 +7492,7 @@ HRESULT WINAPI D3DXComputeTangentFrameEx(ID3DXMesh *mesh, DWORD texture_in_seman
vertex_stride = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
indices_are_32bit = mesh->lpVtbl->GetOptions(mesh) & D3DXMESH_32BIT;
point_reps = HeapAlloc(GetProcessHeap(), 0, num_vertices * sizeof(*point_reps));
point_reps = malloc(num_vertices * sizeof(*point_reps));
if (!point_reps)
{
hr = E_OUTOFMEMORY;
@ -7626,7 +7609,7 @@ done:
if (indices)
mesh->lpVtbl->UnlockIndexBuffer(mesh);
HeapFree(GetProcessHeap(), 0, point_reps);
free(point_reps);
return hr;
}
@ -7693,7 +7676,7 @@ static BOOL queue_frame_node(struct list *queue, D3DXFRAME *frame)
if (!frame->pFrameFirstChild)
return TRUE;
node = HeapAlloc(GetProcessHeap(), 0, sizeof(*node));
node = malloc(sizeof(*node));
if (!node)
return FALSE;
@ -7709,7 +7692,7 @@ static void empty_frame_queue(struct list *queue)
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, queue, struct frame_node, entry)
{
list_remove(&cur->entry);
HeapFree(GetProcessHeap(), 0, cur);
free(cur);
}
}
@ -7751,7 +7734,7 @@ D3DXFRAME * WINAPI D3DXFrameFind(const D3DXFRAME *root, const char *name)
node = LIST_ENTRY(list_head(&queue), struct frame_node, entry);
list_remove(&node->entry);
frame = node->frame->pFrameFirstChild;
HeapFree(GetProcessHeap(), 0, node);
free(node);
}
cleanup:

View file

@ -308,7 +308,7 @@ static HRESULT regstore_alloc_table(struct d3dx_regstore *rs, unsigned int table
size = get_offset_reg(table, rs->table_sizes[table]) * table_info[table].component_size;
if (size)
{
rs->tables[table] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
rs->tables[table] = calloc(1, size);
if (!rs->tables[table])
return E_OUTOFMEMORY;
}
@ -321,7 +321,7 @@ static void regstore_free_tables(struct d3dx_regstore *rs)
for (i = 0; i < PRES_REGTAB_COUNT; ++i)
{
HeapFree(GetProcessHeap(), 0, rs->tables[i]);
free(rs->tables[i]);
}
}
@ -593,7 +593,7 @@ static HRESULT append_const_set(struct d3dx_const_tab *const_tab, struct d3dx_co
if (!const_tab->const_set_size)
{
new_size = INITIAL_CONST_SET_SIZE;
new_alloc = HeapAlloc(GetProcessHeap(), 0, sizeof(*const_tab->const_set) * new_size);
new_alloc = malloc(sizeof(*const_tab->const_set) * new_size);
if (!new_alloc)
{
ERR("Out of memory.\n");
@ -603,8 +603,7 @@ static HRESULT append_const_set(struct d3dx_const_tab *const_tab, struct d3dx_co
else
{
new_size = const_tab->const_set_size * 2;
new_alloc = HeapReAlloc(GetProcessHeap(), 0, const_tab->const_set,
sizeof(*const_tab->const_set) * new_size);
new_alloc = realloc(const_tab->const_set, sizeof(*const_tab->const_set) * new_size);
if (!new_alloc)
{
ERR("Out of memory.\n");
@ -875,8 +874,8 @@ static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab
goto cleanup;
}
out->inputs = cdesc = HeapAlloc(GetProcessHeap(), 0, sizeof(*cdesc) * desc.Constants);
out->inputs_param = inputs_param = HeapAlloc(GetProcessHeap(), 0, sizeof(*inputs_param) * desc.Constants);
out->inputs = cdesc = malloc(sizeof(*cdesc) * desc.Constants);
out->inputs_param = inputs_param = malloc(sizeof(*inputs_param) * desc.Constants);
if (!cdesc || !inputs_param)
{
hr = E_OUTOFMEMORY;
@ -980,8 +979,7 @@ static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab
}
}
new_alloc = HeapReAlloc(GetProcessHeap(), 0, out->const_set,
sizeof(*out->const_set) * out->const_set_count);
new_alloc = realloc(out->const_set, sizeof(*out->const_set) * out->const_set_count);
if (new_alloc)
{
out->const_set = new_alloc;
@ -1158,7 +1156,7 @@ static HRESULT parse_preshader(struct d3dx_preshader *pres, unsigned int *ptr, u
return D3DXERR_INVALIDDATA;
}
TRACE("%u instructions.\n", pres->ins_count);
pres->ins = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pres->ins) * pres->ins_count);
pres->ins = calloc(pres->ins_count, sizeof(*pres->ins));
if (!pres->ins)
return E_OUTOFMEMORY;
for (i = 0; i < pres->ins_count; ++i)
@ -1252,7 +1250,7 @@ HRESULT d3dx_create_param_eval(struct d3dx_parameters_store *parameters, void *b
return D3D_OK;
}
peval = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*peval));
peval = calloc(1, sizeof(*peval));
if (!peval)
{
ret = E_OUTOFMEMORY;
@ -1343,14 +1341,14 @@ err_out:
static void d3dx_free_const_tab(struct d3dx_const_tab *ctab)
{
HeapFree(GetProcessHeap(), 0, ctab->inputs);
HeapFree(GetProcessHeap(), 0, ctab->inputs_param);
HeapFree(GetProcessHeap(), 0, ctab->const_set);
free(ctab->inputs);
free(ctab->inputs_param);
free(ctab->const_set);
}
static void d3dx_free_preshader(struct d3dx_preshader *pres)
{
HeapFree(GetProcessHeap(), 0, pres->ins);
free(pres->ins);
regstore_free_tables(&pres->regs);
d3dx_free_const_tab(&pres->inputs);
@ -1365,7 +1363,7 @@ void d3dx_free_param_eval(struct d3dx_param_eval *peval)
d3dx_free_preshader(&peval->pres);
d3dx_free_const_tab(&peval->shader_inputs);
HeapFree(GetProcessHeap(), 0, peval);
free(peval);
}
static void pres_int_from_float(void *out, const void *in, unsigned int count)

View file

@ -40,8 +40,7 @@ static HRESULT device_state_init(IDirect3DDevice9 *device, struct device_state *
if (FAILED(hr)) return hr;
state->num_render_targets = caps.NumSimultaneousRTs;
state->render_targets = HeapAlloc(GetProcessHeap(), 0,
state->num_render_targets * sizeof(IDirect3DSurface9 *));
state->render_targets = malloc(state->num_render_targets * sizeof(IDirect3DSurface9 *));
if (!state->render_targets)
return E_OUTOFMEMORY;
@ -100,7 +99,7 @@ static void device_state_release(struct device_state *state)
IDirect3DSurface9_Release(state->render_targets[i]);
}
HeapFree(GetProcessHeap(), 0, state->render_targets);
free(state->render_targets);
if (state->depth_stencil) IDirect3DSurface9_Release(state->depth_stencil);
}
@ -174,7 +173,7 @@ static ULONG WINAPI D3DXRenderToSurface_Release(ID3DXRenderToSurface *iface)
IDirect3DDevice9_Release(render->device);
HeapFree(GetProcessHeap(), 0, render);
free(render);
}
return ref;
@ -386,7 +385,7 @@ HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device,
if (!device || !out) return D3DERR_INVALIDCALL;
render = HeapAlloc(GetProcessHeap(), 0, sizeof(struct render_to_surface));
render = malloc(sizeof(struct render_to_surface));
if (!render) return E_OUTOFMEMORY;
render->ID3DXRenderToSurface_iface.lpVtbl = &render_to_surface_vtbl;
@ -405,7 +404,7 @@ HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device,
hr = device_state_init(device, &render->previous_state);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, render);
free(render);
return hr;
}
@ -513,7 +512,7 @@ static ULONG WINAPI D3DXRenderToEnvMap_Release(ID3DXRenderToEnvMap *iface)
IDirect3DDevice9_Release(render->device);
HeapFree(GetProcessHeap(), 0, render);
free(render);
}
return ref;
@ -764,7 +763,7 @@ HRESULT WINAPI D3DXCreateRenderToEnvMap(IDirect3DDevice9 *device,
D3DUSAGE_RENDERTARGET, &format, D3DPOOL_DEFAULT);
if (FAILED(hr)) return hr;
render = HeapAlloc(GetProcessHeap(), 0, sizeof(struct render_to_envmap));
render = malloc(sizeof(*render));
if (!render) return E_OUTOFMEMORY;
render->ID3DXRenderToEnvMap_iface.lpVtbl = &render_to_envmap_vtbl;
@ -784,7 +783,7 @@ HRESULT WINAPI D3DXCreateRenderToEnvMap(IDirect3DDevice9 *device,
hr = device_state_init(device, &render->previous_device_state);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, render);
free(render);
return hr;
}

View file

@ -271,7 +271,7 @@ static HRESULT WINAPI d3dx_include_from_file_open(ID3DXInclude *iface, D3DXINCLU
++p;
else
p = parent_name;
pathname = HeapAlloc(GetProcessHeap(), 0, (p - parent_name) + strlen(filename) + 1);
pathname = malloc((p - parent_name) + strlen(filename) + 1);
if(!pathname)
return HRESULT_FROM_WIN32(GetLastError());
@ -295,7 +295,7 @@ static HRESULT WINAPI d3dx_include_from_file_open(ID3DXInclude *iface, D3DXINCLU
if(size == INVALID_FILE_SIZE)
goto error;
buffer = HeapAlloc(GetProcessHeap(), 0, size + sizeof(char *));
buffer = malloc(size + sizeof(char *));
if(!buffer)
goto error;
*buffer = pathname;
@ -311,15 +311,15 @@ static HRESULT WINAPI d3dx_include_from_file_open(ID3DXInclude *iface, D3DXINCLU
error:
CloseHandle(file);
HeapFree(GetProcessHeap(), 0, pathname);
HeapFree(GetProcessHeap(), 0, buffer);
free(pathname);
free(buffer);
return HRESULT_FROM_WIN32(GetLastError());
}
static HRESULT WINAPI d3dx_include_from_file_close(ID3DXInclude *iface, const void *data)
{
HeapFree(GetProcessHeap(), 0, *((char **)data - 1));
HeapFree(GetProcessHeap(), 0, (char **)data - 1);
free(*((char **)data - 1));
free((char **)data - 1);
if (main_file_data == data)
main_file_data = NULL;
return S_OK;
@ -344,13 +344,13 @@ HRESULT WINAPI D3DXAssembleShaderFromFileA(const char *filename, const D3DXMACRO
if (!filename) return D3DXERR_INVALIDDATA;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filename_w = malloc(len * sizeof(WCHAR));
if (!filename_w) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
ret = D3DXAssembleShaderFromFileW(filename_w, defines, include, flags, shader, error_messages);
HeapFree(GetProcessHeap(), 0, filename_w);
free(filename_w);
return ret;
}
@ -373,7 +373,7 @@ HRESULT WINAPI D3DXAssembleShaderFromFileW(const WCHAR *filename, const D3DXMACR
}
len = WideCharToMultiByte(CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL);
filename_a = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
filename_a = malloc(len * sizeof(char));
if (!filename_a)
return E_OUTOFMEMORY;
WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, len, NULL, NULL);
@ -383,7 +383,7 @@ HRESULT WINAPI D3DXAssembleShaderFromFileW(const WCHAR *filename, const D3DXMACR
if (FAILED(hr))
{
LeaveCriticalSection(&from_file_mutex);
HeapFree(GetProcessHeap(), 0, filename_a);
free(filename_a);
return D3DXERR_INVALIDDATA;
}
@ -391,7 +391,7 @@ HRESULT WINAPI D3DXAssembleShaderFromFileW(const WCHAR *filename, const D3DXMACR
ID3DXInclude_Close(include, buffer);
LeaveCriticalSection(&from_file_mutex);
HeapFree(GetProcessHeap(), 0, filename_a);
free(filename_a);
return hr;
}
@ -477,7 +477,7 @@ HRESULT WINAPI D3DXCompileShaderFromFileA(const char *filename, const D3DXMACRO
if (!filename) return D3DXERR_INVALIDDATA;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filename_w = malloc(len * sizeof(WCHAR));
if (!filename_w) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
@ -485,7 +485,7 @@ HRESULT WINAPI D3DXCompileShaderFromFileA(const char *filename, const D3DXMACRO
entrypoint, profile, flags,
shader, error_messages, constant_table);
HeapFree(GetProcessHeap(), 0, filename_w);
free(filename_w);
return ret;
}
@ -512,7 +512,7 @@ HRESULT WINAPI D3DXCompileShaderFromFileW(const WCHAR *filename, const D3DXMACRO
}
filename_len = WideCharToMultiByte(CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL);
filename_a = HeapAlloc(GetProcessHeap(), 0, filename_len * sizeof(char));
filename_a = malloc(filename_len * sizeof(char));
if (!filename_a)
return E_OUTOFMEMORY;
WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, filename_len, NULL, NULL);
@ -522,7 +522,7 @@ HRESULT WINAPI D3DXCompileShaderFromFileW(const WCHAR *filename, const D3DXMACRO
if (FAILED(hr))
{
LeaveCriticalSection(&from_file_mutex);
HeapFree(GetProcessHeap(), 0, filename_a);
free(filename_a);
return D3DXERR_INVALIDDATA;
}
@ -539,7 +539,7 @@ HRESULT WINAPI D3DXCompileShaderFromFileW(const WCHAR *filename, const D3DXMACRO
ID3DXInclude_Close(include, buffer);
LeaveCriticalSection(&from_file_mutex);
HeapFree(GetProcessHeap(), 0, filename_a);
free(filename_a);
return hr;
}
@ -609,13 +609,13 @@ HRESULT WINAPI D3DXPreprocessShaderFromFileA(const char *filename, const D3DXMAC
if (!filename) return D3DXERR_INVALIDDATA;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filename_w = malloc(len * sizeof(WCHAR));
if (!filename_w) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
ret = D3DXPreprocessShaderFromFileW(filename_w, defines, include, shader, error_messages);
HeapFree(GetProcessHeap(), 0, filename_w);
free(filename_w);
return ret;
}
@ -638,7 +638,7 @@ HRESULT WINAPI D3DXPreprocessShaderFromFileW(const WCHAR *filename, const D3DXMA
}
len = WideCharToMultiByte(CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL);
filename_a = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
filename_a = malloc(len * sizeof(char));
if (!filename_a)
return E_OUTOFMEMORY;
WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, len, NULL, NULL);
@ -648,7 +648,7 @@ HRESULT WINAPI D3DXPreprocessShaderFromFileW(const WCHAR *filename, const D3DXMA
if (FAILED(hr))
{
LeaveCriticalSection(&from_file_mutex);
HeapFree(GetProcessHeap(), 0, filename_a);
free(filename_a);
return D3DXERR_INVALIDDATA;
}
@ -659,7 +659,7 @@ HRESULT WINAPI D3DXPreprocessShaderFromFileW(const WCHAR *filename, const D3DXMA
ID3DXInclude_Close(include, buffer);
LeaveCriticalSection(&from_file_mutex);
HeapFree(GetProcessHeap(), 0, filename_a);
free(filename_a);
return hr;
}
@ -721,7 +721,7 @@ static void free_constant(struct ctab_constant *constant)
{
free_constant(&constant->constants[i]);
}
HeapFree(GetProcessHeap(), 0, constant->constants);
free(constant->constants);
}
}
@ -735,9 +735,9 @@ static void free_constant_table(struct ID3DXConstantTableImpl *table)
{
free_constant(&table->constants[i]);
}
HeapFree(GetProcessHeap(), 0, table->constants);
free(table->constants);
}
HeapFree(GetProcessHeap(), 0, table->ctab);
free(table->ctab);
}
static inline struct ID3DXConstantTableImpl *impl_from_ID3DXConstantTable(ID3DXConstantTable *iface)
@ -926,7 +926,7 @@ static ULONG WINAPI ID3DXConstantTableImpl_Release(ID3DXConstantTable *iface)
if (!refcount)
{
free_constant_table(table);
HeapFree(GetProcessHeap(), 0, table);
free(table);
}
return refcount;
@ -1875,7 +1875,7 @@ static HRESULT parse_ctab_constant_type(const char *ctab, DWORD typeoffset, stru
if (count)
{
constant->constants = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*constant->constants) * count);
constant->constants = calloc(count, sizeof(*constant->constants));
if (!constant->constants)
{
ERR("Out of memory\n");
@ -1967,7 +1967,7 @@ error:
{
free_constant(&constant->constants[i]);
}
HeapFree(GetProcessHeap(), 0, constant->constants);
free(constant->constants);
constant->constants = NULL;
}
@ -2024,18 +2024,18 @@ HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags,
return D3DXERR_INVALIDDATA;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
object->ID3DXConstantTable_iface.lpVtbl = &ID3DXConstantTable_Vtbl;
object->ref = 1;
object->ctab = HeapAlloc(GetProcessHeap(), 0, size);
object->ctab = malloc(size);
if (!object->ctab)
{
ERR("Out of memory\n");
HeapFree(GetProcessHeap(), 0, object);
free(object);
return E_OUTOFMEMORY;
}
object->size = size;
@ -2049,8 +2049,7 @@ HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags,
debugstr_a(object->desc.Creator), object->desc.Version, object->desc.Constants,
debugstr_a(ctab_header->Target ? object->ctab + ctab_header->Target : NULL));
object->constants = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*object->constants) * object->desc.Constants);
object->constants = calloc(object->desc.Constants, sizeof(*object->constants));
if (!object->constants)
{
ERR("Out of memory\n");
@ -2090,7 +2089,7 @@ HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags,
error:
free_constant_table(object);
HeapFree(GetProcessHeap(), 0, object);
free(object);
return hr;
}
@ -2153,7 +2152,7 @@ static ULONG WINAPI d3dx9_fragment_linker_Release(ID3DXFragmentLinker *iface)
if (!refcount)
{
IDirect3DDevice9_Release(linker->device);
heap_free(linker);
free(linker);
}
return refcount;
@ -2293,7 +2292,7 @@ HRESULT WINAPI D3DXCreateFragmentLinkerEx(IDirect3DDevice9 *device, UINT size, D
TRACE("device %p, size %u, flags %#lx, linker %p.\n", device, size, flags, linker);
object = heap_alloc(sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -2429,7 +2428,7 @@ static ULONG WINAPI d3dx9_texture_shader_Release(ID3DXTextureShader *iface)
ID3DXBuffer_Release(texture_shader->byte_code);
d3dx_free_param_eval(texture_shader->eval);
d3dx_parameters_store_cleanup(&texture_shader->parameters);
HeapFree(GetProcessHeap(), 0, texture_shader);
free(texture_shader);
}
return refcount;
@ -2659,7 +2658,7 @@ HRESULT WINAPI D3DXCreateTextureShader(const DWORD *function, ID3DXTextureShader
if (!(size = D3DXGetShaderSize(function)))
return D3DXERR_INVALIDDATA;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->ID3DXTextureShader_iface.lpVtbl = &d3dx9_texture_shader_vtbl;

View file

@ -88,12 +88,12 @@ static ULONG WINAPI d3dx9_skin_info_Release(ID3DXSkinInfo *iface)
for (i = 0; i < skin->num_bones; ++i)
{
HeapFree(GetProcessHeap(), 0, skin->bones[i].name);
HeapFree(GetProcessHeap(), 0, skin->bones[i].vertices);
HeapFree(GetProcessHeap(), 0, skin->bones[i].weights);
free(skin->bones[i].name);
free(skin->bones[i].vertices);
free(skin->bones[i].weights);
}
HeapFree(GetProcessHeap(), 0, skin->bones);
HeapFree(GetProcessHeap(), 0, skin);
free(skin->bones);
free(skin);
}
return refcount;
@ -114,12 +114,12 @@ static HRESULT WINAPI d3dx9_skin_info_SetBoneInfluence(ID3DXSkinInfo *iface,
return D3DERR_INVALIDCALL;
if (num_influences) {
new_vertices = HeapAlloc(GetProcessHeap(), 0, num_influences * sizeof(*vertices));
new_vertices = malloc(num_influences * sizeof(*vertices));
if (!new_vertices)
return E_OUTOFMEMORY;
new_weights = HeapAlloc(GetProcessHeap(), 0, num_influences * sizeof(*weights));
new_weights = malloc(num_influences * sizeof(*weights));
if (!new_weights) {
HeapFree(GetProcessHeap(), 0, new_vertices);
free(new_vertices);
return E_OUTOFMEMORY;
}
memcpy(new_vertices, vertices, num_influences * sizeof(*vertices));
@ -127,8 +127,8 @@ static HRESULT WINAPI d3dx9_skin_info_SetBoneInfluence(ID3DXSkinInfo *iface,
}
bone = &skin->bones[bone_num];
bone->num_influences = num_influences;
HeapFree(GetProcessHeap(), 0, bone->vertices);
HeapFree(GetProcessHeap(), 0, bone->weights);
free(bone->vertices);
free(bone->weights);
bone->vertices = new_vertices;
bone->weights = new_weights;
@ -240,19 +240,16 @@ static HRESULT WINAPI d3dx9_skin_info_SetBoneName(ID3DXSkinInfo *iface, DWORD bo
{
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
char *new_name;
size_t size;
TRACE("iface %p, bone_idx %lu, name %s.\n", iface, bone_idx, debugstr_a(name));
if (bone_idx >= skin->num_bones || !name)
return D3DERR_INVALIDCALL;
size = strlen(name) + 1;
new_name = HeapAlloc(GetProcessHeap(), 0, size);
new_name = strdup(name);
if (!new_name)
return E_OUTOFMEMORY;
memcpy(new_name, name, size);
HeapFree(GetProcessHeap(), 0, skin->bones[bone_idx].name);
free(skin->bones[bone_idx].name);
skin->bones[bone_idx].name = new_name;
return D3D_OK;
@ -476,7 +473,7 @@ HRESULT WINAPI D3DXCreateSkinInfo(DWORD vertex_count, const D3DVERTEXELEMENT9 *d
if (!skin_info || !declaration)
return D3DERR_INVALIDCALL;
object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -487,7 +484,7 @@ HRESULT WINAPI D3DXCreateSkinInfo(DWORD vertex_count, const D3DVERTEXELEMENT9 *d
object->vertex_declaration[0] = empty_declaration;
object->fvf = 0;
object->bones = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bone_count * sizeof(*object->bones));
object->bones = calloc(bone_count, sizeof(*object->bones));
if (!object->bones) {
hr = E_OUTOFMEMORY;
goto error;
@ -500,8 +497,8 @@ HRESULT WINAPI D3DXCreateSkinInfo(DWORD vertex_count, const D3DVERTEXELEMENT9 *d
return D3D_OK;
error:
HeapFree(GetProcessHeap(), 0, object->bones);
HeapFree(GetProcessHeap(), 0, object);
free(object->bones);
free(object);
return hr;
}

View file

@ -121,7 +121,7 @@ static ULONG WINAPI d3dx9_sprite_Release(ID3DXSprite *iface)
}
}
HeapFree(GetProcessHeap(), 0, sprite->sprites);
free(sprite->sprites);
}
if (sprite->stateblock)
@ -130,7 +130,7 @@ static ULONG WINAPI d3dx9_sprite_Release(ID3DXSprite *iface)
IDirect3DVertexDeclaration9_Release(sprite->vdecl);
if (sprite->device)
IDirect3DDevice9_Release(sprite->device);
HeapFree(GetProcessHeap(), 0, sprite);
free(sprite);
}
return refcount;
@ -344,6 +344,7 @@ static HRESULT WINAPI d3dx9_sprite_Draw(ID3DXSprite *iface, IDirect3DTexture9 *t
struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
struct sprite *new_sprites;
D3DSURFACE_DESC texdesc;
int new_size;
TRACE("iface %p, texture %p, rect %s, center %p, position %p, color 0x%08lx.\n",
iface, texture, wine_dbgstr_rect(rect), center, position, color);
@ -351,19 +352,14 @@ static HRESULT WINAPI d3dx9_sprite_Draw(ID3DXSprite *iface, IDirect3DTexture9 *t
if(texture==NULL) return D3DERR_INVALIDCALL;
if(!This->ready) return D3DERR_INVALIDCALL;
if (!This->allocated_sprites)
if (This->allocated_sprites <= This->sprite_count)
{
This->sprites = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 32 * sizeof(*This->sprites));
This->allocated_sprites = 32;
}
else if (This->allocated_sprites <= This->sprite_count)
{
new_sprites = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
This->sprites, This->allocated_sprites * 2 * sizeof(*This->sprites));
new_size = This->allocated_sprites ? This->allocated_sprites * 2 : 32;
new_sprites = realloc(This->sprites, new_size * sizeof(*This->sprites));
if (!new_sprites)
return E_OUTOFMEMORY;
This->sprites = new_sprites;
This->allocated_sprites *= 2;
This->allocated_sprites = new_size;
}
This->sprites[This->sprite_count].texture=texture;
if(!(This->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE))
@ -418,7 +414,7 @@ static HRESULT WINAPI d3dx9_sprite_Flush(ID3DXSprite *iface)
if(!This->sprite_count) return D3D_OK;
/* TODO: use of a vertex buffer here */
vertices = HeapAlloc(GetProcessHeap(), 0, sizeof(*vertices) * 6 * This->sprite_count);
vertices = malloc(sizeof(*vertices) * 6 * This->sprite_count);
for(start=0;start<This->sprite_count;start+=count,count=0) {
i=start;
@ -467,7 +463,7 @@ static HRESULT WINAPI d3dx9_sprite_Flush(ID3DXSprite *iface)
IDirect3DDevice9_DrawPrimitiveUP(This->device, D3DPT_TRIANGLELIST,
2 * count, vertices + 6 * start, sizeof(*vertices));
}
HeapFree(GetProcessHeap(), 0, vertices);
free(vertices);
if(!(This->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE))
for(i=0;i<This->sprite_count;i++)
@ -571,7 +567,7 @@ HRESULT WINAPI D3DXCreateSprite(struct IDirect3DDevice9 *device, struct ID3DXSpr
if(device==NULL || sprite==NULL) return D3DERR_INVALIDCALL;
if (!(object=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
{
*sprite = NULL;
return E_OUTOFMEMORY;

View file

@ -869,7 +869,7 @@ static BOOL convert_dib_to_bmp(const void **data, unsigned int *size)
TRACE("Converting DIB file to BMP\n");
new_size = *size + sizeof(BITMAPFILEHEADER);
new_data = HeapAlloc(GetProcessHeap(), 0, new_size);
new_data = malloc(new_size);
CopyMemory(new_data + sizeof(BITMAPFILEHEADER), *data, *size);
/* Add BMP header */
@ -1058,7 +1058,7 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
IWICBitmapDecoder_Release(decoder);
if (dib)
HeapFree(GetProcessHeap(), 0, (void*)data);
free((void*)data);
if (FAILED(hr)) {
TRACE("Invalid or unsupported image file\n");
@ -1090,11 +1090,11 @@ HRESULT WINAPI D3DXGetImageInfoFromFileA(const char *file, D3DXIMAGE_INFO *info)
if( !file ) return D3DERR_INVALIDCALL;
strlength = MultiByteToWideChar(CP_ACP, 0, file, -1, NULL, 0);
widename = HeapAlloc(GetProcessHeap(), 0, strlength * sizeof(*widename));
widename = malloc(strlength * sizeof(*widename));
MultiByteToWideChar(CP_ACP, 0, file, -1, widename, strlength);
hr = D3DXGetImageInfoFromFileW(widename, info);
HeapFree(GetProcessHeap(), 0, widename);
free(widename);
return hr;
}
@ -1286,7 +1286,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
WICColor *colors = NULL;
pitch = formatdesc->bytes_per_pixel * wicrect.Width;
buffer = HeapAlloc(GetProcessHeap(), 0, pitch * wicrect.Height);
buffer = malloc(pitch * wicrect.Height);
hr = IWICBitmapFrameDecode_CopyPixels(bitmapframe, &wicrect, pitch,
pitch * wicrect.Height, buffer);
@ -1303,8 +1303,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
hr = IWICPalette_GetColorCount(wic_palette, &nb_colors);
if (SUCCEEDED(hr))
{
colors = HeapAlloc(GetProcessHeap(), 0, nb_colors * sizeof(colors[0]));
palette = HeapAlloc(GetProcessHeap(), 0, nb_colors * sizeof(palette[0]));
colors = malloc(nb_colors * sizeof(colors[0]));
palette = malloc(nb_colors * sizeof(palette[0]));
if (!colors || !palette)
hr = E_OUTOFMEMORY;
}
@ -1334,9 +1334,9 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
palette, &rect, dwFilter, Colorkey);
}
HeapFree(GetProcessHeap(), 0, colors);
HeapFree(GetProcessHeap(), 0, palette);
HeapFree(GetProcessHeap(), 0, buffer);
free(colors);
free(palette);
free(buffer);
}
IWICBitmapFrameDecode_Release(bitmapframe);
@ -1349,7 +1349,7 @@ cleanup_err:
IWICImagingFactory_Release(factory);
if (imginfo.ImageFileFormat == D3DXIFF_DIB)
HeapFree(GetProcessHeap(), 0, (void*)pSrcData);
free((void*)pSrcData);
if (FAILED(hr))
return D3DXERR_INVALIDDATA;
@ -1377,12 +1377,12 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileA(IDirect3DSurface9 *dst_surface,
return D3DERR_INVALIDCALL;
strlength = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0);
src_file_w = HeapAlloc(GetProcessHeap(), 0, strlength * sizeof(*src_file_w));
src_file_w = malloc(strlength * sizeof(*src_file_w));
MultiByteToWideChar(CP_ACP, 0, src_file, -1, src_file_w, strlength);
hr = D3DXLoadSurfaceFromFileW(dst_surface, dst_palette, dst_rect,
src_file_w, src_rect, filter, color_key, src_info);
HeapFree(GetProcessHeap(), 0, src_file_w);
free(src_file_w);
return hr;
}
@ -2040,7 +2040,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
src_pitch = src_pitch * srcformatdesc->block_width / srcformatdesc->block_byte_count;
src_uncompressed = heap_alloc(src_size.width * src_size.height * sizeof(DWORD));
src_uncompressed = malloc(src_size.width * src_size.height * sizeof(DWORD));
if (!src_uncompressed)
{
unlock_surface(dst_surface, &dst_rect_aligned, surface, FALSE);
@ -2086,15 +2086,16 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
|| dst_rect->top != dst_rect_aligned.top
|| dst_rect->right != dst_rect_aligned.right
|| dst_rect->bottom != dst_rect_aligned.bottom;
size_t dst_uncompressed_size = dst_size_aligned.width * dst_size_aligned.height * sizeof(DWORD);
dst_uncompressed = HeapAlloc(GetProcessHeap(), dst_misaligned ? HEAP_ZERO_MEMORY : 0,
dst_size_aligned.width * dst_size_aligned.height * sizeof(DWORD));
dst_uncompressed = malloc(dst_uncompressed_size);
if (!dst_uncompressed)
{
heap_free(src_uncompressed);
free(src_uncompressed);
unlock_surface(dst_surface, &dst_rect_aligned, surface, FALSE);
return E_OUTOFMEMORY;
}
if (dst_misaligned) memset(dst_uncompressed, 0, dst_uncompressed_size);
dst_pitch = dst_size_aligned.width * sizeof(DWORD);
dst_format = get_format_info(D3DFMT_A8B8G8R8);
dst_mem = dst_uncompressed + (dst_rect->top - dst_rect_aligned.top) * dst_pitch
@ -2123,7 +2124,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
dst_mem, dst_pitch, 0, &dst_size, dst_format, color_key, src_palette);
}
heap_free(src_uncompressed);
free(src_uncompressed);
if (dst_uncompressed)
{
@ -2149,7 +2150,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
tx_compress_dxtn(4, dst_size_aligned.width, dst_size_aligned.height,
dst_uncompressed, gl_format, lockrect.pBits,
lockrect.Pitch);
heap_free(dst_uncompressed);
free(dst_uncompressed);
}
}
@ -2323,7 +2324,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileA(const char *dst_filename, D3DXIMAGE_FILEFO
if (!dst_filename) return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, NULL, 0);
filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filename = malloc(len * sizeof(WCHAR));
if (!filename) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, filename, len);
@ -2334,7 +2335,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileA(const char *dst_filename, D3DXIMAGE_FILEFO
ID3DXBuffer_Release(buffer);
}
HeapFree(GetProcessHeap(), 0, filename);
free(filename);
return hr;
}
@ -2507,7 +2508,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
size.height = height;
size.depth = 1;
dst_pitch = width * dst_format_desc->bytes_per_pixel;
dst_data = HeapAlloc(GetProcessHeap(), 0, dst_pitch * height);
dst_data = malloc(dst_pitch * height);
if (!dst_data)
{
hr = E_OUTOFMEMORY;
@ -2515,7 +2516,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
}
if (FAILED(hr = lock_surface(src_surface, src_rect, &locked_rect, &temp_surface, FALSE)))
{
HeapFree(GetProcessHeap(), 0, dst_data);
free(dst_data);
goto cleanup;
}
convert_argb_pixels(locked_rect.pBits, locked_rect.Pitch, 0, &size, src_format_desc,
@ -2523,7 +2524,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
unlock_surface(src_surface, src_rect, temp_surface, FALSE);
IWICBitmapFrameEncode_WritePixels(frame, height, dst_pitch, dst_pitch * height, dst_data);
HeapFree(GetProcessHeap(), 0, dst_data);
free(dst_data);
}
hr = IWICBitmapFrameEncode_Commit(frame);

View file

@ -801,14 +801,14 @@ HRESULT WINAPI D3DXCreateTextureFromFileExA(struct IDirect3DDevice9 *device, con
return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
widename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*widename));
widename = malloc(len * sizeof(*widename));
MultiByteToWideChar(CP_ACP, 0, srcfile, -1, widename, len);
hr = D3DXCreateTextureFromFileExW(device, widename, width, height, miplevels,
usage, format, pool, filter, mipfilter,
colorkey, srcinfo, palette, texture);
HeapFree(GetProcessHeap(), 0, widename);
free(widename);
return hr;
}
@ -981,12 +981,12 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileA(IDirect3DDevice9 *device,
if (!filename) return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
filenameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filenameW = malloc(len * sizeof(WCHAR));
if (!filenameW) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, len);
hr = map_view_of_file(filenameW, &data, &data_size);
HeapFree(GetProcessHeap(), 0, filenameW);
free(filenameW);
if (FAILED(hr)) return D3DXERR_INVALIDDATA;
hr = D3DXCreateVolumeTextureFromFileInMemoryEx(device, data, data_size, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
@ -1049,12 +1049,12 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileExA(IDirect3DDevice9 *device,
if (!filename) return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
filenameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filenameW = malloc(len * sizeof(WCHAR));
if (!filenameW) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, len);
hr = map_view_of_file(filenameW, &data, &data_size);
HeapFree(GetProcessHeap(), 0, filenameW);
free(filenameW);
if (FAILED(hr)) return D3DXERR_INVALIDDATA;
hr = D3DXCreateVolumeTextureFromFileInMemoryEx(device, data, data_size, width, height, depth,
@ -1520,14 +1520,14 @@ HRESULT WINAPI D3DXCreateCubeTextureFromFileA(IDirect3DDevice9 *device,
if (!src_filename) return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, src_filename, -1, NULL, 0);
filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filename = malloc(len * sizeof(WCHAR));
if (!filename) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, src_filename, -1, filename, len);
hr = map_view_of_file(filename, &data, &data_size);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, filename);
free(filename);
return D3DXERR_INVALIDDATA;
}
@ -1535,7 +1535,7 @@ HRESULT WINAPI D3DXCreateCubeTextureFromFileA(IDirect3DDevice9 *device,
0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, cube_texture);
UnmapViewOfFile(data);
HeapFree(GetProcessHeap(), 0, filename);
free(filename);
return hr;
}
@ -1578,14 +1578,14 @@ HRESULT WINAPI D3DXCreateCubeTextureFromFileExA(IDirect3DDevice9 *device, const
if (!src_filename) return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, src_filename, -1, NULL, 0);
filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filename = malloc(len * sizeof(WCHAR));
if (!filename) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, src_filename, -1, filename, len);
hr = map_view_of_file(filename, &data, &data_size);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, filename);
free(filename);
return D3DXERR_INVALIDDATA;
}
@ -1593,7 +1593,7 @@ HRESULT WINAPI D3DXCreateCubeTextureFromFileExA(IDirect3DDevice9 *device, const
usage, format, pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
UnmapViewOfFile(data);
HeapFree(GetProcessHeap(), 0, filename);
free(filename);
return hr;
}
@ -1809,7 +1809,7 @@ HRESULT WINAPI D3DXSaveTextureToFileA(const char *dst_filename, D3DXIMAGE_FILEFO
if (!dst_filename) return D3DERR_INVALIDCALL;
len = MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, NULL, 0);
filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
filename = malloc(len * sizeof(WCHAR));
if (!filename) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, filename, len);
@ -1820,7 +1820,7 @@ HRESULT WINAPI D3DXSaveTextureToFileA(const char *dst_filename, D3DXIMAGE_FILEFO
ID3DXBuffer_Release(buffer);
}
HeapFree(GetProcessHeap(), 0, filename);
free(filename);
return hr;
}

View file

@ -36,13 +36,13 @@ HRESULT WINAPI D3DXLoadVolumeFromFileA(IDirect3DVolume9 *dst_volume, const PALET
if (!dst_volume || !filename) return D3DERR_INVALIDCALL;
length = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
filenameW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(*filenameW));
filenameW = malloc(length * sizeof(*filenameW));
if (!filenameW) return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, length);
hr = D3DXLoadVolumeFromFileW(dst_volume, dst_palette, dst_box, filenameW,
src_box, filter, color_key, info);
HeapFree(GetProcessHeap(), 0, filenameW);
free(filenameW);
return hr;
}

View file

@ -129,9 +129,9 @@ static ULONG WINAPI d3dx9_file_data_Release(ID3DXFileData *iface)
ID3DXFileData *child = file_data->children[i];
child->lpVtbl->Release(child);
}
HeapFree(GetProcessHeap(), 0, file_data->children);
free(file_data->children);
IDirectXFileData_Release(file_data->dxfile_data);
HeapFree(GetProcessHeap(), 0, file_data);
free(file_data);
}
return refcount;
@ -303,7 +303,7 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
*ret_iface = NULL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -322,7 +322,7 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
IUnknown_Release(reference);
if (FAILED(ret))
{
HeapFree(GetProcessHeap(), 0, object);
free(object);
return E_FAIL;
}
object->reference = TRUE;
@ -330,7 +330,7 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
else
{
FIXME("Don't know what to do with binary object\n");
HeapFree(GetProcessHeap(), 0, object);
free(object);
return E_FAIL;
}
}
@ -341,17 +341,8 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
{
ID3DXFileData **new_children;
if (object->children)
{
children_array_size *= 2;
new_children = HeapReAlloc(GetProcessHeap(), 0, object->children,
sizeof(*object->children) * children_array_size);
}
else
{
children_array_size = 4;
new_children = HeapAlloc(GetProcessHeap(), 0, sizeof(*object->children) * children_array_size);
}
children_array_size = object->children ? children_array_size * 2 : 4;
new_children = realloc(object->children, sizeof(*object->children) * children_array_size);
if (!new_children)
{
ret = E_OUTOFMEMORY;
@ -374,8 +365,7 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
{
ID3DXFileData **new_children;
new_children = HeapReAlloc(GetProcessHeap(), 0, object->children,
sizeof(*object->children) * object->child_count);
new_children = realloc(object->children, sizeof(*object->children) * object->child_count);
if (new_children)
object->children = new_children;
}
@ -431,8 +421,8 @@ static ULONG WINAPI d3dx9_file_enum_object_Release(ID3DXFileEnumObject *iface)
ID3DXFileData *child = file_enum->children[i];
child->lpVtbl->Release(child);
}
HeapFree(GetProcessHeap(), 0, file_enum->children);
HeapFree(GetProcessHeap(), 0, file_enum);
free(file_enum->children);
free(file_enum);
}
return refcount;
@ -540,7 +530,7 @@ static ULONG WINAPI d3dx9_file_Release(ID3DXFile *iface)
if (!refcount)
{
IDirectXFile_Release(file->dxfile);
HeapFree(GetProcessHeap(), 0, file);
free(file);
}
return refcount;
@ -597,7 +587,7 @@ static HRESULT WINAPI d3dx9_file_CreateEnumObject(ID3DXFile *iface, const void *
return E_NOTIMPL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -608,7 +598,7 @@ static HRESULT WINAPI d3dx9_file_CreateEnumObject(ID3DXFile *iface, const void *
if (ret != S_OK)
{
HeapFree(GetProcessHeap(), 0, object);
free(object);
return ret;
}
@ -619,17 +609,8 @@ static HRESULT WINAPI d3dx9_file_CreateEnumObject(ID3DXFile *iface, const void *
{
ID3DXFileData **new_children;
if (object->children)
{
children_array_size *= 2;
new_children = HeapReAlloc(GetProcessHeap(), 0, object->children,
sizeof(*object->children) * children_array_size);
}
else
{
children_array_size = 4;
new_children = HeapAlloc(GetProcessHeap(), 0, sizeof(*object->children) * children_array_size);
}
children_array_size = object->children ? children_array_size * 2 : 4;
new_children = realloc(object->children, sizeof(*object->children) * children_array_size);
if (!new_children)
{
ret = E_OUTOFMEMORY;
@ -648,8 +629,7 @@ static HRESULT WINAPI d3dx9_file_CreateEnumObject(ID3DXFile *iface, const void *
{
ID3DXFileData **new_children;
new_children = HeapReAlloc(GetProcessHeap(), 0, object->children,
sizeof(*object->children) * object->child_count);
new_children = realloc(object->children, sizeof(*object->children) * object->child_count);
if (new_children)
object->children = new_children;
}
@ -722,14 +702,14 @@ HRESULT WINAPI D3DXFileCreate(ID3DXFile **d3dxfile)
*d3dxfile = NULL;
object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
ret = DirectXFileCreate(&object->dxfile);
if (ret != S_OK)
{
HeapFree(GetProcessHeap(), 0, object);
free(object);
if (ret == E_OUTOFMEMORY)
return ret;
return E_FAIL;