summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-04-24 21:16:37 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-04-24 21:16:37 -0700
commit3427eefac9cf38ac3fa2635c69bb3f0693700cf8 (patch)
treeb078abaf3bb0841b89df3e26319035ff01cd0604 /src
parent2bcc2ca1ed6b7e1fa075770bcb306a3fdff917af (diff)
*: free setup allocations via til_setup_free()
This should plug a bulk of the setup leaks. Some of the free_funcs still need to be changed to bespoke ones in modules that allocate nested things in their respective setup, so those are still leaking the nested things which are usually just a small strdup of some kind.
Diffstat (limited to 'src')
-rw-r--r--src/modules/compose/compose.c18
-rw-r--r--src/modules/montage/montage.c7
-rw-r--r--src/modules/rtv/rtv.c13
3 files changed, 24 insertions, 14 deletions
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c
index 0fa1204..110bb63 100644
--- a/src/modules/compose/compose.c
+++ b/src/modules/compose/compose.c
@@ -87,8 +87,7 @@ static void * compose_create_context(unsigned ticks, unsigned num_cpus, til_setu
ctxt->layers[i].module = layer_module;
(void) til_module_create_context(layer_module, ticks, layer_setup, &ctxt->layers[i].module_ctxt);
-
- /* TODO FIXME: free setup! */
+ til_setup_free(layer_setup);
ctxt->n_layers++;
}
@@ -167,20 +166,29 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set
* going to let the user potentially compose with montage
* or rtv as one of the layers.
*/
- if (!strcmp(layer, "compose")) /* XXX: prevent infinite recursion */
+ if (!strcmp(layer, "compose")) { /* XXX: prevent infinite recursion */
+ til_setup_free(&setup->til_setup);
+
return -EINVAL;
+ }
for (i = 0; i < n_modules; i++) {
if (!strcmp(layer, modules[i]->name))
break;
}
- if (i >= n_modules)
+ if (i >= n_modules) {
+ til_setup_free(&setup->til_setup);
+
return -EINVAL;
+ }
new = realloc(setup, sizeof(*setup) + n * sizeof(*setup->layers));
- if (!new)
+ if (!new) {
+ til_setup_free(&setup->til_setup);
+
return -ENOMEM;
+ }
new->layers[n - 2] = layer;
new->layers[n - 1] = NULL;
diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c
index 268d7db..13c8a36 100644
--- a/src/modules/montage/montage.c
+++ b/src/modules/montage/montage.c
@@ -95,12 +95,7 @@ static void * montage_create_context(unsigned ticks, unsigned num_cpus, til_setu
if (module->create_context) /* FIXME errors */
ctxt->contexts[i] = module->create_context(ticks, 1, setup);
- /* TODO FIXME: free setup! modules don't currently implement it.
- * What should probably happen is the setup should become a til struct
- * type having just a free function pointer. Then module setups would
- * simply embed this at the start of their private setup struct and return a
- * pointer to that as their setup.
- */
+ til_setup_free(setup);
}
return ctxt;
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index 06dfd90..08f4b8a 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -409,8 +409,11 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting
til_get_modules(&modules, &n_modules);
tokchannels = strdup(channels);
- if (!tokchannels)
+ if (!tokchannels) {
+ til_setup_free(&setup->til_setup);
+
return -ENOMEM;
+ }
channel = strtok(tokchannels, ":");
do {
@@ -422,12 +425,16 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting
break;
}
- if (i >= n_modules)
+ if (i >= n_modules) {
+ til_setup_free(&setup->til_setup);
+
return -EINVAL;
+ }
new = realloc(setup, sizeof(*setup) + n * sizeof(setup->channels[0]));
if (!new) {
- free(setup);
+ til_setup_free(&setup->til_setup);
+
return -ENOMEM;
}
© All Rights Reserved