tests: Store resources in a fixed-size array.

We will need to allocate some structures in the Vulkan backend; this is easier
if we don't need to worry about allocating them dynamically.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2022-04-11 12:18:29 -05:00 committed by Alexandre Julliard
parent 02182ce4f7
commit e208d87847
2 changed files with 6 additions and 3 deletions

View File

@ -327,7 +327,9 @@ static void set_resource(struct shader_runner *runner, struct resource *resource
} }
} }
runner->resources = realloc(runner->resources, (runner->resource_count + 1) * sizeof(*runner->resources)); if (runner->resource_count == MAX_RESOURCES)
fatal_error("Too many resources declared.\n");
runner->resources[runner->resource_count++] = resource; runner->resources[runner->resource_count++] = resource;
} }
@ -846,7 +848,6 @@ out:
if (runner->resources[i]) if (runner->resources[i])
runner->ops->destroy_resource(runner, runner->resources[i]); runner->ops->destroy_resource(runner, runner->resources[i]);
} }
free(runner->resources);
fclose(f); fclose(f);

View File

@ -87,6 +87,8 @@ struct input_element
unsigned int index; unsigned int index;
}; };
#define MAX_RESOURCES 32
struct shader_runner struct shader_runner
{ {
const struct shader_runner_ops *ops; const struct shader_runner_ops *ops;
@ -98,7 +100,7 @@ struct shader_runner
uint32_t *uniforms; uint32_t *uniforms;
size_t uniform_count, uniform_capacity; size_t uniform_count, uniform_capacity;
struct resource **resources; struct resource *resources[MAX_RESOURCES];
size_t resource_count; size_t resource_count;
struct sampler *samplers; struct sampler *samplers;