summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/til_setup.c14
-rw-r--r--src/til_setup.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/src/til_setup.c b/src/til_setup.c
index ce95366..c06614f 100644
--- a/src/til_setup.c
+++ b/src/til_setup.c
@@ -110,3 +110,17 @@ void * til_setup_free(til_setup_t *setup)
return NULL;
}
+
+
+/* ergonomic helper for setup_funcs to use in res_setup baking */
+int til_setup_free_with_failed_setting_ret_err(til_setup_t *setup, til_setting_t *failed_setting, til_setting_t **res_setting, int err)
+{
+ assert(failed_setting);
+ assert(res_setting);
+ assert(err < 0);
+
+ til_setup_free(setup);
+ *res_setting = failed_setting;
+
+ return err;
+}
diff --git a/src/til_setup.h b/src/til_setup.h
index 905dd6e..eac1444 100644
--- a/src/til_setup.h
+++ b/src/til_setup.h
@@ -4,6 +4,7 @@
#include <stdint.h>
typedef struct til_settings_t til_settings_t;
+typedef struct til_setting_t til_setting_t;
typedef struct til_setup_t til_setup_t;
struct til_setup_t {
@@ -17,5 +18,6 @@ struct til_setup_t {
void * til_setup_new(const til_settings_t *settings, size_t size, void (*free_func)(til_setup_t *setup), const void *creator);
void * til_setup_ref(til_setup_t *setup);
void * til_setup_free(til_setup_t *setup);
+int til_setup_free_with_failed_setting_ret_err(til_setup_t *setup, til_setting_t *failed_setting, til_setting_t **res_setting, int err);
#endif
© All Rights Reserved