diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-06-03 13:55:41 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-06-03 14:05:43 -0700 |
commit | 126f38df518b4a26886b69a418d748af4f759dcd (patch) | |
tree | b7bd750e8a1dcdac55187ebb9f3ee40ddc67b6b3 /src/til_settings.c | |
parent | 8ceaa22c5e29edbc31bd9d7d8696b179fbf1f5b2 (diff) |
til_settings: drop desc from til_settings_add_value()
In a world where "describing" settings is an iterative process,
especially post-nested-settings which are realized via the
desc-applying process, it's better to not even offer desc-setting
while adding a new setting.
This commit just gets rid of that.
The one caller that was passing a non-NULL desc to
til_settings_add_value(), til_module_setup_randomize(), was
redundantly doing so since the subsequent desc-processing was
assigning it again anyways. Future commits will likely change
til_module_setup_randomize() use a non-NULL desc for skipping
desc-applying, which wouldn't even work if it was always setting
the desc @ add time. That becomes necessary for partially
randomizing sparsely-populated settings.
Diffstat (limited to 'src/til_settings.c')
-rw-r--r-- | src/til_settings.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/til_settings.c b/src/til_settings.c index 2811b72..cc988c0 100644 --- a/src/til_settings.c +++ b/src/til_settings.c @@ -47,7 +47,7 @@ typedef enum til_settings_fsm_state_t { } til_settings_fsm_state_t; -static til_setting_t * add_setting(til_settings_t *settings, const char *key, const char *value, const til_setting_desc_t *desc) +static til_setting_t * add_setting(til_settings_t *settings, const char *key, const char *value) { til_setting_t **new_entries; til_setting_t *s; @@ -61,7 +61,6 @@ static til_setting_t * add_setting(til_settings_t *settings, const char *key, co s->parent = settings; s->key = key; s->value = value; - s->desc = desc; new_entries = realloc(settings->entries, (settings->num + 1) * sizeof(til_setting_t *)); if (!new_entries) { @@ -119,10 +118,10 @@ til_settings_t * til_settings_new(const til_settings_t *parent, const char *labe fclose(value_fp); if (*p == '=') { /* key= */ - (void) add_setting(settings, value_buf, NULL, NULL); + (void) add_setting(settings, value_buf, NULL); state = TIL_SETTINGS_FSM_STATE_EQUAL; } else { /* bare value */ - (void) add_setting(settings, NULL, value_buf, NULL); + (void) add_setting(settings, NULL, value_buf); state = TIL_SETTINGS_FSM_STATE_COMMA; } } else @@ -297,16 +296,15 @@ int til_settings_get_and_describe_value(const til_settings_t *settings, const ti /* add key,value as a new setting to settings, * NULL keys are passed through as-is * values must not be NULL - * desc may be NULL, it's simply passed along as a passenger. */ /* returns the added setting, or NULL on error (ENOMEM) */ -til_setting_t * til_settings_add_value(til_settings_t *settings, const char *key, const char *value, const til_setting_desc_t *desc) +til_setting_t * til_settings_add_value(til_settings_t *settings, const char *key, const char *value) { assert(settings); assert(value); /* XXX: ^^ non-NULL values makes til_settings_get_value_by_idx() NULL-return-for-end-of-settings OK */ - return add_setting(settings, key ? strdup(key) : NULL, strdup(value), desc); + return add_setting(settings, key ? strdup(key) : NULL, strdup(value)); } |