diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-08-30 17:26:56 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-08-30 17:26:56 -0700 |
commit | c91c9e5eeae06a7cbed94354d62c1281dc356407 (patch) | |
tree | a589ab8716cba804ec7c60e5882a2eec7f0033b7 /src/modules/stars | |
parent | 20d097ab1fe8ef5b62f4169f4353cc0074c27e4b (diff) |
modules/*: til_module_context_free() error paths
Several modules still had vestigial ad-hoc free() cleanups on
error paths in their create_context().
Largely mechanical change of replacing those with
til_module_context_free() which is more appropriate, since the
til_module_context_t holds a reference on the setup. A plain
free() will leak that reference.
But it's only on create_context() failures which are uncommon,
so this was in practice mostly harmless...
Diffstat (limited to 'src/modules/stars')
-rw-r--r-- | src/modules/stars/stars.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c index bff3d8f..ef35c4e 100644 --- a/src/modules/stars/stars.c +++ b/src/modules/stars/stars.c @@ -123,7 +123,8 @@ static til_module_context_t * stars_create_context(const til_module_t *module, t for(int i=0; i<rand_r(&ctxt->seed)%16; i++){ p_ptr = malloc(sizeof(struct points)); if (!p_ptr) - return NULL; + return til_module_context_free(&ctxt->til_module_context); + p_ptr->x = get_random_unit_coord(&ctxt->seed); p_ptr->y = get_random_unit_coord(&ctxt->seed); p_ptr->z = z; |