Commit 07562f1e authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

d3dx9: Factor out free_parameter_object_data() function.

parent 4020a382
......@@ -542,16 +542,21 @@ static void free_sampler(struct d3dx_sampler *sampler)
static void d3dx_pool_release_shared_parameter(struct d3dx_top_level_parameter *param);
static void free_parameter_data(struct d3dx_parameter *param, BOOL child)
static void free_parameter_object_data(struct d3dx_parameter *param, const void *data, unsigned int bytes)
{
if (!param->data)
unsigned int i, count;
if (param->class != D3DXPC_OBJECT)
return;
if (param->class == D3DXPC_OBJECT && !param->element_count)
count = min(param->element_count ? param->element_count : 1, bytes / sizeof(void *));
for (i = 0; i < count; ++i)
{
switch (param->type)
{
case D3DXPT_STRING:
heap_free(*(char **)param->data);
heap_free(((char **)data)[i]);
break;
case D3DXPT_TEXTURE:
......@@ -561,7 +566,8 @@ static void free_parameter_data(struct d3dx_parameter *param, BOOL child)
case D3DXPT_TEXTURECUBE:
case D3DXPT_PIXELSHADER:
case D3DXPT_VERTEXSHADER:
if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
if (*(IUnknown **)data)
IUnknown_Release(((IUnknown **)data)[i]);
break;
case D3DXPT_SAMPLER:
......@@ -569,7 +575,8 @@ static void free_parameter_data(struct d3dx_parameter *param, BOOL child)
case D3DXPT_SAMPLER2D:
case D3DXPT_SAMPLER3D:
case D3DXPT_SAMPLERCUBE:
free_sampler((struct d3dx_sampler *)param->data);
assert(count == 1);
free_sampler((struct d3dx_sampler *)data);
return;
default:
......@@ -577,6 +584,16 @@ static void free_parameter_data(struct d3dx_parameter *param, BOOL child)
break;
}
}
}
static void free_parameter_data(struct d3dx_parameter *param, BOOL child)
{
if (!param->data)
return;
if (!param->element_count)
free_parameter_object_data(param, param->data, param->bytes);
if (!child || is_param_type_sampler(param->type))
heap_free(param->data);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment