From 5e647dee95763d8f628bdc771a32c5d33c51d78a Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 19 Jan 2023 21:00:40 -0800 Subject: til: pass module to .context_create()/til_module_context_new() Let's make it so til_module_context_t as returned from til_module_context_new() can immediately be freed via til_module_context_free(). Previously it was only after the context propagated out to til_module_context_create() that it could be freed that way, as that was where the module member was being assigned. With this change, and wiring up the module pointer into til_module_t.create_context() as well for convenient providing to til_module_context_new(), til_module_t.create_context() error paths can easily cleanup via `return til_module_context_free()` But this does require the til_module_t.destroy_context() be able to safely handle partially constructed contexts, since the mid-create failure freeing won't necessarily have all the members initialized. There will probably be some NULL derefs to fix up, but at least the contexts are zero-initialized @ new. --- src/modules/montage/montage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules/montage') diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c index 9315e79..2d4314a 100644 --- a/src/modules/montage/montage.c +++ b/src/modules/montage/montage.c @@ -16,7 +16,7 @@ typedef struct montage_context_t { size_t n_modules; } montage_context_t; -static til_module_context_t * montage_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup); +static til_module_context_t * montage_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup); static void montage_destroy_context(til_module_context_t *context); static void montage_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan); static void montage_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr); @@ -32,13 +32,13 @@ til_module_t montage_module = { }; -static til_module_context_t * montage_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) +static til_module_context_t * montage_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) { const til_module_t **modules, *rtv_module, *compose_module; size_t n_modules; montage_context_t *ctxt; - ctxt = til_module_context_new(stream, sizeof(montage_context_t), seed, ticks, n_cpus, path); + ctxt = til_module_context_new(module, sizeof(montage_context_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; -- cgit v1.2.1