summaryrefslogtreecommitdiffstats
path: root/m_option.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-04 11:14:38 +0200
committerwm4 <wm4@nowhere>2012-08-04 19:59:56 +0200
commit37c03f2c81a443e910eeb3b2613865dce59c54bf (patch)
treee9d5ae5c0ed1fce9f6f689f03edec75bf1e7cca4 /m_option.h
parentab63072b47f9710852636a78a339b368b493e329 (diff)
downloadmpv-37c03f2c81a443e910eeb3b2613865dce59c54bf.tar.bz2
mpv-37c03f2c81a443e910eeb3b2613865dce59c54bf.tar.xz
options: revert passing around talloc contexts
This reverts commit 48f0692ab9 "options: make option struct the talloc parent of options". This made things actually more complicated. It introduced a new parameter to the option parse and copy functions, which was used inconsistently. Some code passed a parent, some not. Morever, you have to call m_option_free() anyway, because not all options actually respect the talloc parent. There is also the question whether passing NULL as parent is supposed to work, or if you still have to implement m_config_free(). On the other hand, this simplifies nothing. I assume the intention was being able to free all option values with a single talloc_free() call, but the same goal can be reached by simply freeing the m_config struct. (The m_config talloc destructor will free each option values.) Get rid of the talloc parent context parameter. This essentially reverts commit 48f0692ab9 ("options: make option struct the talloc parent of options"). In video_out.c, make the VO priv struct the talloc parent for the m_config object, so that destroying the VO will free the options. The ability to free the m_config struct and all its managed options was introduced in commit 89a17bcda6c.
Diffstat (limited to 'm_option.h')
-rw-r--r--m_option.h11
1 files changed, 4 insertions, 7 deletions
diff --git a/m_option.h b/m_option.h
index 2584471e7c..d100e1c628 100644
--- a/m_option.h
+++ b/m_option.h
@@ -192,12 +192,11 @@ struct m_option_type {
* may not be an argument meant for this option
* \param dst Pointer to the memory where the data should be written.
* If NULL the parameter validity should still be checked.
- * talloc_ctx: talloc context if value type requires allocations
* \return On error a negative value is returned, on success the number
* of arguments consumed. For details see \ref OptionParserReturn.
*/
int (*parse)(const m_option_t *opt, struct bstr name, struct bstr param,
- bool ambiguous_param, void *dst, void *talloc_ctx);
+ bool ambiguous_param, void *dst);
// Print back a value in string form.
/** \param opt The option to print.
@@ -211,10 +210,8 @@ struct m_option_type {
/** \param opt The option to copy.
* \param dst Pointer to the destination memory.
* \param src Pointer to the source memory.
- * talloc_ctx: talloc context to use in deep copy
*/
- void (*copy)(const m_option_t *opt, void *dst, const void *src,
- void *talloc_ctx);
+ void (*copy)(const m_option_t *opt, void *dst, const void *src);
// Free the data allocated for a save slot.
/** This is only needed for dynamic types like strings.
@@ -393,7 +390,7 @@ static inline int m_option_parse(const m_option_t *opt, struct bstr name,
struct bstr param, bool ambiguous_param,
void *dst)
{
- return opt->type->parse(opt, name, param, ambiguous_param, dst, NULL);
+ return opt->type->parse(opt, name, param, ambiguous_param, dst);
}
// Helper to print options, see \ref m_option_type::print.
@@ -410,7 +407,7 @@ static inline void m_option_copy(const m_option_t *opt, void *dst,
const void *src)
{
if (opt->type->copy)
- opt->type->copy(opt, dst, src, NULL);
+ opt->type->copy(opt, dst, src);
}
// Helper around \ref m_option_type::free.