From 5fc1b54cc6134bd70f4e22df90a2e5631aaea77a Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Wed, 28 Jul 1999 02:20:22 +0000 Subject: [PATCH] allow undedication of the dedicated buffer --- lib/dns/include/dns/name.h | 10 +++++++--- lib/dns/name.c | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 7a67de0c9b..b7f4dcef94 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -254,12 +254,16 @@ dns_name_setbuffer(dns_name_t *name, isc_buffer_t *buffer); * The caller must not write to buffer until the name has been * invalidated or is otherwise known not to be in use. * + * If buffer is NULL and the name previously had a dedicated buffer, + * than that buffer is no longer dedicated to use with this name. + * The caller is responsible for ensuring that the storage used by + * the name remains valid. + * * Requires: * 'name' is a valid name. * - * 'name' doesn't have a dedicated buffer already. - * - * 'buffer' is a valid binary buffer. + * 'buffer' is a valid binary buffer and 'name' doesn't have a + * dedicated buffer already, or 'buffer' is NULL. */ isc_boolean_t diff --git a/lib/dns/name.c b/lib/dns/name.c index d702a93c29..a0051b32fe 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -289,8 +289,10 @@ dns_name_setbuffer(dns_name_t *name, isc_buffer_t *buffer) { */ REQUIRE(VALID_NAME(name)); - REQUIRE(name->buffer == NULL); - REQUIRE(isc_buffer_type(buffer) == ISC_BUFFERTYPE_BINARY); + REQUIRE((buffer != NULL && + name->buffer == NULL && + isc_buffer_type(buffer) == ISC_BUFFERTYPE_BINARY) || + (buffer == NULL)); name->buffer = buffer; }