]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
cfg_parse_ API doesn't need memory context
authorColin Vidal <colin@isc.org>
Tue, 4 Nov 2025 09:46:05 +0000 (10:46 +0100)
committerColin Vidal <colin@isc.org>
Thu, 4 Dec 2025 15:09:40 +0000 (16:09 +0100)
Because the parser now uses global memory context, the cfg_parse_* API
doesn't take a memory context anymore.

20 files changed:
bin/check/named-checkconf.c
bin/delv/delv.c
bin/dig/dighost.c
bin/dnssec/dnssec-keygen.c
bin/dnssec/dnssec-ksr.c
bin/named/config.c
bin/named/controlconf.c
bin/named/server.c
bin/nsupdate/nsupdate.c
bin/plugins/filter-a.c
bin/plugins/filter-aaaa.c
bin/plugins/synthrecord.c
bin/rndc/rndc.c
bin/tests/system/hooks/driver/test-syncplugin.c
doc/misc/cfg_test.c
lib/isccfg/include/isccfg/cfg.h
lib/isccfg/parser.c
tests/isccfg/duration_test.c
tests/isccfg/grammar_test.c
tests/isccfg/parser_test.c

index 5b2c934e5237b9bbe59c6b2356b95417da953571..a40a4b703c5467a52971fc368f7c9f3639f13c2c 100644 (file)
@@ -531,11 +531,11 @@ parse_builtin(cfg_obj_t **defaultconfig) {
                             sizeof(common_named_defaultconf) - 1);
        isc_buffer_add(&b, sizeof(common_named_defaultconf) - 1);
 
-       return cfg_parse_buffer(
-               isc_g_mctx, &b, __FILE__, 0, &cfg_type_namedconf,
-               CFG_PCTX_NODEPRECATED | CFG_PCTX_NOOBSOLETE |
-                       CFG_PCTX_NOEXPERIMENTAL | CFG_PCTX_BUILTIN,
-               defaultconfig);
+       return cfg_parse_buffer(&b, __FILE__, 0, &cfg_type_namedconf,
+                               CFG_PCTX_NODEPRECATED | CFG_PCTX_NOOBSOLETE |
+                                       CFG_PCTX_NOEXPERIMENTAL |
+                                       CFG_PCTX_BUILTIN,
+                               defaultconfig);
 }
 
 static void
@@ -714,8 +714,8 @@ main(int argc, char **argv) {
        }
 
        CHECK(setup_logging(stdout));
