From: Timo Sirainen Date: Wed, 8 Mar 2023 15:06:52 +0000 (+0200) Subject: lib-settings: Remove ability to use multiple roots in setting_parser_context X-Git-Tag: 2.4.0~2227 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e5c1150a0440ba14a5c24a665ec98314f3db23b;p=thirdparty%2Fdovecot%2Fcore.git lib-settings: Remove ability to use multiple roots in setting_parser_context --- diff --git a/src/lib-settings/settings-parser.c b/src/lib-settings/settings-parser.c index 6d193d9499..885497b6dd 100644 --- a/src/lib-settings/settings-parser.c +++ b/src/lib-settings/settings-parser.c @@ -74,13 +74,6 @@ settings_apply(struct setting_link *dest_link, const struct setting_link *src_link, pool_t pool, const char **conflict_key_r); -struct setting_parser_context * -settings_parser_init(pool_t set_pool, const struct setting_parser_info *root, - enum settings_parser_flags flags) -{ - return settings_parser_init_list(set_pool, &root, 1, flags); -} - static void copy_unique_defaults(struct setting_parser_context *ctx, const struct setting_define *def, @@ -188,16 +181,13 @@ setting_parser_copy_defaults(struct setting_parser_context *ctx, } struct setting_parser_context * -settings_parser_init_list(pool_t set_pool, - const struct setting_parser_info *const *roots, - unsigned int count, enum settings_parser_flags flags) +settings_parser_init(pool_t set_pool, const struct setting_parser_info *root, + enum settings_parser_flags flags) { struct setting_parser_context *ctx; unsigned int i; pool_t parser_pool; - i_assert(count > 0); - parser_pool = pool_alloconly_create(MEMPOOL_GROWING"settings parser", 1024); ctx = p_new(parser_pool, struct setting_parser_context, 1); @@ -213,9 +203,10 @@ settings_parser_init_list(pool_t set_pool, hash_table_create(&ctx->links, ctx->parser_pool, 0, strcase_hash, strcasecmp); - ctx->root_count = count; - ctx->roots = p_new(ctx->parser_pool, struct setting_link, count); - for (i = 0; i < count; i++) { + ctx->root_count = 1; + ctx->roots = p_new(ctx->parser_pool, struct setting_link, 1); + const struct setting_parser_info *const *roots = &root; + for (i = 0; i < 1; i++) { ctx->roots[i].info = roots[i]; if (roots[i]->struct_size == 0) continue; @@ -271,18 +262,6 @@ void *settings_parser_get_changes(struct setting_parser_context *ctx) return ctx->roots[0].change_struct; } -const struct setting_parser_info *const * -settings_parser_get_roots(const struct setting_parser_context *ctx) -{ - const struct setting_parser_info **infos; - unsigned int i; - - infos = t_new(const struct setting_parser_info *, ctx->root_count + 1); - for (i = 0; i < ctx->root_count; i++) - infos[i] = ctx->roots[i].info; - return infos; -} - static void settings_parser_set_error(struct setting_parser_context *ctx, const char *error) { diff --git a/src/lib-settings/settings-parser.h b/src/lib-settings/settings-parser.h index 58071fcf14..d9729e459f 100644 --- a/src/lib-settings/settings-parser.h +++ b/src/lib-settings/settings-parser.h @@ -127,10 +127,6 @@ struct setting_parser_context; struct setting_parser_context * settings_parser_init(pool_t set_pool, const struct setting_parser_info *root, enum settings_parser_flags flags); -struct setting_parser_context * -settings_parser_init_list(pool_t set_pool, - const struct setting_parser_info *const *roots, - unsigned int count, enum settings_parser_flags flags); void settings_parser_ref(struct setting_parser_context *ctx); void settings_parser_unref(struct setting_parser_context **ctx); @@ -141,9 +137,6 @@ void *settings_parser_get_root_set(const struct setting_parser_context *ctx, const struct setting_parser_info *root); /* Return pointer to changes in the root setting structure. */ void *settings_parser_get_changes(struct setting_parser_context *ctx); -/* Returns the setting parser's roots (same as given to init()). */ -const struct setting_parser_info *const * -settings_parser_get_roots(const struct setting_parser_context *ctx); /* Return the last error. */ const char *settings_parser_get_error(struct setting_parser_context *ctx);