2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

- Removed config *_delete functions on structures that use reference

counting and replaced with *_detach.
- Changed config *_attach functions to return the new attached value through
  the paramater list rather than as a return value.
- Changed config *_delete functions to no longer allow deletion of a null
  pointer
- Changed calls to the config *_delete functions to make sure no null
  pointers were passed in.
- Changed use of the config *_attach function to match new signature.
This commit is contained in:
James Brister
1999-11-17 21:52:32 +00:00
parent 715799a30e
commit 292031c9fc
15 changed files with 262 additions and 211 deletions

View File

@@ -74,11 +74,9 @@ dns_c_acltable_delete(isc_log_t *lctx,
isc_mem_t *mem;
REQUIRE(table != NULL);
REQUIRE(*table != NULL);
acltable = *table;
if (acltable == NULL) {
return (ISC_R_SUCCESS);
}
REQUIRE(DNS_CONFACLTABLE_VALID(acltable));
@@ -291,7 +289,7 @@ dns_c_acl_setipml(isc_log_t *lctx, dns_c_acl_t *acl,
REQUIRE(ipml != NULL);
if (acl->ipml != NULL) {
dns_c_ipmatchlist_delete(lctx, &acl->ipml);
dns_c_ipmatchlist_detach(lctx, &acl->ipml);
}
if (deepcopy) {
@@ -405,11 +403,9 @@ acl_delete(isc_log_t *lctx, dns_c_acl_t **aclptr)
isc_mem_t *mem;
REQUIRE(aclptr != NULL);
REQUIRE(*aclptr != NULL);
acl = *aclptr;
if (acl == NULL) {
return (ISC_R_SUCCESS);
}
REQUIRE(DNS_CONFACL_VALID(acl));
@@ -418,8 +414,12 @@ acl_delete(isc_log_t *lctx, dns_c_acl_t **aclptr)
acl->mytable = NULL;
isc_mem_free(mem, acl->name);
res = dns_c_ipmatchlist_delete(lctx, &acl->ipml);
if (acl->ipml != NULL)
res = dns_c_ipmatchlist_detach(lctx, &acl->ipml);
else
res = ISC_R_SUCCESS;
acl->magic = 0;
isc_mem_put(mem, acl, sizeof *acl);

View File

@@ -100,11 +100,9 @@ dns_c_ctrllist_delete(isc_log_t *lctx,
dns_c_ctrllist_t *clist;
REQUIRE(list != NULL);
REQUIRE(*list != NULL);
clist = *list;
if (clist == NULL) {
return (ISC_R_SUCCESS);
}
REQUIRE(DNS_CONFCTLLIST_VALID(clist));
@@ -209,11 +207,9 @@ dns_c_ctrl_delete(isc_log_t *lctx,
dns_c_ctrl_t *ctrl;
REQUIRE(control != NULL);
REQUIRE(*control != NULL);
ctrl = *control;
if (ctrl == NULL) {
return (ISC_R_SUCCESS);
}
REQUIRE(DNS_CONFCTL_VALID(ctrl));
@@ -221,8 +217,11 @@ dns_c_ctrl_delete(isc_log_t *lctx,
switch (ctrl->control_type) {
case dns_c_inet_control:
res = dns_c_ipmatchlist_delete(lctx,
&ctrl->u.inet_v.matchlist);
if (ctrl->u.inet_v.matchlist != NULL)
res = dns_c_ipmatchlist_detach(lctx,
&ctrl->u.inet_v.matchlist);
else
res = ISC_R_SUCCESS;
break;
case dns_c_unix_control:

View File

@@ -195,15 +195,32 @@ dns_c_ctx_delete(isc_log_t *lctx,
REQUIRE(c->mem != NULL);
dns_c_ctx_optionsdelete(lctx, &c->options);
dns_c_ctrllist_delete(lctx, &c->controls);
dns_c_srvlist_delete(lctx, &c->servers);
dns_c_acltable_delete(lctx, &c->acls);
dns_c_kdeflist_delete(lctx, &c->keydefs);
dns_c_zonelist_delete(lctx, &c->zlist);
dns_c_tkeylist_delete(lctx, &c->trusted_keys);
dns_c_logginglist_delete(lctx, &c->logging);
dns_c_viewtable_delete(lctx, &c->views);
if (c->options != NULL)
dns_c_ctx_optionsdelete(lctx, &c->options);
if (c->controls != NULL)
dns_c_ctrllist_delete(lctx, &c->controls);
if (c->servers != NULL)
dns_c_srvlist_delete(lctx, &c->servers);
if (c->acls != NULL)
dns_c_acltable_delete(lctx, &c->acls);
if (c->keydefs != NULL)
dns_c_kdeflist_delete(lctx, &c->keydefs);
if (c->zlist != NULL)
dns_c_zonelist_delete(lctx, &c->zlist);
if (c->trusted_keys != NULL)
dns_c_tkeylist_delete(lctx, &c->trusted_keys);
if (c->logging != NULL)
dns_c_logginglist_delete(lctx, &c->logging);
if (c->views != NULL)
dns_c_viewtable_delete(lctx, &c->views);
isc_mem_put(c->mem, c, sizeof *c);
*cfg = NULL;
@@ -3051,7 +3068,7 @@ dns_c_ctx_optionsdelete(isc_log_t *lctx,
dns_c_options_t **opts)
{
dns_c_options_t *options;
isc_result_t r;
isc_result_t r, result;
REQUIRE(opts != NULL);
@@ -3098,39 +3115,68 @@ dns_c_ctx_optionsdelete(isc_log_t *lctx,
isc_mem_free(options->mem, options->tkeydhkeycp);
}
r = dns_c_ipmatchlist_delete(lctx, &options->queryacl);
if (r != ISC_R_SUCCESS) return (r);
result = ISC_R_SUCCESS;
r = dns_c_ipmatchlist_delete(lctx, &options->transferacl);
if (r != ISC_R_SUCCESS) return (r);
if (options->queryacl != NULL) {
r = dns_c_ipmatchlist_detach(lctx, &options->queryacl);
if (r != ISC_R_SUCCESS)
result = r;
}
r = dns_c_ipmatchlist_delete(lctx, &options->recursionacl);
if (r != ISC_R_SUCCESS) return (r);
if (options->transferacl != NULL) {
r = dns_c_ipmatchlist_detach(lctx, &options->transferacl);
if (r != ISC_R_SUCCESS)
result = r;
}
r = dns_c_ipmatchlist_delete(lctx, &options->blackhole);
if (r != ISC_R_SUCCESS) return (r);
if (options->recursionacl != NULL) {
r = dns_c_ipmatchlist_detach(lctx, &options->recursionacl);
if (r != ISC_R_SUCCESS)
result = r;
}
r = dns_c_ipmatchlist_delete(lctx, &options->topology);
if (r != ISC_R_SUCCESS) return (r);
if (options->blackhole != NULL) {
r = dns_c_ipmatchlist_detach(lctx, &options->blackhole);
if (r != ISC_R_SUCCESS)
result = r;
}
if (options->topology != NULL) {
r = dns_c_ipmatchlist_detach(lctx, &options->topology);
if (r != ISC_R_SUCCESS)
result = r;
}
if (options->sortlist != NULL) {
r = dns_c_ipmatchlist_detach(lctx, &options->sortlist);
if (r != ISC_R_SUCCESS)
result = r;
}
if (options->listens != NULL) {
r = dns_c_lstnlist_delete(lctx, &options->listens);
if (r != ISC_R_SUCCESS)
result = r;
}
if (options->ordering != NULL) {
r = dns_c_rrsolist_delete(lctx, &options->ordering);
if (r != ISC_R_SUCCESS)
result = r;
}
if (options->forwarders != NULL) {
r = dns_c_ipmatchlist_detach(lctx, &options->forwarders);
if (r != ISC_R_SUCCESS)
result = r;
}
r = dns_c_ipmatchlist_delete(lctx, &options->sortlist);
if (r != ISC_R_SUCCESS) return (r);
r = dns_c_lstnlist_delete(lctx, &options->listens);
if (r != ISC_R_SUCCESS) return (r);
r = dns_c_rrsolist_delete(lctx, &options->ordering);
if (r != ISC_R_SUCCESS) return (r);
r = dns_c_ipmatchlist_delete(lctx, &options->forwarders);
if (r != ISC_R_SUCCESS) return (r);
*opts = NULL;
options->magic = 0;
isc_mem_put(options->mem, options, sizeof *options);
return (ISC_R_SUCCESS);
return (result);
}
@@ -3493,7 +3539,7 @@ cfg_set_iplist(isc_log_t *lctx,
}
} else {
if (*fieldaddr != NULL) {
res = dns_c_ipmatchlist_delete(lctx, fieldaddr);
res = dns_c_ipmatchlist_detach(lctx, fieldaddr);
if (res != ISC_R_SUCCESS) {
return (res);
}

View File

@@ -99,11 +99,8 @@ dns_c_ipmatchelement_delete(isc_log_t *lctx,
REQUIRE(mem != NULL);
REQUIRE(ipme != NULL);
REQUIRE(*ipme != NULL);
if (*ipme == NULL) {
return (ISC_R_SUCCESS);
}
elem = *ipme;
REQUIRE(DNS_IPMELEM_VALID(elem));
@@ -118,7 +115,9 @@ dns_c_ipmatchelement_delete(isc_log_t *lctx,
case dns_c_ipmatch_indirect:
INSIST(elem->u.indirect.list != NULL);
dns_c_ipmatchlist_delete(lctx, &elem->u.indirect.list);
if (elem->u.indirect.list != NULL)
dns_c_ipmatchlist_detach(lctx, &elem->u.indirect.list);
if (elem->u.indirect.refname.base != NULL) {
isc_mem_put(mem, elem->u.indirect.refname.base,
elem->u.indirect.refname.length);
@@ -330,7 +329,7 @@ dns_c_ipmatchindirect_new(isc_log_t *lctx,
strcpy(ime->u.indirect.refname.base, name);
}
} else {
dns_c_ipmatchlist_delete(lctx, &iml_copy);
dns_c_ipmatchlist_detach(lctx, &iml_copy);
}
*result = ime;
@@ -481,7 +480,7 @@ dns_c_ipmatchlist_new(isc_log_t *lctx,
isc_result_t
dns_c_ipmatchlist_delete(isc_log_t *lctx,
dns_c_ipmatchlist_detach(isc_log_t *lctx,
dns_c_ipmatchlist_t **ml)
{
dns_c_ipmatchelement_t *ime;
@@ -490,11 +489,9 @@ dns_c_ipmatchlist_delete(isc_log_t *lctx,
isc_mem_t *mem;
REQUIRE(ml != NULL);
REQUIRE(*ml != NULL);
iml = *ml;
if (iml == NULL) {
return (ISC_R_SUCCESS);
}
*ml = NULL;
REQUIRE(DNS_IPMLIST_VALID(iml));
@@ -522,19 +519,19 @@ dns_c_ipmatchlist_delete(isc_log_t *lctx,
}
dns_c_ipmatchlist_t *
dns_c_ipmatchlist_attach(isc_log_t *lctx,
dns_c_ipmatchlist_t *ipml)
void
dns_c_ipmatchlist_attach(isc_log_t *lctx, dns_c_ipmatchlist_t *source,
dns_c_ipmatchlist_t **target)
{
(void) lctx;
REQUIRE(DNS_IPMLIST_VALID(ipml));
REQUIRE(DNS_IPMLIST_VALID(source));
INSIST(ipml->refcount > 0);
INSIST(source->refcount > 0);
ipml->refcount++;
return (ipml);
source->refcount++;
*target = source;
}
@@ -586,7 +583,7 @@ dns_c_ipmatchlist_copy(isc_log_t *lctx, isc_mem_t *mem,
while (ime != NULL) {
result = dns_c_ipmatchelement_copy(lctx, mem, &ptr, ime);
if (result != ISC_R_SUCCESS) {
dns_c_ipmatchlist_delete(lctx, &newlist);
dns_c_ipmatchlist_detach(lctx, &newlist);
return (result);
}
@@ -798,7 +795,7 @@ dns_c_iplist_new(isc_log_t *lctx,
isc_result_t
dns_c_iplist_delete(isc_log_t *lctx,
dns_c_iplist_detach(isc_log_t *lctx,
dns_c_iplist_t **list)
{
dns_c_iplist_t *l ;
@@ -806,11 +803,9 @@ dns_c_iplist_delete(isc_log_t *lctx,
(void) lctx;
REQUIRE(list != NULL);
REQUIRE(*list != NULL);
l = *list;
if (l == NULL) {
return (ISC_R_SUCCESS);
}
REQUIRE(DNS_IPLIST_VALID(l));
INSIST(l->refcount > 0);
@@ -828,18 +823,17 @@ dns_c_iplist_delete(isc_log_t *lctx,
}
dns_c_iplist_t *
dns_c_iplist_attach(isc_log_t *lctx,
dns_c_iplist_t *list)
void
dns_c_iplist_attach(isc_log_t *lctx, dns_c_iplist_t *source,
dns_c_iplist_t **target)
{
(void) lctx;
REQUIRE(DNS_IPLIST_VALID(list));
INSIST(list->refcount > 0);
REQUIRE(DNS_IPLIST_VALID(source));
INSIST(source->refcount > 0);
list->refcount++;
return (list);
source->refcount++;
*target = source;
}

View File

@@ -65,11 +65,9 @@ dns_c_kdeflist_delete(isc_log_t *lctx,
isc_result_t res;
REQUIRE(list != NULL);
REQUIRE(*list != NULL);
l = *list;
if (l == NULL) {
return (ISC_R_SUCCESS);
}
kd = ISC_LIST_HEAD(l->keydefs);
while (kd != NULL) {
@@ -277,11 +275,9 @@ dns_c_kdef_delete(isc_log_t *lctx, dns_c_kdef_t **keydef)
(void)lctx;
REQUIRE(keydef != NULL);
REQUIRE(*keydef != NULL);
kd = *keydef;
if (kd == NULL) {
return (ISC_R_SUCCESS);
}
mem = kd->mylist->mem;
@@ -451,11 +447,9 @@ dns_c_kidlist_delete(isc_log_t *lctx,
isc_result_t r;
REQUIRE(list != NULL);
REQUIRE(*list != NULL);
l = *list;
if (l == NULL) {
return (ISC_R_SUCCESS);
}
ki = ISC_LIST_HEAD(l->keyids);
while (ki != NULL) {
@@ -483,11 +477,11 @@ keyid_delete(isc_log_t *lctx,
dns_c_kid_t *ki;
(void)lctx;
REQUIRE(keyid != NULL);
REQUIRE(*keyid != NULL);
ki = *keyid;
if (ki == NULL) {
return (ISC_R_SUCCESS);
}
isc_mem_free(ki->mylist->mem, ki->keyid);
isc_mem_put(ki->mylist->mem, ki, sizeof *ki);
@@ -651,11 +645,9 @@ dns_c_pubkey_delete(isc_log_t *lctx,
(void)lctx;
REQUIRE(pubkey != NULL);
REQUIRE(*pubkey != NULL);
pkey = *pubkey;
if (pkey == NULL) {
return (ISC_R_SUCCESS);
}
if (pkey->key != NULL) {
isc_mem_free(pkey->mem, pkey->key);
@@ -749,11 +741,9 @@ dns_c_tkeylist_delete(isc_log_t *lctx,
isc_result_t res;
REQUIRE(list != NULL);
REQUIRE(*list != NULL);
l = *list;
if (l == NULL) {
return (ISC_R_SUCCESS);
}
tkey = ISC_LIST_HEAD(l->tkeylist);
while (tkey != NULL) {
@@ -922,11 +912,9 @@ dns_c_tkey_delete(isc_log_t *lctx,
dns_c_tkey_t *tk;
REQUIRE(tkey != NULL);
REQUIRE(*tkey != NULL);
tk = *tkey;
if (tk == NULL) {
return (ISC_R_SUCCESS);
}
isc_mem_free(tk->mem, tk->domain);

View File

@@ -91,11 +91,9 @@ dns_c_logginglist_delete(isc_log_t *lctx,
isc_result_t res;
REQUIRE(list != NULL);
REQUIRE(*list != NULL);
l = *list;
if (l == NULL) {
return (ISC_R_SUCCESS);
}
chan = ISC_LIST_HEAD(l->channels);
while (chan != NULL) {
@@ -499,11 +497,9 @@ dns_c_logchan_delete(isc_log_t *lctx,
(void) lctx;
REQUIRE(channel != NULL);
REQUIRE(*channel != NULL);
logc = *channel;
if (logc == NULL) {
return (ISC_R_SUCCESS);
}
isc_mem_free(logc->mem, logc->name);
@@ -1166,6 +1162,7 @@ dns_c_logcat_delete(isc_log_t *lctx,
(void) lctx;
REQUIRE(logcat != NULL);
REQUIRE(*logcat != NULL);
logc = *logcat;
if (logc == NULL) {

View File

@@ -66,23 +66,22 @@ dns_c_lstnon_delete(isc_log_t *lctx, dns_c_lstnon_t **listen)
isc_result_t r;
REQUIRE(listen != NULL);
REQUIRE(*listen != NULL);
lo = *listen;
if (lo == NULL) {
return (ISC_R_SUCCESS);
}
CHECK_LISTEN(lo);
r = dns_c_ipmatchlist_delete(lctx, &lo->iml);
if (r != ISC_R_SUCCESS) {
return (r);
}
if (lo->iml != NULL) {
r = dns_c_ipmatchlist_detach(lctx, &lo->iml);
} else
r = ISC_R_SUCCESS;
isc_mem_put(lo->mem, lo, sizeof *lo);
*listen = NULL;
return (ISC_R_SUCCESS);
return (r);
}
@@ -94,11 +93,16 @@ dns_c_lstnon_setiml(isc_log_t *lctx, dns_c_lstnon_t *listen,
REQUIRE(listen != NULL);
REQUIRE(iml != NULL);
result = dns_c_ipmatchlist_delete(lctx, &listen->iml);
if (result != ISC_R_SUCCESS) {
return (result);
if (listen->iml != NULL) {
result = dns_c_ipmatchlist_detach(lctx, &listen->iml);
if (result != ISC_R_SUCCESS) {
return (result);
}
} else {
result = ISC_R_SUCCESS;
}
if (deepcopy) {
result = dns_c_ipmatchlist_copy(lctx, listen->mem,
@@ -151,11 +155,9 @@ dns_c_lstnlist_delete(isc_log_t *lctx, dns_c_lstnlist_t **llist)
isc_result_t r;
REQUIRE(llist != NULL);
REQUIRE(*llist != NULL);
ll = *llist;
if (ll == NULL) {
return (ISC_R_SUCCESS);
}
CHECK_LLIST(ll);

View File

@@ -17,7 +17,7 @@
*/
#if !defined(lint) && !defined(SABER)
static char rcsid[] = "$Id: confparser.y,v 1.24 1999/11/02 15:49:42 brister Exp $";
static char rcsid[] = "$Id: confparser.y,v 1.25 1999/11/17 21:52:29 brister Exp $";
#endif /* not lint */
#include <config.h>
@@ -2201,7 +2201,7 @@ address_match_simple: ip_address
}
}
dns_c_ipmatchlist_delete(logcontext, &$2);
dns_c_ipmatchlist_detach(logcontext, &$2);
$$ = ime;
}
@@ -2504,7 +2504,7 @@ zone_stmt: L_ZONE domain_name optional_class L_LBRACE L_TYPE zone_type L_EOS
tmpres = dns_c_zonelist_addzone(logcontext,
currcfg->zlist, zone);
if (tmpres != ISC_R_SUCCESS) {
dns_c_zone_delete(logcontext, &zone);
dns_c_zone_detach(logcontext, &zone);
isc_log_write(logcontext, DNS_LOGCATEGORY_CONFIG,
DNS_LOGMODULE_CONFIG,
ISC_LOG_CRITICAL,
@@ -2896,7 +2896,7 @@ zone_option: L_FILE L_QSTRING
default:
parser_error(ISC_FALSE,
"Failed to set zone forwarders.");
dns_c_iplist_delete(logcontext, &$3);
dns_c_iplist_detach(logcontext, &$3);
break;
}
}

View File

@@ -135,11 +135,9 @@ dns_c_rrsolist_delete(isc_log_t *lctx, dns_c_rrsolist_t **list)
isc_result_t r;
REQUIRE(list != NULL);
REQUIRE(*list != NULL);
l = *list;
if (l == NULL) {
return (ISC_R_SUCCESS);
}
elem = ISC_LIST_HEAD(l->elements);
while (elem != NULL) {
@@ -169,11 +167,9 @@ dns_c_rrso_delete(isc_log_t *lctx, dns_c_rrso_t **order)
(void)lctx;
REQUIRE(order != NULL);
REQUIRE(*order != NULL);
oldo = *order;
if (oldo == NULL) {
return (ISC_R_SUCCESS);
}
REQUIRE(oldo->name != NULL);
isc_mem_free(oldo->mem, oldo->name);

View File

@@ -70,11 +70,9 @@ dns_c_srvlist_delete(isc_log_t *lctx, dns_c_srvlist_t **list)
isc_result_t r;
REQUIRE(list != NULL);
REQUIRE(*list != NULL);
l = *list;
if (l == NULL) {
return (ISC_R_SUCCESS);
}
server = ISC_LIST_HEAD(l->elements);
while (server != NULL) {
@@ -199,15 +197,15 @@ dns_c_srv_delete(isc_log_t *lctx, dns_c_srv_t **server)
isc_mem_t *mem;
REQUIRE(server != NULL);
REQUIRE(*server != NULL);
serv = *server;
if (serv == NULL) {
return (ISC_R_SUCCESS);
}
mem = serv->mem;
serv->mem = NULL;
dns_c_kidlist_delete(lctx, &serv->keys);
if (serv->keys != NULL)
dns_c_kidlist_delete(lctx, &serv->keys);
isc_mem_put(mem, serv, sizeof *serv);

View File

@@ -64,11 +64,9 @@ dns_c_viewtable_delete(isc_log_t *lctx,
dns_c_viewtable_t *table;
REQUIRE(viewtable != NULL);
REQUIRE(*viewtable != NULL);
table = *viewtable;
if (table == NULL) {
return (ISC_R_SUCCESS);
}
*viewtable = NULL;
dns_c_viewtable_clear(lctx, table);
@@ -281,7 +279,7 @@ dns_c_view_setallowquery(isc_log_t *lctx,
REQUIRE(ipml != NULL);
if (view->allowquery != NULL) {
dns_c_ipmatchlist_delete(lctx, &view->allowquery);
dns_c_ipmatchlist_detach(lctx, &view->allowquery);
}
if (deepcopy) {
@@ -332,16 +330,14 @@ dns_c_view_delete(isc_log_t *lctx,
dns_c_view_t *view;
REQUIRE(viewptr != NULL);
if (*viewptr == NULL) {
return (ISC_R_SUCCESS);
}
REQUIRE(*viewptr != NULL);
view = *viewptr;
isc_mem_free(view->mem, view->name);
dns_c_ipmatchlist_delete(lctx, &view->allowquery);
if (view->allowquery != NULL)
dns_c_ipmatchlist_detach(lctx, &view->allowquery);
isc_mem_put(view->mem, view, sizeof *view);

View File

@@ -151,11 +151,9 @@ dns_c_zonelist_delete(isc_log_t *lctx, dns_c_zonelist_t **zlist)
isc_result_t res;
REQUIRE(zlist != NULL);
REQUIRE(*zlist != NULL);
list = *zlist;
if (list == NULL) {
return (ISC_R_SUCCESS);
}
zoneelem = ISC_LIST_HEAD(list->zones);
while (zoneelem != NULL) {
@@ -276,7 +274,7 @@ dns_c_zonelist_rmbyname(isc_log_t *lctx, dns_c_zonelist_t *zlist,
if (zoneelem != NULL) {
ISC_LIST_UNLINK(zlist->zones, zoneelem, next);
res = dns_c_zone_delete(lctx, &zoneelem->thezone);
res = dns_c_zone_detach(lctx, &zoneelem->thezone);
isc_mem_put(zlist->mem, zoneelem, sizeof *zoneelem);
} else {
res = ISC_R_NOTFOUND;
@@ -307,7 +305,7 @@ dns_c_zonelist_rmzone(isc_log_t *lctx, dns_c_zonelist_t *zlist,
if (zoneelem != NULL) {
ISC_LIST_UNLINK(zlist->zones, zoneelem, next);
res = dns_c_zone_delete(lctx, &zoneelem->thezone);
res = dns_c_zone_detach(lctx, &zoneelem->thezone);
isc_mem_put(zlist->mem, zoneelem, sizeof *zoneelem);
} else {
res = ISC_R_NOTFOUND;
@@ -439,11 +437,15 @@ dns_c_zone_new(isc_log_t *lctx, isc_mem_t *mem,
isc_result_t
dns_c_zone_delete(isc_log_t *lctx, dns_c_zone_t **zone)
dns_c_zone_detach(isc_log_t *lctx, dns_c_zone_t **zone)
{
dns_c_zone_t *zoneptr = *zone;
dns_c_zone_t *zoneptr;
isc_result_t res = ISC_R_SUCCESS;
REQUIRE(zone != NULL);
REQUIRE(*zone != NULL);
zoneptr = *zone;
*zone = NULL;
REQUIRE(zoneptr->refcount > 0);
@@ -458,17 +460,17 @@ dns_c_zone_delete(isc_log_t *lctx, dns_c_zone_t **zone)
void
dns_c_zone_attach(isc_log_t *lctx, dns_c_zone_t *zone,
dns_c_zone_t **newzone)
dns_c_zone_attach(isc_log_t *lctx, dns_c_zone_t *source,
dns_c_zone_t **target)
{
REQUIRE(zone != NULL);
REQUIRE(newzone != NULL);
REQUIRE(source != NULL);
REQUIRE(target != NULL);
(void) lctx;
zone->refcount++;
source->refcount++;
*newzone = zone;
*target = source;
}
@@ -2941,6 +2943,7 @@ zone_delete(isc_log_t *lctx, dns_c_zone_t **zone)
isc_result_t res = ISC_R_SUCCESS;
REQUIRE(zone != NULL);
REQUIRE(*zone != NULL);
z = *zone;
@@ -2986,10 +2989,17 @@ master_zone_clear(isc_log_t *lctx, isc_mem_t *mem, dns_c_masterzone_t *mzone)
isc_mem_free(mem, mzone->file);
}
dns_c_ipmatchlist_delete(lctx, &mzone->allow_update);
dns_c_ipmatchlist_delete(lctx, &mzone->allow_query);
dns_c_ipmatchlist_delete(lctx, &mzone->allow_transfer);
dns_c_iplist_delete(lctx, &mzone->also_notify);
if (mzone->allow_update != NULL)
dns_c_ipmatchlist_detach(lctx, &mzone->allow_update);
if (mzone->allow_query != NULL)
dns_c_ipmatchlist_detach(lctx, &mzone->allow_query);
if (mzone->allow_transfer != NULL)
dns_c_ipmatchlist_detach(lctx, &mzone->allow_transfer);
if (mzone->also_notify != NULL)
dns_c_iplist_detach(lctx, &mzone->also_notify);
if (mzone->ixfr_base != NULL) {
isc_mem_free(mem, mzone->ixfr_base);
@@ -2998,9 +3008,12 @@ master_zone_clear(isc_log_t *lctx, isc_mem_t *mem, dns_c_masterzone_t *mzone)
if (mzone->ixfr_tmp != NULL) {
isc_mem_free(mem, mzone->ixfr_tmp);
}
dns_c_pubkey_delete(lctx, &mzone->pubkey);
dns_c_iplist_delete(lctx, &mzone->forwarders);
if (mzone->pubkey != NULL)
dns_c_pubkey_delete(lctx, &mzone->pubkey);
if (mzone->forwarders != NULL)
dns_c_iplist_detach(lctx, &mzone->forwarders);
return (ISC_R_SUCCESS);
}
@@ -3025,12 +3038,23 @@ slave_zone_clear(isc_log_t *lctx, isc_mem_t *mem, dns_c_slavezone_t *szone)
isc_mem_free(mem, szone->ixfr_tmp);
}
dns_c_iplist_delete(lctx, &szone->master_ips);
dns_c_ipmatchlist_delete(lctx, &szone->allow_update);
dns_c_ipmatchlist_delete(lctx, &szone->allow_query);
dns_c_ipmatchlist_delete(lctx, &szone->allow_transfer);
dns_c_iplist_delete(lctx, &szone->also_notify);
dns_c_iplist_delete(lctx, &szone->forwarders);
if (szone->master_ips != NULL)
dns_c_iplist_detach(lctx, &szone->master_ips);
if (szone->allow_update != NULL)
dns_c_ipmatchlist_detach(lctx, &szone->allow_update);
if (szone->allow_query != NULL)
dns_c_ipmatchlist_detach(lctx, &szone->allow_query);
if (szone->allow_transfer != NULL)
dns_c_ipmatchlist_detach(lctx, &szone->allow_transfer);
if (szone->also_notify != NULL)
dns_c_iplist_detach(lctx, &szone->also_notify);
if (szone->forwarders != NULL)
dns_c_iplist_detach(lctx, &szone->forwarders);
return (ISC_R_SUCCESS);
}
@@ -3048,10 +3072,18 @@ stub_zone_clear(isc_log_t *lctx, isc_mem_t *mem, dns_c_stubzone_t *tzone)
isc_mem_free(mem, tzone->file);
}
dns_c_iplist_delete(lctx, &tzone->master_ips);
dns_c_ipmatchlist_delete(lctx, &tzone->allow_update);
dns_c_ipmatchlist_delete(lctx, &tzone->allow_query);
dns_c_ipmatchlist_delete(lctx, &tzone->allow_transfer);
if (tzone->master_ips != NULL)
dns_c_iplist_detach(lctx, &tzone->master_ips);
if (tzone->allow_update != NULL)
dns_c_ipmatchlist_detach(lctx, &tzone->allow_update);
if (tzone->allow_query != NULL)
dns_c_ipmatchlist_detach(lctx, &tzone->allow_query);
if (tzone->allow_transfer != NULL)
dns_c_ipmatchlist_detach(lctx, &tzone->allow_transfer);
return (ISC_R_SUCCESS);
}
@@ -3066,7 +3098,8 @@ forward_zone_clear(isc_log_t *lctx, isc_mem_t *mem, dns_c_forwardzone_t *fzone)
(void) mem; /* lint happiness */
dns_c_iplist_delete(lctx, &fzone->forwarders);
if (fzone->forwarders != NULL)
dns_c_iplist_detach(lctx, &fzone->forwarders);
return (ISC_R_SUCCESS);
}
@@ -3099,7 +3132,7 @@ set_ipmatch_list_field(isc_log_t *lctx, isc_mem_t *mem,
isc_result_t res;
if (*dest != NULL) {
res = dns_c_ipmatchlist_delete(lctx, dest);
res = dns_c_ipmatchlist_detach(lctx, dest);
if (res != ISC_R_SUCCESS) {
return (res);
}
@@ -3124,7 +3157,7 @@ set_iplist_field(isc_log_t *lctx, isc_mem_t *mem,
isc_result_t res;
if (*dest != NULL) {
res = dns_c_iplist_delete(lctx, dest);
res = dns_c_iplist_detach(lctx, dest);
if (res != ISC_R_SUCCESS) {
return (res);
}

View File

@@ -193,10 +193,11 @@ isc_result_t dns_c_ipmatchindirect_new(isc_log_t *lctx,
isc_result_t dns_c_ipmatchlist_new(isc_log_t *lctx,
isc_mem_t *mem,
dns_c_ipmatchlist_t **ptr);
isc_result_t dns_c_ipmatchlist_delete(isc_log_t *lctx,
isc_result_t dns_c_ipmatchlist_detach(isc_log_t *lctx,
dns_c_ipmatchlist_t **ml);
dns_c_ipmatchlist_t *dns_c_ipmatchlist_attach(isc_log_t *lctx,
dns_c_ipmatchlist_t *ipml);
void dns_c_ipmatchlist_attach(isc_log_t *lctx,
dns_c_ipmatchlist_t *source,
dns_c_ipmatchlist_t **target);
isc_result_t dns_c_ipmatchlist_copy(isc_log_t *lctx,
isc_mem_t *mem,
dns_c_ipmatchlist_t **dest,
@@ -216,13 +217,14 @@ isc_result_t dns_c_ipmatchlist_print(isc_log_t *lctx,
isc_result_t dns_c_iplist_new(isc_log_t *lctx,
isc_mem_t *mem, int length,
dns_c_iplist_t **newlist);
isc_result_t dns_c_iplist_delete(isc_log_t *lctx,
isc_result_t dns_c_iplist_detach(isc_log_t *lctx,
dns_c_iplist_t **list);
isc_result_t dns_c_iplist_copy(isc_log_t *lctx,
isc_mem_t *mem, dns_c_iplist_t **dest,
dns_c_iplist_t *src);
dns_c_iplist_t *dns_c_iplist_attach(isc_log_t *lctx,
dns_c_iplist_t *list);
void dns_c_iplist_attach(isc_log_t *lctx,
dns_c_iplist_t *source,
dns_c_iplist_t **target);
isc_result_t dns_c_iplist_append(isc_log_t *lctx,
dns_c_iplist_t *list,
isc_sockaddr_t newaddr);

View File

@@ -246,9 +246,9 @@ isc_result_t dns_c_zone_new(isc_log_t *lctx, isc_mem_t *mem,
dns_c_zonetype_t ztype, dns_rdataclass_t zclass,
const char *name, const char *internalname,
dns_c_zone_t **zone);
isc_result_t dns_c_zone_delete(isc_log_t *lctx, dns_c_zone_t **zone);
void dns_c_zone_attach(isc_log_t *lctx, dns_c_zone_t *zone,
dns_c_zone_t **newzone);
isc_result_t dns_c_zone_detach(isc_log_t *lctx, dns_c_zone_t **zone);
void dns_c_zone_attach(isc_log_t *lctx, dns_c_zone_t *source,
dns_c_zone_t **target);
void dns_c_zone_print(isc_log_t *lctx, FILE *fp, int indent,
dns_c_zone_t *zone);
isc_result_t dns_c_zone_setfile(isc_log_t *lctx, dns_c_zone_t *zone,

View File

@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: zone.c,v 1.35 1999/10/30 01:53:37 gson Exp $ */
/* $Id: zone.c,v 1.36 1999/11/17 21:52:32 brister Exp $ */
#include <config.h>
@@ -357,11 +357,11 @@ zone_free(dns_zone_t *zone) {
zone->check_names = dns_c_severity_ignore;
zone->pubkey = NULL; /* XXX detach */
if (zone->update_acl != NULL)
dns_c_ipmatchlist_delete(NULL, &zone->update_acl);
dns_c_ipmatchlist_detach(NULL, &zone->update_acl);
if (zone->query_acl != NULL)
dns_c_ipmatchlist_delete(NULL, &zone->query_acl);
dns_c_ipmatchlist_detach(NULL, &zone->query_acl);
if (zone->xfr_acl != NULL)
dns_c_ipmatchlist_delete(NULL, &zone->xfr_acl);
dns_c_ipmatchlist_detach(NULL, &zone->xfr_acl);
if (dns_name_dynamic(&zone->origin))
dns_name_free(&zone->origin, zone->mctx);
@@ -2445,21 +2445,21 @@ dns_zone_copy(isc_log_t *lctx, dns_c_ctx_t *ctx, dns_c_zone_t *czone,
iresult = dns_c_zone_getallowupd(lctx, czone, &acl);
if (iresult == ISC_R_SUCCESS) {
dns_zone_setupdateacl(zone, acl);
dns_c_ipmatchlist_delete(lctx, &acl);
dns_c_ipmatchlist_detach(lctx, &acl);
} else
dns_zone_clearupdateacl(zone);
iresult = dns_c_zone_getallowquery(lctx, czone, &acl);
if (iresult == ISC_R_SUCCESS) {
dns_zone_setqueryacl(zone, acl);
dns_c_ipmatchlist_delete(lctx, &acl);
dns_c_ipmatchlist_detach(lctx, &acl);
} else
dns_zone_clearqueryacl(zone);
iresult = dns_c_zone_getallowtransfer(lctx, czone, &acl);
if (iresult == ISC_R_SUCCESS) {
dns_zone_setxfracl(zone, acl);
dns_c_ipmatchlist_delete(lctx, &acl);
dns_c_ipmatchlist_detach(lctx, &acl);
} else
dns_zone_clearxfracl(zone);
@@ -2522,7 +2522,7 @@ dns_zone_copy(isc_log_t *lctx, dns_c_ctx_t *ctx, dns_c_zone_t *czone,
iresult = dns_c_zone_getallowquery(lctx, czone, &acl);
if (iresult == ISC_R_SUCCESS) {
dns_zone_setqueryacl(zone, acl);
dns_c_ipmatchlist_delete(lctx, &acl);
dns_c_ipmatchlist_detach(lctx, &acl);
} else
dns_zone_clearqueryacl(zone);
@@ -2580,7 +2580,7 @@ dns_zone_copy(isc_log_t *lctx, dns_c_ctx_t *ctx, dns_c_zone_t *czone,
iresult = dns_c_zone_getallowquery(lctx, czone, &acl);
if (iresult == ISC_R_SUCCESS) {
dns_zone_setqueryacl(zone, acl);
dns_c_ipmatchlist_delete(lctx, &acl);
dns_c_ipmatchlist_detach(lctx, &acl);
} else
dns_zone_clearqueryacl(zone);
@@ -2653,10 +2653,10 @@ dns_zone_setqueryacl(dns_zone_t *zone, dns_c_ipmatchlist_t *acl) {
LOCK(&zone->lock);
if (zone->query_acl != NULL)
dns_c_ipmatchlist_delete(NULL /* isc_log_t */,
dns_c_ipmatchlist_detach(NULL /* isc_log_t */,
&zone->query_acl);
zone->query_acl = dns_c_ipmatchlist_attach(NULL /* isc_log_t */,
acl);
dns_c_ipmatchlist_attach(NULL /* isc_log_t */,
acl, &zone->query_acl);
UNLOCK(&zone->lock);
}
@@ -2667,10 +2667,10 @@ dns_zone_setupdateacl(dns_zone_t *zone, dns_c_ipmatchlist_t *acl) {
LOCK(&zone->lock);
if (zone->update_acl != NULL)
dns_c_ipmatchlist_delete(NULL /* isc_log_t */,
dns_c_ipmatchlist_detach(NULL /* isc_log_t */,
&zone->update_acl);
zone->update_acl = dns_c_ipmatchlist_attach(NULL /* isc_log_t */,
acl);
dns_c_ipmatchlist_attach(NULL /* isc_log_t */,
acl, &zone->update_acl);
UNLOCK(&zone->lock);
}
@@ -2681,10 +2681,10 @@ dns_zone_setxfracl(dns_zone_t *zone, dns_c_ipmatchlist_t *acl) {
LOCK(&zone->lock);
if (zone->xfr_acl != NULL)
dns_c_ipmatchlist_delete(NULL /* isc_log_t */,
dns_c_ipmatchlist_detach(NULL /* isc_log_t */,
&zone->xfr_acl);
zone->xfr_acl = dns_c_ipmatchlist_attach(NULL /* isc_log_t */,
acl);
dns_c_ipmatchlist_attach(NULL /* isc_log_t */,
acl, &zone->xfr_acl);
UNLOCK(&zone->lock);
}
@@ -2719,7 +2719,7 @@ dns_zone_clearupdateacl(dns_zone_t *zone) {
LOCK(&zone->lock);
if (zone->update_acl != NULL)
dns_c_ipmatchlist_delete(NULL /* isc_log_t */,
dns_c_ipmatchlist_detach(NULL /* isc_log_t */,
&zone->update_acl);
UNLOCK(&zone->lock);
}
@@ -2731,7 +2731,7 @@ dns_zone_clearqueryacl(dns_zone_t *zone) {
LOCK(&zone->lock);
if (zone->query_acl != NULL)
dns_c_ipmatchlist_delete(NULL /* isc_log_t */,
dns_c_ipmatchlist_detach(NULL /* isc_log_t */,
&zone->query_acl);
UNLOCK(&zone->lock);
}
@@ -2743,7 +2743,7 @@ dns_zone_clearxfracl(dns_zone_t *zone) {
LOCK(&zone->lock);
if (zone->xfr_acl != NULL)
dns_c_ipmatchlist_delete(NULL /* isc_log_t */,
dns_c_ipmatchlist_detach(NULL /* isc_log_t */,
&zone->xfr_acl);
UNLOCK(&zone->lock);
}