diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index 7dcb002376..482bcec8d5 100644 --- a/lib/dns/include/dns/zone.h +++ b/lib/dns/include/dns/zone.h @@ -120,7 +120,7 @@ dns_result_t dns_zone_setorigin(dns_zone_t *zone, char *origin); * All possible values from dns_name_fromtext(). */ -dns_result_t dns_zone_getorigin(dns_zone_t *zone, isc_mem_t *mctx, dns_name_t *name); +dns_name_t * dns_zone_getorigin(dns_zone_t *zone); /* * Returns the value of the origin. * diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 1efbf14e6d..91f5b548ec 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: zone.c,v 1.19 1999/10/13 23:32:02 marka Exp $ */ + /* $Id: zone.c,v 1.20 1999/10/14 00:46:58 marka Exp $ */ #include @@ -2274,7 +2274,7 @@ isc_result_t dns_zone_callback(dns_c_ctx_t *cfg, dns_c_zone_t *czone, dns_c_view_t *cview, void *uap) { dns_zone_callbackarg_t *cba = uap; - dns_name_t name; + dns_name_t *name = NULL; dns_view_t *oldview = NULL; dns_zone_t *oldzone = NULL; dns_view_t *newview = NULL; @@ -2287,11 +2287,6 @@ dns_zone_callback(dns_c_ctx_t *cfg, dns_c_zone_t *czone, dns_c_view_t *cview, REQUIRE(czone != NULL); REQUIRE(cba != NULL); - /* - * Initialization. - */ - dns_name_init(&name, NULL); - /* * Find views by name. */ @@ -2335,12 +2330,10 @@ dns_zone_callback(dns_c_ctx_t *cfg, dns_c_zone_t *czone, dns_c_view_t *cview, /* * Find zone in mount table. */ - result = dns_zone_getorigin(newzone, cba->mctx, &name); - if (result != DNS_R_SUCCESS) - goto cleanup; + name = dns_zone_getorigin(newzone); dns_zone_print(newzone); - result = dns_zt_find(newview->zonetable, &name, NULL, &tmpzone); + result = dns_zt_find(newview->zonetable, name, NULL, &tmpzone); if (result == DNS_R_SUCCESS) { printf("zone already exists=\n"); result = DNS_R_EXISTS; @@ -2349,7 +2342,7 @@ dns_zone_callback(dns_c_ctx_t *cfg, dns_c_zone_t *czone, dns_c_view_t *cview, goto cleanup; if (oldview != NULL) - result = dns_zt_find(oldview->zonetable, &name, NULL, &oldzone); + result = dns_zt_find(oldview->zonetable, name, NULL, &oldzone); else result = DNS_R_NOTFOUND; @@ -2374,8 +2367,6 @@ dns_zone_callback(dns_c_ctx_t *cfg, dns_c_zone_t *czone, dns_c_view_t *cview, } cleanup: - if (dns_name_dynamic(&name)) - dns_name_free(&name, cba->mctx); if (tmpzone != NULL) dns_zone_detach(&tmpzone); if (newzone != NULL) @@ -2956,11 +2947,11 @@ dns_zonetype_t dns_zone_gettype(dns_zone_t *zone) { return (zone->type); } -dns_result_t -dns_zone_getorigin(dns_zone_t *zone, isc_mem_t *mctx, dns_name_t *name) { +dns_name_t * +dns_zone_getorigin(dns_zone_t *zone) { REQUIRE(DNS_ZONE_VALID(zone)); - return (dns_name_dup(&zone->origin, mctx, name)); + return (&zone->origin); } isc_task_t *dns_zone_gettask(dns_zone_t *zone) { diff --git a/lib/dns/zt.c b/lib/dns/zt.c index e186a37e6c..a86439013e 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -88,60 +88,38 @@ isc_result_t dns_zt_mount(dns_zt_t *zt, dns_zone_t *zone) { isc_result_t result; dns_zone_t *dummy = NULL; - dns_name_t name; + dns_name_t *name; REQUIRE(VALID_ZT(zt)); - /* - * XXXRTH I don't understand why dns_zone_getorigin() is - * returning a dup'd name. I think we should make it - * return a pointer to the name in the zone structure - * and let the caller dup it if they need to. - */ - dns_name_init(&name, NULL); - result = dns_zone_getorigin(zone, zt->mctx, &name); - if (result != DNS_R_SUCCESS) - return (result); + name = dns_zone_getorigin(zone); RWLOCK(&zt->rwlock, isc_rwlocktype_write); - result = dns_rbt_addname(zt->table, &name, zone); + result = dns_rbt_addname(zt->table, name, zone); if (result == ISC_R_SUCCESS) dns_zone_attach(zone, &dummy); RWUNLOCK(&zt->rwlock, isc_rwlocktype_write); - dns_name_free(&name, zt->mctx); - return (result); } isc_result_t dns_zt_unmount(dns_zt_t *zt, dns_zone_t *zone) { isc_result_t result; - dns_name_t name; + dns_name_t *name; REQUIRE(VALID_ZT(zt)); - /* - * XXXRTH I don't understand why dns_zone_getorigin() is - * returning a dup'd name. I think we should make it - * return a pointer to the name in the zone structure - * and let the caller dup it if they need to. - */ - dns_name_init(&name, NULL); - result = dns_zone_getorigin(zone, zt->mctx, &name); - if (result != DNS_R_SUCCESS) - return (result); + name = dns_zone_getorigin(zone); RWLOCK(&zt->rwlock, isc_rwlocktype_write); - result = dns_rbt_deletename(zt->table, &name, ISC_FALSE); + result = dns_rbt_deletename(zt->table, name, ISC_FALSE); RWUNLOCK(&zt->rwlock, isc_rwlocktype_write); - dns_name_free(&name, zt->mctx); - return (result); }