cleanup:
if (config != NULL) {
- cfg_obj_destroy(&config);
+ cfg_obj_detach(&config);
}
if (parser != NULL) {
cleanup:
if (bindkeys != NULL) {
- cfg_obj_destroy(&bindkeys);
+ cfg_obj_detach(&bindkeys);
}
if (parser != NULL) {
cfg_parser_destroy(&parser);
cleanup:
if (pctx != NULL) {
if (file != NULL) {
- cfg_obj_destroy(&file);
+ cfg_obj_detach(&file);
}
cfg_parser_destroy(&pctx);
}
}
dns_kasp_detach(&kasp);
- cfg_obj_destroy(&config);
+ cfg_obj_detach(&config);
cfg_parser_destroy(&parser);
}
} else {
if (ISC_LIST_EMPTY(dns_kasp_keys(*kasp))) {
fatal("dnssec-policy '%s' has no keys configured", ksr->policy);
}
- cfg_obj_destroy(&config);
+ cfg_obj_detach(&config);
cfg_parser_destroy(&parser);
}
cleanup:
if (*conf) {
- cfg_obj_destroy(conf);
+ cfg_obj_detach(conf);
}
out:
free_controlkey(keyid, mctx);
}
if (config != NULL) {
- cfg_obj_destroy(&config);
+ cfg_obj_detach(&config);
}
if (pctx != NULL) {
cfg_parser_destroy(&pctx);
if (cfg_obj_isstring(obj)) {
printf(" geoip-directory: %s\n", cfg_obj_asstring(obj));
}
- cfg_obj_destroy(&config);
+ cfg_obj_detach(&config);
isc_mem_detach(&geoip_mctx);
#endif /* HAVE_GEOIP2 */
}
dns_zone_detach(&zone);
}
if (zoneconf != NULL) {
- cfg_obj_destroy(&zoneconf);
+ cfg_obj_detach(&zoneconf);
}
if (dnsforwarders != NULL) {
dns_forwarders_detach(&dnsforwarders);
cleanup:
if (zoneconf != NULL) {
- cfg_obj_destroy(&zoneconf);
+ cfg_obj_detach(&zoneconf);
}
dns_zone_detach(&zone);
cleanup:
if (zoneconf != NULL) {
- cfg_obj_destroy(&zoneconf);
+ cfg_obj_detach(&zoneconf);
}
return result;
/*
* Destroy the configuration object created in this iteration.
*/
- cfg_obj_destroy(&zconfigobj);
+ cfg_obj_detach(&zconfigobj);
}
if (text != NULL) {
isc_buffer_free(&text);
}
if (zconfigobj != NULL) {
- cfg_obj_destroy(&zconfigobj);
+ cfg_obj_detach(&zconfigobj);
}
mdb_cursor_close(cursor);
UNLOCK(&view->new_zone_lock);
if (zoneconf != NULL) {
- cfg_obj_destroy(&zoneconf);
+ cfg_obj_detach(&zoneconf);
}
if (text != NULL) {
isc_buffer_free(&text);
cfg_parser_destroy(&parser);
}
if (bindkeys != NULL) {
- cfg_obj_destroy(&bindkeys);
+ cfg_obj_detach(&bindkeys);
}
if (config != NULL) {
- cfg_obj_destroy(&config);
+ cfg_obj_detach(&config);
}
return result;
cfg_aclconfctx_detach(&server->aclctx);
}
- cfg_obj_destroy(&named_g_defaultconfig);
+ cfg_obj_detach(&named_g_defaultconfig);
(void)named_server_saventa(server);
}
if (nzf_config != NULL) {
- cfg_obj_destroy(&nzf_config);
+ cfg_obj_detach(&nzf_config);
}
return result;
}
if (zoneconf != NULL) {
- cfg_obj_destroy(&zoneconf);
+ cfg_obj_detach(&zoneconf);
}
if (view != NULL) {
dns_view_detach(&view);
e = UNCONST(elt);
ISC_LIST_UNLINK(*list, e, link);
- cfg_obj_destroy(&e->obj);
+ cfg_obj_detach(&e->obj);
isc_mem_put(pctx->mctx, e, sizeof(*e));
result = ISC_R_SUCCESS;
break;
(void)putnull(text);
}
if (zoneconf != NULL) {
- cfg_obj_destroy(&zoneconf);
+ cfg_obj_detach(&zoneconf);
}
if (view != NULL) {
dns_view_detach(&view);
cleanup:
#ifdef HAVE_LMDB
if (nzconfig != NULL) {
- cfg_obj_destroy(&nzconfig);
+ cfg_obj_detach(&nzconfig);
}
#endif /* HAVE_LMDB */
if (isc_buffer_usedlength(*text) > 0) {
cfg = *cfgp;
if (cfg->config != NULL) {
- cfg_obj_destroy(&cfg->config);
+ cfg_obj_detach(&cfg->config);
}
if (cfg->vconfig != NULL) {
- cfg_obj_destroy(&cfg->vconfig);
+ cfg_obj_detach(&cfg->vconfig);
}
if (cfg->nzf_config != NULL) {
- cfg_obj_destroy(&cfg->nzf_config);
+ cfg_obj_detach(&cfg->nzf_config);
}
if (cfg->aclctx != NULL) {
cleanup:
if (pctx != NULL) {
if (sessionkey != NULL) {
- cfg_obj_destroy(&sessionkey);
+ cfg_obj_detach(&sessionkey);
}
cfg_parser_destroy(&pctx);
}
cleanup:
if (param_obj != NULL) {
- cfg_obj_destroy(¶m_obj);
+ cfg_obj_detach(¶m_obj);
}
if (parser != NULL) {
cfg_parser_destroy(&parser);
cleanup:
if (param_obj != NULL) {
- cfg_obj_destroy(¶m_obj);
+ cfg_obj_detach(¶m_obj);
}
if (parser != NULL) {
cfg_parser_destroy(&parser);
cleanup:
if (param_obj != NULL) {
- cfg_obj_destroy(¶m_obj);
+ cfg_obj_detach(¶m_obj);
}
if (parser != NULL) {
cfg_parser_destroy(&parser);
cleanup:
if (param_obj != NULL) {
- cfg_obj_destroy(¶m_obj);
+ cfg_obj_detach(¶m_obj);
}
if (parser != NULL) {
cfg_parser_destroy(&parser);
cleanup:
if (synthrecordcfg != NULL) {
- cfg_obj_destroy(&synthrecordcfg);
+ cfg_obj_detach(&synthrecordcfg);
}
if (parser != NULL) {
isccc_ccmsg_invalidate(&rndc_ccmsg);
- cfg_obj_destroy(&config);
+ cfg_obj_detach(&config);
cfg_parser_destroy(&pctx);
isc_mem_put(isc_g_mctx, args, argslen);
}
if (syncplugincfg != NULL) {
- cfg_obj_destroy(&syncplugincfg);
+ cfg_obj_detach(&syncplugincfg);
}
if (parser != NULL) {
cfg_print(cfg, output, NULL);
- cfg_obj_destroy(&cfg);
+ cfg_obj_detach(&cfg);
cfg_parser_destroy(&pctx);
}
* Return true iff 'obj' is of type 'type'.
*/
-void
-cfg_obj_attach(cfg_obj_t *src, cfg_obj_t **dest);
-/*%<
- * Reference a configuration object.
- */
-
-void
-cfg_obj_destroy(cfg_obj_t **obj);
-/*%<
- * Delete a reference to a configuration object; destroy the object if
- * there are no more references.
- *
- * Require:
- * \li '*obj' is a valid cfg_obj_t.
- * \li 'mctx' is a valid isc_mem_t.
- */
-
void
cfg_obj_log(const cfg_obj_t *obj, int level, const char *fmt, ...)
ISC_FORMAT_PRINTF(3, 4);
* 'list'
* \li first 'callback' return value which was not #ISC_R_SUCCESS otherwise
*/
+
+ISC_REFCOUNT_DECL(cfg_obj);
} while (0)
/*% Clean up a configuration object if non-NULL. */
-#define CLEANUP_OBJ(obj) \
- do { \
- if ((obj) != NULL) \
- cfg_obj_destroy(&(obj)); \
+#define CLEANUP_OBJ(obj) \
+ do { \
+ if ((obj) != NULL) \
+ cfg_obj_detach(&(obj)); \
} while (0)
/*%
} while (0)
/* Clean up a configuration object if non-NULL. */
-#define CLEANUP_OBJ(obj) \
- do { \
- if ((obj) != NULL) \
- cfg_obj_destroy(&(obj)); \
+#define CLEANUP_OBJ(obj) \
+ do { \
+ if ((obj) != NULL) \
+ cfg_obj_detach(&(obj)); \
} while (0)
/* cfg_obj_t magic number */
static void
free_listelt(isc_mem_t *mctx, cfg_listelt_t *elt) {
if (elt->obj != NULL) {
- cfg_obj_destroy(&elt->obj);
+ cfg_obj_detach(&elt->obj);
}
isc_mem_put(mctx, elt, sizeof(*elt));
}
CHECK(parser_openfile(pctx, g.gl_pathv[i]));
}
- cfg_obj_destroy(&includename);
+ cfg_obj_detach(&includename);
globfree(&g);
goto redo;
*/
CHECK(cfg_parse_obj(pctx, &cfg_type_unsupported,
&eltobj));
- cfg_obj_destroy(&eltobj);
+ cfg_obj_detach(&eltobj);
CHECK(parse_semicolon(pctx));
continue;
}
UNUSED(type);
UNUSED(userarg);
- cfg_obj_destroy(&obj);
+ cfg_obj_detach(&obj);
}
static isc_result_t
/*
* Destroy 'obj', a configuration object created in 'pctx'.
*/
-void
-cfg_obj_destroy(cfg_obj_t **objp) {
- REQUIRE(objp != NULL && *objp != NULL);
- REQUIRE((*objp)->magic == CFGOBJ_MAGIC);
-
- cfg_obj_t *obj = *objp;
- *objp = NULL;
-
- if (isc_refcount_decrement(&obj->references) == 1) {
- obj->magic = 0;
-
- if (obj->file != NULL) {
- cfg_obj_destroy(&obj->file);
- }
+static void
+cfg__obj_destroy(cfg_obj_t *obj) {
+ REQUIRE(obj != NULL);
+ REQUIRE(obj->magic == CFGOBJ_MAGIC);
- obj->type->rep->free(obj);
+ obj->magic = 0;
- isc_refcount_destroy(&obj->references);
- isc_mem_putanddetach(&obj->mctx, obj, sizeof(cfg_obj_t));
+ if (obj->file != NULL) {
+ cfg_obj_detach(&obj->file);
}
-}
-void
-cfg_obj_attach(cfg_obj_t *src, cfg_obj_t **dest) {
- REQUIRE(src != NULL);
- REQUIRE(dest != NULL && *dest == NULL);
+ obj->type->rep->free(obj);
- isc_refcount_increment(&src->references);
- *dest = src;
+ isc_refcount_destroy(&obj->references);
+ isc_mem_putanddetach(&obj->mctx, obj, sizeof(cfg_obj_t));
}
+ISC_REFCOUNT_IMPL(cfg_obj, cfg__obj_destroy);
+
static void
free_noop(cfg_obj_t *obj) {
UNUSED(obj);
assert_int_equal(cmp, 0);
}
- cfg_obj_destroy(&c1);
+ cfg_obj_detach(&c1);
cfg_parser_destroy(&p1);
}
}
output_conf->type->print(&pctx, output_conf);
assert_text(expected);
- cfg_obj_destroy(parser, &output_conf);
+ cfg_obj_detach(parser, &output_conf);
cfg_parser_reset(parser);
cfg_parser_destroy(&parser);
}
strlcat(buf, ";", sizeof(buf));
assert_string_equal(tests[i], buf);
- cfg_obj_destroy(&conf);
+ cfg_obj_detach(&conf);
cfg_parser_reset(p);
}
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(p2->line, 104);
- cfg_obj_destroy(&c1);
- cfg_obj_destroy(&c2);
+ cfg_obj_detach(&c1);
+ cfg_obj_detach(&c2);
cfg_parser_destroy(&p1);
cfg_parser_destroy(&p2);