From: Timo Sirainen Date: Mon, 15 May 2023 21:12:02 +0000 (+0300) Subject: config: Replace config_export_dup_module_parsers() with config_export_set_module_pars... X-Git-Tag: 2.4.0~2091 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bd0489d4e8d906fdbe40061538932c7c39e17ba9;p=thirdparty%2Fdovecot%2Fcore.git config: Replace config_export_dup_module_parsers() with config_export_set_module_parsers() Now that settings checks are done while parsing the config, the parsers no longer change afterwards so there is no need to duplicate them. --- diff --git a/src/config/config-dump-full.c b/src/config/config-dump-full.c index 441aa23eb6..3fb2802e5f 100644 --- a/src/config/config-dump-full.c +++ b/src/config/config-dump-full.c @@ -282,7 +282,9 @@ int config_dump_full(struct config_parsed *config, CONFIG_DUMP_SCOPE_CHANGED, flags, config_dump_full_callback, &dump_ctx); } - config_export_dup_module_parsers(export_ctx, config); + struct config_filter_parser *filter_parser = + config_parsed_get_global_filter_parser(config); + config_export_set_module_parsers(export_ctx, filter_parser->module_parsers); string_t *path = t_str_new(128); const char *final_path = NULL; diff --git a/src/config/config-request.c b/src/config/config-request.c index 0f83c3f144..d49bbcf44a 100644 --- a/src/config/config-request.c +++ b/src/config/config-request.c @@ -25,7 +25,6 @@ struct config_export_context { enum config_dump_flags flags; const struct config_module_parser *module_parsers; - struct config_module_parser *dup_module_parsers; unsigned int section_idx; }; @@ -398,33 +397,6 @@ config_export_init(enum config_dump_scope scope, return ctx; } -static struct config_module_parser * -config_filter_parsers_dup(pool_t pool, struct config_filter_parser *global_filter) -{ - struct config_module_parser *dest; - unsigned int i, count; - - for (count = 0; global_filter->module_parsers[count].root != NULL; count++) ; - dest = p_new(pool, struct config_module_parser, count + 1); - for (i = 0; i < count; i++) { - dest[i] = global_filter->module_parsers[i]; - dest[i].parser = - settings_parser_dup(global_filter->module_parsers[i].parser, pool); - } - return dest; -} - -void config_export_dup_module_parsers(struct config_export_context *ctx, - struct config_parsed *config) -{ - struct config_filter_parser *global_filter = - config_parsed_get_global_filter_parser(config); - - ctx->dup_module_parsers = - config_filter_parsers_dup(ctx->pool, global_filter); - ctx->module_parsers = ctx->dup_module_parsers; -} - void config_export_set_module_parsers(struct config_export_context *ctx, const struct config_module_parser *module_parsers) { @@ -479,8 +451,6 @@ void config_export_free(struct config_export_context **_ctx) *_ctx = NULL; - if (ctx->dup_module_parsers != NULL) - config_module_parsers_free(ctx->dup_module_parsers); hash_table_destroy(&ctx->keys); pool_unref(&ctx->pool); } diff --git a/src/config/config-request.h b/src/config/config-request.h index 0c0b070851..8e7591879a 100644 --- a/src/config/config-request.h +++ b/src/config/config-request.h @@ -40,8 +40,6 @@ config_export_init(enum config_dump_scope scope, enum config_dump_flags flags, config_request_callback_t *callback, void *context) ATTR_NULL(1, 5); -void config_export_dup_module_parsers(struct config_export_context *ctx, - struct config_parsed *config); void config_export_set_module_parsers(struct config_export_context *ctx, const struct config_module_parser *parsers); unsigned int config_export_get_parser_count(struct config_export_context *ctx); diff --git a/src/config/doveconf.c b/src/config/doveconf.c index 2759eda3d2..f86938eb24 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -574,7 +574,10 @@ config_dump_human(enum config_dump_scope scope, const char *setting_name_filter, o_stream_cork(output); ctx = config_dump_human_init(scope); - config_export_dup_module_parsers(ctx->export_ctx, config); + struct config_filter_parser *filter_parser = + config_parsed_get_global_filter_parser(config); + config_export_set_module_parsers(ctx->export_ctx, + filter_parser->module_parsers); config_dump_human_output(ctx, output, 0, setting_name_filter, hide_passwords); config_dump_human_deinit(ctx); @@ -603,7 +606,10 @@ config_dump_one(bool hide_key, bool dump_section = FALSE; ctx = config_dump_human_init(scope); - config_export_dup_module_parsers(ctx->export_ctx, config); + struct config_filter_parser *filter_parser = + config_parsed_get_global_filter_parser(config); + config_export_set_module_parsers(ctx->export_ctx, + filter_parser->module_parsers); if (config_export_all_parsers(&ctx->export_ctx, §ion_idx) < 0) i_unreached(); /* settings aren't checked - this can't happen */ @@ -968,7 +974,9 @@ int main(int argc, char *argv[]) ctx = config_export_init(scope, 0, config_request_simple_stdout, setting_name_filters); - config_export_dup_module_parsers(ctx, config); + struct config_filter_parser *filter_parser = + config_parsed_get_global_filter_parser(config); + config_export_set_module_parsers(ctx, filter_parser->module_parsers); if (config_export_all_parsers(&ctx, §ion_idx) < 0) i_unreached(); ret2 = 0;