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 --- 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 0aca7830e..2bdc6bd15 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 8dc77673b..3bfbf48df 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;