summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-08-30 23:48:42 +0200
committerwm4 <wm4@nowhere>2016-08-30 23:48:42 +0200
commite65a8d7b61762ddf07825c59a6ebd47b026b0ea7 (patch)
treec3df16d9edff2c9fde858052d13993c1d7b3e414 /options
parent5f88e6a0db292d272b3dc8f66c257c27327d1733 (diff)
downloadmpv-e65a8d7b61762ddf07825c59a6ebd47b026b0ea7.tar.bz2
mpv-e65a8d7b61762ddf07825c59a6ebd47b026b0ea7.tar.xz
m_config: pass parent option in m_config_add_option()
Instead of just the parent name. This is a minor refactor as preparation for other things.
Diffstat (limited to 'options')
-rw-r--r--options/m_config.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/options/m_config.c b/options/m_config.c
index c98ee6713f..8a4d5998d6 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -174,7 +174,7 @@ static void substruct_write_ptr(void *ptr, void *val)
}
static void add_options(struct m_config *config,
- const char *parent_name,
+ struct m_config_option *parent,
void *optstruct,
const void *optstruct_def,
const struct m_option *defs);
@@ -202,7 +202,7 @@ struct m_config *m_config_new(void *talloc_ctx, struct mp_log *log,
memcpy(config->optstruct, defaults, size);
}
if (options)
- add_options(config, "", config->optstruct, defaults, options);
+ add_options(config, NULL, config->optstruct, defaults, options);
return config;
}
@@ -344,19 +344,19 @@ static void add_negation_option(struct m_config *config,
}
static void m_config_add_option(struct m_config *config,
- const char *parent_name,
+ struct m_config_option *parent,
void *optstruct,
const void *optstruct_def,
const struct m_option *arg);
static void add_options(struct m_config *config,
- const char *parent_name,
+ struct m_config_option *parent,
void *optstruct,
const void *optstruct_def,
const struct m_option *defs)
{
for (int i = 0; defs && defs[i].name; i++)
- m_config_add_option(config, parent_name, optstruct, optstruct_def, &defs[i]);
+ m_config_add_option(config, parent, optstruct, optstruct_def, &defs[i]);
}
// Initialize a field with a given value. In case this is dynamic data, it has
@@ -372,7 +372,7 @@ static void init_opt_inplace(const struct m_option *opt, void *dst,
}
static void m_config_add_option(struct m_config *config,
- const char *parent_name,
+ struct m_config_option *parent,
void *optstruct,
const void *optstruct_def,
const struct m_option *arg)
@@ -380,6 +380,8 @@ static void m_config_add_option(struct m_config *config,
assert(config != NULL);
assert(arg != NULL);
+ const char *parent_name = parent ? parent->name : "";
+
struct m_config_option co = {
.opt = arg,
.name = arg->name,
@@ -419,8 +421,7 @@ static void m_config_add_option(struct m_config *config,
if (!new_optstruct_def)
new_optstruct_def = subopts->defaults;
- add_options(config, co.name, new_optstruct,
- new_optstruct_def, subopts->opts);
+ add_options(config, &co, new_optstruct, new_optstruct_def, subopts->opts);
} else {
// Initialize options
if (co.data && co.default_data) {
@@ -451,7 +452,7 @@ static void m_config_add_option(struct m_config *config,
new->priv = talloc_strdup(config, no_alias);
new->type = &m_option_type_alias;
new->offset = -1;
- m_config_add_option(config, "", NULL, NULL, new);
+ m_config_add_option(config, NULL, NULL, NULL, new);
}
}