summaryrefslogtreecommitdiffstats
path: root/m_config.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-05-20 01:26:38 +0300
committerUoti Urpala <uau@mplayer2.org>2012-07-16 21:08:42 +0300
commit48f0692ab973448de5faa323478d1cba3d42e2af (patch)
tree0d00001f5ad9f04e64613c9759c38be5c80b9f10 /m_config.c
parentdc2a4863af9b0e587ac4ec3e2096639098e99a8f (diff)
downloadmpv-48f0692ab973448de5faa323478d1cba3d42e2af.tar.bz2
mpv-48f0692ab973448de5faa323478d1cba3d42e2af.tar.xz
options: make option struct the talloc parent of options
Allocate dynamically-allocated option values as talloc children of the option struct. This will allow implementing per-object (VO etc) options so that simply freeing the object will free associated options too. This doesn't change quite every allocation in m_option.c, but the exceptions are legacy types which will not matter for new per-object options.
Diffstat (limited to 'm_config.c')
-rw-r--r--m_config.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/m_config.c b/m_config.c
index e8996670f4..7545cdb4eb 100644
--- a/m_config.c
+++ b/m_config.c
@@ -67,7 +67,8 @@ static int parse_profile(struct m_config *config, const struct m_option *opt,
}
char **list = NULL;
- int r = m_option_type_string_list.parse(opt, name, param, false, &list);
+ int r = m_option_type_string_list.parse(opt, name, param, false, &list,
+ NULL);
if (r < 0)
return r;
if (!list || !list[0])
@@ -144,7 +145,7 @@ static void m_option_save(const struct m_config *config,
{
if (opt->type->copy) {
const void *src = m_option_get_ptr(opt, config->optstruct);
- opt->type->copy(opt, dst, src);
+ opt->type->copy(opt, dst, src, NULL);
}
}
@@ -153,7 +154,7 @@ static void m_option_set(void *optstruct,
{
if (opt->type->copy) {
void *dst = m_option_get_ptr(opt, optstruct);
- opt->type->copy(opt, dst, src);
+ opt->type->copy(opt, dst, src, optstruct);
}
}
@@ -483,7 +484,8 @@ static int m_config_parse_option(struct m_config *config, void *optstruct,
}
void *dst = set ? m_option_get_ptr(co->opt, optstruct) : NULL;
- int r = m_option_parse(co->opt, name, param, ambiguous_param, dst);
+ int r = co->opt->type->parse(co->opt, name, param, ambiguous_param, dst,
+ optstruct);
// Parsing failed ?
if (r < 0)
return r;
@@ -498,7 +500,8 @@ static int parse_subopts(struct m_config *config, void *optstruct, char *name,
{
char **lst = NULL;
// Split the argument into child options
- int r = m_option_type_subconfig.parse(NULL, bstr(""), param, false, &lst);
+ int r = m_option_type_subconfig.parse(NULL, bstr(""), param, false, &lst,
+ optstruct);
if (r < 0)
return r;
// Parse the child options