m_option: remove M_OPT_TYPE_DYNAMIC flag

It's actually redundant with whether m_option_type.free is set. Some
option types were flagged inconsistently. Its only use was for running
an additional sanity check without any real functionality.
This commit is contained in:
wm4 2016-08-30 23:45:58 +02:00
parent 6f6d2eb770
commit 3bb134969e
3 changed files with 4 additions and 17 deletions

View File

@ -424,7 +424,7 @@ static void m_config_add_option(struct m_config *config,
} else {
// Initialize options
if (co.data && co.default_data) {
if (arg->type->flags & M_OPT_TYPE_DYNAMIC) {
if (arg->type->free) {
// Would leak memory by overwriting *co.data repeatedly.
for (int i = 0; i < config->num_opts; i++) {
if (co.data == config->opts[i].data)

View File

@ -1175,7 +1175,6 @@ static void free_str(void *src)
const m_option_type_t m_option_type_string = {
.name = "String",
.size = sizeof(char *),
.flags = M_OPT_TYPE_DYNAMIC,
.parse = parse_str,
.print = print_str,
.copy = copy_str,
@ -1486,7 +1485,7 @@ const m_option_type_t m_option_type_string_list = {
*/
.name = "String list",
.size = sizeof(char **),
.flags = M_OPT_TYPE_DYNAMIC | M_OPT_TYPE_ALLOW_WILDCARD,
.flags = M_OPT_TYPE_ALLOW_WILDCARD,
.parse = parse_str_list,
.print = print_str_list,
.copy = copy_str_list,
@ -1522,7 +1521,6 @@ static int parse_str_append_list(struct mp_log *log, const m_option_t *opt,
const m_option_type_t m_option_type_string_append_list = {
.name = "String list",
.size = sizeof(char **),
.flags = M_OPT_TYPE_DYNAMIC,
.parse = parse_str_append_list,
.print = print_str_list,
.copy = copy_str_list,
@ -1636,7 +1634,6 @@ static int keyvalue_list_get(const m_option_t *opt, void *ta_parent,
const m_option_type_t m_option_type_keyvalue_list = {
.name = "Key/value list",
.size = sizeof(char **),
.flags = M_OPT_TYPE_DYNAMIC,
.parse = parse_keyvalue_list,
.print = print_keyvalue_list,
.copy = copy_str_list,
@ -1703,7 +1700,6 @@ static int set_msglevels(const m_option_t *opt, void *dst,
const m_option_type_t m_option_type_msglevels = {
.name = "Output verbosity levels",
.size = sizeof(char **),
.flags = M_OPT_TYPE_DYNAMIC,
.parse = parse_msglevels,
.print = print_keyvalue_list,
.copy = copy_str_list,
@ -3284,7 +3280,7 @@ static int get_obj_settings_list(const m_option_t *opt, void *ta_parent,
const m_option_type_t m_option_type_obj_settings_list = {
.name = "Object settings list",
.size = sizeof(m_obj_settings_t *),
.flags = M_OPT_TYPE_DYNAMIC | M_OPT_TYPE_ALLOW_WILDCARD,
.flags = M_OPT_TYPE_ALLOW_WILDCARD,
.parse = parse_obj_settings_list,
.print = print_obj_settings_list,
.copy = copy_obj_settings_list,
@ -3405,7 +3401,6 @@ static int node_get(const m_option_t *opt, void *ta_parent,
const m_option_type_t m_option_type_node = {
.name = "Complex",
.size = sizeof(struct mpv_node),
.flags = M_OPT_TYPE_DYNAMIC,
.parse = parse_node,
.print = print_node,
.copy = copy_node,

View File

@ -403,19 +403,11 @@ struct m_option {
*/
#define M_OPT_TYPE_ALLOW_WILDCARD (1 << 1)
// Dynamic data type.
/** This flag indicates that the data is dynamically allocated (m_option::p
* points to a pointer). It enables a little hack in the \ref Config which
* replaces the initial value of such variables with a dynamic copy in case
* the initial value is statically allocated (pretty common with strings).
*/
#define M_OPT_TYPE_DYNAMIC (1 << 2)
// The parameter is optional and by default no parameter is preferred. If
// ambiguous syntax is used ("--opt value"), the command line parser will
// assume that the argument takes no parameter. In config files, these
// options can be used without "=" and value.
#define M_OPT_TYPE_OPTIONAL_PARAM (1 << 3)
#define M_OPT_TYPE_OPTIONAL_PARAM (1 << 2)
///////////////////////////// Parser flags /////////////////////////////////