diff options
author | wm4 <wm4@nowhere> | 2012-08-04 11:33:24 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-04 19:59:56 +0200 |
commit | 6031b8e22ce34754218ddcd98d4758ab46d647b8 (patch) | |
tree | e2aad57ded8184bb538841c145c99c22983d501d /m_config.c | |
parent | 37c03f2c81a443e910eeb3b2613865dce59c54bf (diff) | |
download | mpv-6031b8e22ce34754218ddcd98d4758ab46d647b8.tar.bz2 mpv-6031b8e22ce34754218ddcd98d4758ab46d647b8.tar.xz |
m_config: implement m_config_new in terms of m_config_simple
Also change m_config_simple() such that you need to register options
using m_config_register_options().
Diffstat (limited to 'm_config.c')
-rw-r--r-- | m_config.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/m_config.c b/m_config.c index 075adcd633..0edf7d9023 100644 --- a/m_config.c +++ b/m_config.c @@ -182,11 +182,19 @@ static int config_destroy(void *p) return 0; } +struct m_config *m_config_simple(void *optstruct) +{ + struct m_config *config = talloc_struct(NULL, struct m_config, { + .optstruct = optstruct, + }); + talloc_set_destructor(config, config_destroy); + return config; +} + struct m_config *m_config_new(void *optstruct, int includefunc(struct m_config *conf, char *filename)) { - struct m_config *config; static const struct m_option ref_opts[] = { { "profile", NULL, CONF_TYPE_STRING_LIST, CONF_NOSAVE, 0, 0, NULL }, { "show-profile", show_profile, CONF_TYPE_PRINT_FUNC, CONF_NOCFG }, @@ -194,8 +202,8 @@ struct m_config *m_config_new(void *optstruct, { NULL } }; - config = talloc_zero(NULL, struct m_config); - talloc_set_destructor(config, config_destroy); + struct m_config *config = m_config_simple(optstruct); + struct m_option *self_opts = talloc_memdup(config, ref_opts, sizeof(ref_opts)); for (int i = 1; self_opts[i].name; i++) @@ -209,22 +217,10 @@ struct m_config *m_config_new(void *optstruct, m_config_add_option(config, p, NULL, NULL); config->includefunc = includefunc; } - config->optstruct = optstruct; return config; } -struct m_config *m_config_simple(const struct m_option *options, - void *optstruct) -{ - struct m_config *config = talloc_struct(NULL, struct m_config, { - .optstruct = optstruct, - }); - talloc_set_destructor(config, config_destroy); - m_config_register_options(config, options); - return config; -} - void m_config_free(struct m_config *config) { talloc_free(config); |