From e208d87847e1d3e426a1a69755e8e0c6aaccc3c8 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 11 Apr 2022 12:18:29 -0500 Subject: [PATCH] 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 Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- tests/shader_runner.c | 5 +++-- tests/shader_runner.h | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 0aca7830..2bdc6bd1 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -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; } @@ -846,7 +848,6 @@ out: if (runner->resources[i]) runner->ops->destroy_resource(runner, runner->resources[i]); } - free(runner->resources); fclose(f); diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 8dc77673..3bfbf48d 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -87,6 +87,8 @@ struct input_element unsigned int index; }; +#define MAX_RESOURCES 32 + struct shader_runner { const struct shader_runner_ops *ops; @@ -98,7 +100,7 @@ struct shader_runner uint32_t *uniforms; size_t uniform_count, uniform_capacity; - struct resource **resources; + struct resource *resources[MAX_RESOURCES]; size_t resource_count; struct sampler *samplers;