From 3bb134969eb624e859a546fd7142fe2eae076346 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 30 Aug 2016 23:45:58 +0200 Subject: [PATCH] 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. --- options/m_config.c | 2 +- options/m_option.c | 9 ++------- options/m_option.h | 10 +--------- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/options/m_config.c b/options/m_config.c index 106a8f20eec74..d2fe3fdcfa244 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -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) diff --git a/options/m_option.c b/options/m_option.c index 0acdc55b0abbf..94dab9f59f364 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -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, diff --git a/options/m_option.h b/options/m_option.h index 80be447c424c9..847cd1097cb06 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -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 /////////////////////////////////