From 6aa77bc0efc27d976f2d478ca54fa59a7c47e934 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 28 May 2023 18:38:52 -0700 Subject: til_setup,*: note settings path in til_setup_t This commit adds passing the settings instance to til_setup_new() which is used for deriving a path for the setup via til_settings_print_path() on the supplied settings. That path gets an allocated copy left in the returned til_setup_t at til_setup_t.path This path will exist for the lifetime of the til_setup_t, to be freed along with the rest of the baked setup instance when the refcount reaches 0. The incoming til_settings_t is only read @ til_setup_new() in constructing the path, no reference is kept. Basically the til_settings_t* is just passed in for convenience reasons, since constructing the path needs memory and may fail, this approach lets the existing til_setup_new() call error handling also capture the path allocation failures as-is turning til_setup_new() into a bit more of a convenience helper. Note that now all code may assume a til_setup_t has a set and valid til_setup_t.path, which should be useful for context creates when a setup is available. --- src/modules/blinds/blinds.c | 2 +- src/modules/checkers/checkers.c | 2 +- src/modules/compose/compose.c | 2 +- src/modules/drizzle/drizzle.c | 2 +- src/modules/flui2d/flui2d.c | 2 +- src/modules/moire/moire.c | 2 +- src/modules/pixbounce/pixbounce.c | 2 +- src/modules/plato/plato.c | 2 +- src/modules/rkt/rkt.c | 2 +- src/modules/rtv/rtv.c | 2 +- src/modules/shapes/shapes.c | 2 +- src/modules/sparkler/sparkler.c | 2 +- src/modules/stars/stars.c | 2 +- src/modules/strobe/strobe.c | 2 +- src/modules/submit/submit.c | 2 +- src/modules/swarm/swarm.c | 2 +- src/modules/voronoi/voronoi.c | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/modules') diff --git a/src/modules/blinds/blinds.c b/src/modules/blinds/blinds.c index ecfa2d5..39b439f 100644 --- a/src/modules/blinds/blinds.c +++ b/src/modules/blinds/blinds.c @@ -175,7 +175,7 @@ static int blinds_setup(const til_settings_t *settings, til_setting_t **res_sett if (res_setup) { blinds_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c index f13727e..3bd4dda 100644 --- a/src/modules/checkers/checkers.c +++ b/src/modules/checkers/checkers.c @@ -670,7 +670,7 @@ static int checkers_setup(const til_settings_t *settings, til_setting_t **res_se if (res_setup) { checkers_setup_t *setup; - setup = til_setup_new(sizeof(*setup), checkers_setup_free); + setup = til_setup_new(settings, sizeof(*setup), checkers_setup_free); if (!setup) return -ENOMEM; diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c index 600193c..4f0a8c8 100644 --- a/src/modules/compose/compose.c +++ b/src/modules/compose/compose.c @@ -454,7 +454,7 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set til_setting_t *layer_setting; compose_setup_t *setup; - setup = til_setup_new(sizeof(*setup) + n_layers * sizeof(*setup->layers), compose_setup_free); + setup = til_setup_new(settings, sizeof(*setup) + n_layers * sizeof(*setup->layers), compose_setup_free); if (!setup) return -ENOMEM; diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c index 3485cc1..844a19a 100644 --- a/src/modules/drizzle/drizzle.c +++ b/src/modules/drizzle/drizzle.c @@ -402,7 +402,7 @@ static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_set drizzle_setup_t *setup; int i; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c index ba95023..41baaac 100644 --- a/src/modules/flui2d/flui2d.c +++ b/src/modules/flui2d/flui2d.c @@ -523,7 +523,7 @@ static int flui2d_setup(const til_settings_t *settings, til_setting_t **res_sett if (res_setup) { flui2d_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/moire/moire.c b/src/modules/moire/moire.c index 8616f3b..e75a5df 100644 --- a/src/modules/moire/moire.c +++ b/src/modules/moire/moire.c @@ -142,7 +142,7 @@ static int moire_setup(const til_settings_t *settings, til_setting_t **res_setti if (res_setup) { moire_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c index 80857f7..4589b60 100644 --- a/src/modules/pixbounce/pixbounce.c +++ b/src/modules/pixbounce/pixbounce.c @@ -374,7 +374,7 @@ int pixbounce_setup(const til_settings_t *settings, til_setting_t **res_setting, if (res_setup) { pixbounce_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c index f8a3483..52e653a 100644 --- a/src/modules/plato/plato.c +++ b/src/modules/plato/plato.c @@ -744,7 +744,7 @@ static int plato_setup(const til_settings_t *settings, til_setting_t **res_setti plato_setup_t *setup; int i; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c index d274391..6bd4ddd 100644 --- a/src/modules/rkt/rkt.c +++ b/src/modules/rkt/rkt.c @@ -391,7 +391,7 @@ static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting return -ENOENT; /* TODO: we're going to need a custom setup_free to cleanup host+base etc. */ - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index 29d1e71..389a0f5 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -492,7 +492,7 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting rtv_setup_t *setup; /* FIXME: rtv_setup_t.snow_module needs freeing, so we need a bespoke free_func */ - setup = til_setup_new(sizeof(*setup) + sizeof(setup->channels[0]), NULL); + setup = til_setup_new(settings, sizeof(*setup) + sizeof(setup->channels[0]), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/shapes/shapes.c b/src/modules/shapes/shapes.c index c3b0ef4..ab836a0 100644 --- a/src/modules/shapes/shapes.c +++ b/src/modules/shapes/shapes.c @@ -455,7 +455,7 @@ static int shapes_setup(const til_settings_t *settings, til_setting_t **res_sett shapes_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c index 6105112..b6ffd01 100644 --- a/src/modules/sparkler/sparkler.c +++ b/src/modules/sparkler/sparkler.c @@ -184,7 +184,7 @@ static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_se if (res_setup) { sparkler_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c index 68e0335..6d5f3c0 100644 --- a/src/modules/stars/stars.c +++ b/src/modules/stars/stars.c @@ -276,7 +276,7 @@ int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, con if (res_setup) { stars_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/strobe/strobe.c b/src/modules/strobe/strobe.c index cd3ba94..9f6b04a 100644 --- a/src/modules/strobe/strobe.c +++ b/src/modules/strobe/strobe.c @@ -123,7 +123,7 @@ static int strobe_setup(const til_settings_t *settings, til_setting_t **res_sett if (res_setup) { strobe_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c index 24e7315..c50b67c 100644 --- a/src/modules/submit/submit.c +++ b/src/modules/submit/submit.c @@ -352,7 +352,7 @@ static int submit_setup(const til_settings_t *settings, til_setting_t **res_sett if (res_setup) { submit_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c index 96b7e1c..4a21260 100644 --- a/src/modules/swarm/swarm.c +++ b/src/modules/swarm/swarm.c @@ -439,7 +439,7 @@ static int swarm_setup(const til_settings_t *settings, til_setting_t **res_setti if (res_setup) { swarm_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; diff --git a/src/modules/voronoi/voronoi.c b/src/modules/voronoi/voronoi.c index 23ea00a..45333b0 100644 --- a/src/modules/voronoi/voronoi.c +++ b/src/modules/voronoi/voronoi.c @@ -403,7 +403,7 @@ static int voronoi_setup(const til_settings_t *settings, til_setting_t **res_set if (res_setup) { voronoi_setup_t *setup; - setup = til_setup_new(sizeof(*setup), NULL); + setup = til_setup_new(settings, sizeof(*setup), NULL); if (!setup) return -ENOMEM; -- cgit v1.2.3