-       CHECK(cfg_parse_file(isc_g_mctx, conffile, &cfg_type_namedconf,
-                            parserflags, &config));
+       CHECK(cfg_parse_file(conffile, &cfg_type_namedconf, parserflags,
+                            &config));
        CHECK(isccfg_check_namedconf(config, checkflags, isc_g_mctx));
        if (load_zones || list_zones) {
                CHECK(load_zones_fromconfig(config, list_zones));
index 262497da41da37ebfe06d4d7f6b5b60ef568176c..0d69fb79d356ff7a2a8ad6540f662be2539a32aa 100644 (file)
@@ -829,8 +829,8 @@ setup_dnsseckeys(dns_client_t *client, dns_view_t *toview) {
                        fatal("Unable to read key file '%s'", anchorfile);
                }
 
-               result = cfg_parse_file(isc_g_mctx, anchorfile,
-                                       &cfg_type_bindkeys, 0, &bindkeys);
+               result = cfg_parse_file(anchorfile, &cfg_type_bindkeys, 0,
+                                       &bindkeys);
                if (result != ISC_R_SUCCESS) {
                        fatal("Unable to load keys from '%s'", anchorfile);
                }
@@ -842,8 +842,8 @@ setup_dnsseckeys(dns_client_t *client, dns_view_t *toview) {
 
                isc_buffer_init(&b, anchortext, sizeof(anchortext) - 1);
                isc_buffer_add(&b, sizeof(anchortext) - 1);
-               result = cfg_parse_buffer(isc_g_mctx, &b, NULL, 0, &delv_type,
-                                         0, &bindkeys);
+               result = cfg_parse_buffer(&b, NULL, 0, &delv_type, 0,
+                                         &bindkeys);
                if (result != ISC_R_SUCCESS) {
                        fatal("Unable to parse built-in keys");
                }
index 80253b18d6d7fc2a4b9649e1b4bf21fa1a30a5a9..4c0af64d64b54c875b402d792104133aab81611f 100644 (file)
@@ -1062,8 +1062,7 @@ read_confkey(void) {
                return ISC_R_FILENOTFOUND;
        }
 
-       CHECK(cfg_parse_file(isc_g_mctx, keyfile, &cfg_type_sessionkey, 0,
-                            &file));
+       CHECK(cfg_parse_file(keyfile, &cfg_type_sessionkey, 0, &file));
 
        CHECK(cfg_map_get(file, "key", &keyobj));
 
index 17556b17b9c7223c59d209c786a68247acbbee8b..4b222de72ee394b12b0e552231f6774665d5cc19 100644 (file)
@@ -1150,9 +1150,8 @@ main(int argc, char **argv) {
                        cfg_obj_t *config = NULL;
                        dns_kasp_t *kasp = NULL;
 
-                       if (cfg_parse_file(isc_g_mctx, ctx.configfile,
-                                          &cfg_type_namedconf, 0,
-                                          &config) != ISC_R_SUCCESS)
+                       if (cfg_parse_file(ctx.configfile, &cfg_type_namedconf,
+                                          0, &config) != ISC_R_SUCCESS)
                        {
                                fatal("unable to load dnssec-policy '%s' from "
                                      "'%s'",
index 8f0c61c7a1c78dc3c743eee10399fc03ab345e4f..9664653d0bde33025f4cd0aaf3db728876e19bc8 100644 (file)
@@ -157,8 +157,8 @@ static void
 getkasp(ksr_ctx_t *ksr, dns_kasp_t **kasp) {
        cfg_obj_t *config = NULL;
 
-       if (cfg_parse_file(isc_g_mctx, ksr->configfile, &cfg_type_namedconf, 0,
-                          &config) != ISC_R_SUCCESS)
+       if (cfg_parse_file(ksr->configfile, &cfg_type_namedconf, 0, &config) !=
+           ISC_R_SUCCESS)
        {
                fatal("unable to load dnssec-policy '%s' from '%s'",
                      ksr->policy, ksr->configfile);
index c953f4c45a975f410617084e5a0bedfee485a375..7c74b527393d508a8309fe0f9d60adf795f2a37f 100644 (file)
@@ -55,11 +55,11 @@ named_config_parsedefaults(cfg_obj_t **conf) {
        isc_buffer_constinit(&b, common_named_defaultconf,
                             sizeof(common_named_defaultconf) - 1);
        isc_buffer_add(&b, sizeof(common_named_defaultconf) - 1);
-       return cfg_parse_buffer(
-               isc_g_mctx, &b, __FILE__, 0, &cfg_type_namedconf,
-               CFG_PCTX_NODEPRECATED | CFG_PCTX_NOOBSOLETE |
-                       CFG_PCTX_NOEXPERIMENTAL | CFG_PCTX_BUILTIN,
-               conf);
+       return cfg_parse_buffer(&b, __FILE__, 0, &cfg_type_namedconf,
+                               CFG_PCTX_NODEPRECATED | CFG_PCTX_NOOBSOLETE |
+                                       CFG_PCTX_NOEXPERIMENTAL |
+                                       CFG_PCTX_BUILTIN,
+                               conf);
 }
 
 isc_result_t
@@ -72,8 +72,7 @@ named_config_parsefile(cfg_obj_t **conf) {
                      ISC_LOG_INFO, "parsing user configuration from '%s'",
                      named_g_conffile);
 
-       CHECK(cfg_parse_file(isc_g_mctx, named_g_conffile, &cfg_type_namedconf,
-                            0, conf));
+       CHECK(cfg_parse_file(named_g_conffile, &cfg_type_namedconf, 0, conf));
 
        /*
         * Check the validity of the configuration.
index 4653bcafa74df58b9e260d72eb1b099b205a7f09..048b88f08728b13e07bd618a0a94c7617cf5e8d2 100644 (file)
@@ -787,8 +787,7 @@ get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids) {
                return ISC_R_FILENOTFOUND;
        }
 
-       CHECK(cfg_parse_file(mctx, named_g_keyfile, &cfg_type_rndckey, 0,
-                            &config));
+       CHECK(cfg_parse_file(named_g_keyfile, &cfg_type_rndckey, 0, &config));
        CHECK(cfg_map_get(config, "key", &key));
 
        keyid = isc_mem_get(mctx, sizeof(*keyid));
index 4dc7b91afac7b9ee6eccc6ea4d853c7baca3ec8b..cb03db4d6208644c43c9a34829ce65881c61a975 100644 (file)
@@ -2350,7 +2350,7 @@ catz_addmodzone_cb(void *arg) {
        confbuf = NULL;
        result = dns_catz_generate_zonecfg(cz->origin, cz->entry, &confbuf);
        if (result == ISC_R_SUCCESS) {
-               result = cfg_parse_buffer(isc_g_mctx, confbuf, "catz", 0,
+               result = cfg_parse_buffer(confbuf, "catz", 0,
                                          &cfg_type_addzoneconf, 0, &zoneconf);
                isc_buffer_free(&confbuf);
        }
@@ -2618,7 +2618,7 @@ catz_reconfigure(dns_catz_entry_t *entry, void *arg1, void *arg2) {
 
        result = dns_catz_generate_zonecfg(data->catz, entry, &confbuf);
        if (result == ISC_R_SUCCESS) {
-               result = cfg_parse_buffer(isc_g_mctx, confbuf, "catz", 0,
+               result = cfg_parse_buffer(confbuf, "catz", 0,
                                          &cfg_type_addzoneconf, 0, &zoneconf);
                isc_buffer_free(&confbuf);
        }
@@ -7294,8 +7294,8 @@ data_to_cfg(dns_view_t *view, MDB_val *key, MDB_val *data, isc_buffer_t *text,
        snprintf(bufname, sizeof(bufname), "%.*s", (int)zone_name_len,
                 zone_name);
 
-       result = cfg_parse_buffer(isc_g_mctx, text, bufname, 0,
-                                 &cfg_type_addzoneconf, 0, &zoneconf);
+       result = cfg_parse_buffer(text, bufname, 0, &cfg_type_addzoneconf, 0,
+                                 &zoneconf);
        if (result != ISC_R_SUCCESS) {
                isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
                              ISC_LOG_ERROR,
@@ -8920,9 +8920,9 @@ load_configuration(named_server_t *server, bool first_time) {
                                      "keys instead",
                                      named_g_bindkeysfile);
                } else {
-                       result = cfg_parse_file(
-                               isc_g_mctx, named_g_bindkeysfile,
-                               &cfg_type_bindkeys, 0, &bindkeys);
+                       result = cfg_parse_file(named_g_bindkeysfile,
+                                               &cfg_type_bindkeys, 0,
+                                               &bindkeys);
                        if (result != ISC_R_SUCCESS) {
                                isc_log_write(NAMED_LOGCATEGORY_GENERAL,
                                              NAMED_LOGMODULE_SERVER,
@@ -12129,8 +12129,7 @@ load_nzf(dns_view_t *view) {
        /*
         * Parse the configuration in the NZF file.
         */
-       result = cfg_parse_file(view->mctx, view->newzone.file,
-                               &cfg_type_addzoneconf, 0,
+       result = cfg_parse_file(view->newzone.file, &cfg_type_addzoneconf, 0,
                                &view->newzone.nzconfig);
        if (result != ISC_R_SUCCESS) {
                isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
@@ -12496,8 +12495,8 @@ load_nzf(dns_view_t *view) {
         * config type, giving us a guarantee that valid configuration
         * will be written to DB.
         */
-       result = cfg_parse_file(isc_g_mctx, view->newzone.file,
-                               &cfg_type_addzoneconf, 0, &nzf_config);
+       result = cfg_parse_file(view->newzone.file, &cfg_type_addzoneconf, 0,
+                               &nzf_config);
        if (result != ISC_R_SUCCESS) {
                isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
                              ISC_LOG_ERROR, "Error parsing NZF file '%s': %s",
@@ -12647,8 +12646,8 @@ newzone_parse(named_server_t *server, char *command, dns_view_t **viewp,
         */
        isc_buffer_forward(&argbuf, 3);
 
-       CHECK(cfg_parse_buffer(server->mctx, &argbuf, bn, 0,
-                              &cfg_type_addzoneconf, 0, &zoneconf));
+       CHECK(cfg_parse_buffer(&argbuf, bn, 0, &cfg_type_addzoneconf, 0,
+                              &zoneconf));
 
        CHECK(cfg_map_get(zoneconf, "zone", &zlist));
        if (!cfg_obj_islist(zlist)) {
index cc8e5b4cd628dc422a196635d6c59929396a32ac..820029d3e84dd645f5d2ebc37d8c77d8ec5bba00 100644 (file)
@@ -569,8 +569,7 @@ read_sessionkey(isc_mem_t *mctx) {
                return ISC_R_FILENOTFOUND;
        }
 
-       CHECK(cfg_parse_file(mctx, keyfile, &cfg_type_sessionkey, 0,
-                            &sessionkey));
+       CHECK(cfg_parse_file(keyfile, &cfg_type_sessionkey, 0, &sessionkey));
 
        CHECK(cfg_map_get(sessionkey, "key", &key));
 
index d5a9d0b26884742bff21725d675478819300f36d..541bb7ebc5044991abefa2988a8f347bc037e0cb 100644 (file)
@@ -272,8 +272,8 @@ parse_parameters(filter_instance_t *inst, const char *parameters,
 
        isc_buffer_constinit(&b, parameters, strlen(parameters));
        isc_buffer_add(&b, strlen(parameters));
-       CHECK(cfg_parse_buffer(mctx, &b, cfg_file, cfg_line,
-                              &cfg_type_parameters, 0, &param_obj));
+       CHECK(cfg_parse_buffer(&b, cfg_file, cfg_line, &cfg_type_parameters, 0,
+                              &param_obj));
 
        CHECK(parse_filter_a_on(param_obj, "filter-a-on-v6", &inst->v6_a));
        CHECK(parse_filter_a_on(param_obj, "filter-a-on-v4", &inst->v4_a));
@@ -359,8 +359,8 @@ plugin_check(const char *parameters, const void *cfg, const char *cfg_file,
 
        isc_buffer_constinit(&b, parameters, strlen(parameters));
        isc_buffer_add(&b, strlen(parameters));
-       CHECK(cfg_parse_buffer(mctx, &b, cfg_file, cfg_line,
-                              &cfg_type_parameters, 0, &param_obj));
+       CHECK(cfg_parse_buffer(&b, cfg_file, cfg_line, &cfg_type_parameters, 0,
+                              &param_obj));
 
        CHECK(check_syntax(param_obj, cfg, mctx, aclctx));
 
index 007d952e7e1151940946ee10757a30f3d0a4e29b..8173b736c7f912ca5384505c7d9025411e1563a2 100644 (file)
@@ -273,8 +273,8 @@ parse_parameters(filter_instance_t *inst, const char *parameters,
 
        isc_buffer_constinit(&b, parameters, strlen(parameters));
        isc_buffer_add(&b, strlen(parameters));
-       CHECK(cfg_parse_buffer(mctx, &b, cfg_file, cfg_line,
-                              &cfg_type_parameters, 0, &param_obj));
+       CHECK(cfg_parse_buffer(&b, cfg_file, cfg_line, &cfg_type_parameters, 0,
+                              &param_obj));
 
        CHECK(parse_filter_aaaa_on(param_obj, "filter-aaaa-on-v4",
                                   &inst->v4_aaaa));
@@ -363,8 +363,8 @@ plugin_check(const char *parameters, const void *cfg, const char *cfg_file,
 
        isc_buffer_constinit(&b, parameters, strlen(parameters));
        isc_buffer_add(&b, strlen(parameters));
-       CHECK(cfg_parse_buffer(mctx, &b, cfg_file, cfg_line,
-                              &cfg_type_parameters, 0, &param_obj));
+       CHECK(cfg_parse_buffer(&b, cfg_file, cfg_line, &cfg_type_parameters, 0,
+                              &param_obj));
 
        CHECK(check_syntax(param_obj, cfg, mctx, aclctx));
 
index 8dc3e257b120e1d7e0c6f9d0928a5e50acb5dd09..895f2f7df2ec3b44e2de0cc431ff00768aa705e4 100644 (file)
@@ -554,15 +554,14 @@ synthrecord_parseconfig(synthrecord_t *inst, const char *parameters,
                        unsigned long cfgline, cfg_aclconfctx_t *aclctx,
                        const dns_name_t *zname) {
        isc_result_t result;
-       isc_mem_t *mctx = inst->mctx;
        cfg_obj_t *synthrecordcfg = NULL;
        isc_buffer_t b;
 
        isc_buffer_constinit(&b, parameters, strlen(parameters));
        isc_buffer_add(&b, strlen(parameters));
 
-       CHECK(cfg_parse_buffer(mctx, &b, cfgfile, cfgline,
-                              &synthrecord_cfgparams, 0, &synthrecordcfg));
+       CHECK(cfg_parse_buffer(&b, cfgfile, cfgline, &synthrecord_cfgparams, 0,
+                              &synthrecordcfg));
 
        synthrecord_setconfigmode(inst, zname);
        CHECK(synthrecord_initorigin(inst, synthrecordcfg, zname));
index 66660351ba1502ed1b1f1fdcc1fe9ab4ff99ce2e..dc5b536f4e6986a543becd078060cf6076df365f 100644 (file)
@@ -537,7 +537,7 @@ rndc_start(void *arg) {
 }
 
 static void
-parse_config(isc_mem_t *mctx, const char *keyname, cfg_obj_t **configp) {
+parse_config(const char *keyname, cfg_obj_t **configp) {
        isc_result_t result;
        const char *conffile = admin_conffile;
        const cfg_obj_t *addresses = NULL;
@@ -581,7 +581,7 @@ parse_config(isc_mem_t *mctx, const char *keyname, cfg_obj_t **configp) {
        /*
         * The parser will output its own errors, so DO() is not used.
         */
-       result = cfg_parse_file(mctx, conffile, conftype, 0, &config);
+       result = cfg_parse_file(conffile, conftype, 0, &config);
        if (result != ISC_R_SUCCESS) {
                fatal("could not load rndc configuration");
        }
@@ -961,7 +961,7 @@ main(int argc, char **argv) {
                ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL, ISC_LOGCATEGORY_DEFAULT,
                ISC_LOGMODULE_DEFAULT);
 
-       parse_config(isc_g_mctx, keyname, &config);
+       parse_config(keyname, &config);
 
        isc_buffer_allocate(isc_g_mctx, &databuf, 2048);
 
index 36409bbda969110474b797220839fa1b468006b4..c125f335d67337c2990dbb3e80a691683fb0de8f 100644 (file)
@@ -126,8 +126,8 @@ plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
        isc_buffer_constinit(&b, parameters, strlen(parameters));
        isc_buffer_add(&b, strlen(parameters));
 
-       CHECK(cfg_parse_buffer(mctx, &b, cfgfile, cfgline,
-                              &syncplugin__cfgparams, 0, &syncplugincfg));
+       CHECK(cfg_parse_buffer(&b, cfgfile, cfgline, &syncplugin__cfgparams, 0,
+                              &syncplugincfg));
 
        CHECK(syncplugin__parse_rcode(syncplugincfg, &inst->rcode));
 
index f29600c2aa7f7ddeb2a54d424e68acddd3bcbdf0..cb17b35e1b9db9cb74467f5533a960bca7c2e33c 100644 (file)
@@ -133,7 +133,7 @@ main(int argc, char **argv) {
                if (type == NULL || filename == NULL) {
                        usage();
                }
-               result = cfg_parse_file(mctx, filename, type, 0, &cfg);
+               result = cfg_parse_file(filename, type, 0, &cfg);
 
                fprintf(stderr, "read config: %s\n", isc_result_totext(result));
 
@@ -147,6 +147,10 @@ main(int argc, char **argv) {
        }
 
        if (memstats) {
+               /*
+                * TODO: this is memstat of config that we are interested in
+                * here, right?
+                */
                isc_mem_stats(mctx, stderr);
        }
        isc_mem_detach(&mctx);
index 882ac2cca15f2f475f854c8e580d712194b80719..5012f492171730c6cd36a2e168d241944cb748e7 100644 (file)
@@ -91,13 +91,12 @@ typedef isc_result_t (*cfg_parsecallback_t)(const char          *clausename,
  ***/
 
 isc_result_t
-cfg_parse_file(isc_mem_t *mctx, const char *file, const cfg_type_t *type,
-              unsigned int flags, cfg_obj_t **ret);
+cfg_parse_file(const char *file, const cfg_type_t *type, unsigned int flags,
+              cfg_obj_t **ret);
 
 isc_result_t
-cfg_parse_buffer(isc_mem_t *mctx, isc_buffer_t *buffer, const char *file,
-                unsigned int line, const cfg_type_t *type, unsigned int flags,
-                cfg_obj_t **ret);
+cfg_parse_buffer(isc_buffer_t *buffer, const char *file, unsigned int line,
+                const cfg_type_t *type, unsigned int flags, cfg_obj_t **ret);
 /*%<
  * Read a configuration containing data of type 'type'
  * and make '*ret' point to its parse tree.
index 188d34226b89885971fe56e292052320c1a488e2..202609a6f4d643e55cbb79c679ffb9a81da61378 100644 (file)
@@ -680,17 +680,16 @@ static cfg_type_t cfg_type_filelist = { "filelist",    NULL,
                                        &cfg_rep_list, &cfg_type_qstring };
 
 static void
-parser_create(isc_mem_t *mctx, cfg_parser_t **ret) {
+parser_create(cfg_parser_t **ret) {
        cfg_parser_t *pctx;
        isc_lexspecials_t specials;
 
-       REQUIRE(mctx != NULL);
        REQUIRE(ret != NULL && *ret == NULL);
 
-       pctx = isc_mem_get(mctx, sizeof(*pctx));
+       pctx = isc_mem_get(isc_g_mctx, sizeof(*pctx));
 
        pctx->mctx = NULL;
-       isc_mem_attach(mctx, &pctx->mctx);
+       isc_mem_attach(isc_g_mctx, &pctx->mctx);
 
        pctx->lexer = NULL;
        pctx->seen_eof = false;
@@ -712,14 +711,14 @@ parser_create(isc_mem_t *mctx, cfg_parser_t **ret) {
        specials['"'] = 1;
        specials['!'] = 1;
 
-       isc_lex_create(pctx->mctx, 1024, &pctx->lexer);
+       isc_lex_create(isc_g_mctx, 1024, &pctx->lexer);
 
        isc_lex_setspecials(pctx->lexer, specials);
        isc_lex_setcomments(pctx->lexer, ISC_LEXCOMMENT_C |
                                                 ISC_LEXCOMMENT_CPLUSPLUS |
                                                 ISC_LEXCOMMENT_SHELL);
 
-       create_list(pctx->mctx, cfg_parser_currentfile(pctx), pctx->line,
+       create_list(isc_g_mctx, cfg_parser_currentfile(pctx), pctx->line,
                    &cfg_type_filelist, &pctx->open_files);
        create_list(pctx->mctx, cfg_parser_currentfile(pctx), pctx->line,
                    &cfg_type_filelist, &pctx->closed_files);
@@ -811,19 +810,18 @@ cleanup:
                           CFG_PCTX_NOEXPERIMENTAL | CFG_PCTX_BUILTIN)) == 0)
 
 isc_result_t
-cfg_parse_file(isc_mem_t *mctx, const char *filename, const cfg_type_t *type,
-              unsigned int flags, cfg_obj_t **ret) {
+cfg_parse_file(const char *filename, const cfg_type_t *type, unsigned int flags,
+              cfg_obj_t **ret) {
        isc_result_t result;
        cfg_listelt_t *elt;
        cfg_parser_t *pctx = NULL;
 
-       REQUIRE(mctx != NULL);
        REQUIRE(filename != NULL);
        REQUIRE(type != NULL);
        REQUIRE(ret != NULL && *ret == NULL);
        REQUIRE_PCTX_FLAGS(flags);
 
-       parser_create(mctx, &pctx);
+       parser_create(&pctx);
        pctx->flags = flags;
 
        CHECK(parser_openfile(pctx, filename));
@@ -843,19 +841,17 @@ cleanup:
 }
 
 isc_result_t
-cfg_parse_buffer(isc_mem_t *mctx, isc_buffer_t *buffer, const char *file,
-                unsigned int line, const cfg_type_t *type, unsigned int flags,
-                cfg_obj_t **ret) {
+cfg_parse_buffer(isc_buffer_t *buffer, const char *file, unsigned int line,
+                const cfg_type_t *type, unsigned int flags, cfg_obj_t **ret) {
        isc_result_t result;
        cfg_parser_t *pctx = NULL;
 
-       REQUIRE(mctx != NULL);
        REQUIRE(type != NULL);
        REQUIRE(buffer != NULL);
        REQUIRE(ret != NULL && *ret == NULL);
        REQUIRE_PCTX_FLAGS(flags);
 
-       parser_create(mctx, &pctx);
+       parser_create(&pctx);
        CHECK(isc_lex_openbuffer(pctx->lexer, buffer));
 
        pctx->buf_name = file;
index a9cb1fd021d53833e36204463da2c0395a03c62b..fbe63046a2fbf3cd9c1154cf6a59cb413c347f9e 100644 (file)
@@ -143,7 +143,7 @@ ISC_RUN_TEST_IMPL(duration) {
                isc_buffer_add(&buf1, strlen(conf) - 1);
 
                /* Parse with default line numbering */
-               result = cfg_parse_buffer(isc_g_mctx, &buf1, "text1", 0,
+               result = cfg_parse_buffer(&buf1, "text1", 0,
                                          &cfg_type_namedconf, 0, &c1);
                if (must_fail) {
                        assert_int_equal(result, DNS_R_BADTTL);
index 59ea8241125135bcd4d8d12eadd17ad8763fffe5..ad524dcbddb7f803911b28ac303f8b9dc4c96124 100644 (file)
@@ -115,8 +115,8 @@ test__query_source_print(const char *config, const char *expected) {
        isc_buffer_constinit(&buffer, config, strlen(config));
        isc_buffer_add(&buffer, strlen(config));
 
-       result = cfg_parse_buffer(isc_g_mctx, &buffer, "text1", 0,
-                                 &cfg_type_namedconf, 0, &output_conf);
+       result = cfg_parse_buffer(&buffer, "text1", 0, &cfg_type_namedconf, 0,
+                                 &output_conf);
        assert_int_equal(result, ISC_R_SUCCESS);
        assert_non_null(output_conf);
 
index e1e6beb093b6d13ce7d9ec6827614dbc113f8375..d817d3eeaf07e748c1066024defb54ad38d1c55c 100644 (file)
@@ -79,8 +79,8 @@ ISC_RUN_TEST_IMPL(addzoneconf) {
                isc_buffer_constinit(&b, tests[i], strlen(tests[i]));
                isc_buffer_add(&b, strlen(tests[i]));
 
-               result = cfg_parse_buffer(isc_g_mctx, &b, "text1", 0,
-                                         &cfg_type_namedconf, 0, &conf);
+               result = cfg_parse_buffer(&b, "text1", 0, &cfg_type_namedconf,
+                                         0, &conf);
                assert_int_equal(result, ISC_R_SUCCESS);
 
                /*
@@ -130,22 +130,20 @@ ISC_RUN_TEST_IMPL(parse_buffer) {
        /* Parse with default line numbering. */
        isc_buffer_init(&buf, &text[0], sizeof(text) - 1);
        isc_buffer_add(&buf, sizeof(text) - 1);
-       result = cfg_parse_buffer(isc_g_mctx, &buf, "text1", 0,
-                                 &cfg_type_namedconf, 0, &c);
+       result = cfg_parse_buffer(&buf, "text1", 0, &cfg_type_namedconf, 0, &c);
        assert_int_equal(result, ISC_R_FAILURE);
        assert_null(c);
 
        /* Parse with changed line number. */
        isc_buffer_first(&buf);
-       result = cfg_parse_buffer(isc_g_mctx, &buf, "text2", 100,
-                                 &cfg_type_namedconf, 0, &c);
+       result = cfg_parse_buffer(&buf, "text2", 100, &cfg_type_namedconf, 0,
+                                 &c);
        assert_int_equal(result, ISC_R_FAILURE);
        assert_null(c);
 
        /* Parse with changed line number and no name. */
        isc_buffer_first(&buf);
-       result = cfg_parse_buffer(isc_g_mctx, &buf, NULL, 100,
-                                 &cfg_type_namedconf, 0, &c);
+       result = cfg_parse_buffer(&buf, NULL, 100, &cfg_type_namedconf, 0, &c);
        assert_int_equal(result, ISC_R_FAILURE);
        assert_null(c);
 
@@ -262,8 +260,7 @@ view \"_bind\" chaos {\n\
        isc_buffer_init(&buf, conf, sizeof(conf));
        isc_buffer_add(&buf, sizeof(conf) - 1);
 
-       result = cfg_parse_buffer(isc_g_mctx, &buf, "", 0, &cfg_type_namedconf,
-                                 0, &orig);
+       result = cfg_parse_buffer(&buf, "", 0, &cfg_type_namedconf, 0, &orig);
        assert_int_equal(result, ISC_R_SUCCESS);
 
        isc_buffer_init(&dumpb1, dumpbdata1, sizeof(dumpbdata1));