diff options
author | Uoti Urpala <uau@symbol.nonexistent.invalid> | 2008-04-30 19:34:26 +0300 |
---|---|---|
committer | Uoti Urpala <uau@symbol.nonexistent.invalid> | 2008-04-30 19:34:48 +0300 |
commit | bb12a33f9ae0b5cbf628e6f4e0218736a89e481f (patch) | |
tree | 3eb6c268cd1206c0eb1387982218be493d388c8d /m_config.c | |
parent | e61ac5e9cb870c03e2404f5dd19cb0bb25aab80c (diff) | |
download | mpv-bb12a33f9ae0b5cbf628e6f4e0218736a89e481f.tar.bz2 mpv-bb12a33f9ae0b5cbf628e6f4e0218736a89e481f.tar.xz |
options: Make dynamic dup hack work with new options
The option system has a hack that converts default values (potentially
constants) of dynamically allocated options to allocated ones when the
options are first added to the config system, so that all values can
be equally freed later. Make this work with new-style options in the
option struct too.
Diffstat (limited to 'm_config.c')
-rw-r--r-- | m_config.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/m_config.c b/m_config.c index 024f7d713f..538ebc32a3 100644 --- a/m_config.c +++ b/m_config.c @@ -229,10 +229,13 @@ m_config_add_option(m_config_t *config, const m_option_t *arg, const char* prefi m_option_save(config, arg, sl->data); // Hack to avoid too much trouble with dynamically allocated data : // We always use a dynamic version - if ((arg->type->flags & M_OPT_TYPE_DYNAMIC) && arg->p - && (*(void**)arg->p)) { - *(void**)arg->p = NULL; - m_option_set(config, arg, sl->data); + if ((arg->type->flags & M_OPT_TYPE_DYNAMIC)) { + char **hackptr = arg->new ? (char*)config->optstruct + arg->offset + : arg->p; + if (hackptr && *hackptr) { + *hackptr = NULL; + m_option_set(config, arg, sl->data); + } } sl->lvl = 0; sl->prev = NULL; |