summaryrefslogtreecommitdiff
path: root/src/til_setup.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-05-28 18:38:52 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-05-28 18:38:52 -0700
commit6aa77bc0efc27d976f2d478ca54fa59a7c47e934 (patch)
treef59d6dc330014a747da94aa2f4d34618e8d6310d /src/til_setup.h
parentfc476199681664f4498babba674c209147fc041c (diff)
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.
Diffstat (limited to 'src/til_setup.h')
-rw-r--r--src/til_setup.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/til_setup.h b/src/til_setup.h
index 8cc7a88..2d0facb 100644
--- a/src/til_setup.h
+++ b/src/til_setup.h
@@ -1,14 +1,16 @@
#ifndef _TIL_SETUP_H
#define _TIL_SETUP_H
+typedef struct til_settings_t til_settings_t;
typedef struct til_setup_t til_setup_t;
struct til_setup_t {
+ const char *path;
unsigned refcount;
void (*free)(til_setup_t *setup);
};
-void * til_setup_new(size_t size, void (*free_func)(til_setup_t *setup));
+void * til_setup_new(const til_settings_t *settings, size_t size, void (*free_func)(til_setup_t *setup));
void * til_setup_ref(til_setup_t *setup);
void * til_setup_free(til_setup_t *setup);
© All Rights Reserved