diff options
author | wm4 <wm4@nowhere> | 2014-10-06 21:20:10 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-10-06 21:49:26 +0200 |
commit | d26104351b65a212c03ec08679cb45a3aa2f0a32 (patch) | |
tree | 6bbdde0b14316cf090924947dd98d6193bcd4634 /options/m_config.c | |
parent | f440c0626e9159945cc8974f0a7b0ea46d1c8510 (diff) | |
download | mpv-d26104351b65a212c03ec08679cb45a3aa2f0a32.tar.bz2 mpv-d26104351b65a212c03ec08679cb45a3aa2f0a32.tar.xz |
m_config: add function to copy all options
Needed to copy the global option struct in the next commit.
Diffstat (limited to 'options/m_config.c')
-rw-r--r-- | options/m_config.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/options/m_config.c b/options/m_config.c index 46af3446a3..852d4c194c 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -196,7 +196,8 @@ struct m_config *m_config_new(void *talloc_ctx, struct mp_log *log, { struct m_config *config = talloc(talloc_ctx, struct m_config); talloc_set_destructor(config, config_destroy); - *config = (struct m_config) {.log = log}; + *config = (struct m_config) + {.log = log, .size = size, .defaults = defaults, .options = options}; // size==0 means a dummy object is created if (size) { config->optstruct = talloc_zero_size(config, size); @@ -907,6 +908,18 @@ void *m_sub_options_copy(void *talloc_ctx, const struct m_sub_options *opts, return new; } +struct m_config *m_config_dup(void *talloc_ctx, struct m_config *config) +{ + struct m_config *new = m_config_new(talloc_ctx, config->log, config->size, + config->defaults, config->options); + assert(new->num_opts == config->num_opts); + for (int n = 0; n < new->num_opts; n++) { + assert(new->opts[n].opt->type == config->opts[n].opt->type); + m_option_copy(new->opts[n].opt, new->opts[n].data, config->opts[n].data); + } + return new; +} + // This is used for printing error messages on unknown options. static const char *const replaced_opts = "|a52drc#--ad-lavc-ac3drc=level" |