]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
remove dns_name_copy() implementation
authorEvan Hunt <each@isc.org>
Sat, 22 May 2021 00:17:23 +0000 (17:17 -0700)
committerEvan Hunt <each@isc.org>
Sat, 22 May 2021 07:22:32 +0000 (00:22 -0700)
Remove dns_name_copy() and refactor the underlying code since
it will only be called by dns_name_copynf() now, and can't fail.

lib/dns/include/dns/name.h
lib/dns/name.c
lib/dns/win32/libdns.def.in

index 16bb5ffa33ae9be1dab8b3d5b703eb95d7d1a415..48c10bfaddfa2d271b53d99a52c02b4fd89b3d7b 100644 (file)
@@ -1240,33 +1240,12 @@ dns_name_settotextfilter(dns_name_totextfilter_t *proc);
  * Includes space for the terminating NULL.
  */
 
-isc_result_t
-dns_name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target);
-/*%<
- * Copies the name in 'source' into 'dest'.  The name data is copied to
- * the 'target' buffer, which is then set as the buffer for 'dest'.
- *
- * Requires:
- * \li 'source' is a valid name.
- *
- * \li 'dest' is an initialized name.
- *
- * \li 'target' is an initialized buffer.
- *
- * Ensures:
- *
- *\li  On success, the used space in target is updated.
- *
- * Returns:
- *\li  #ISC_R_SUCCESS
- *\li  #ISC_R_NOSPACE
- */
-
 void
 dns_name_copynf(const dns_name_t *source, dns_name_t *dest);
 /*%<
  * Copies the name in 'source' into 'dest'.  The name data is copied to
- * the dedicated buffer for 'dest'.
+ * the dedicated buffer for 'dest'. (If copying to a name that doesn't
+ * have a dedicated buffer, use dns_name_setbuffer() first.)
  *
  * Requires:
  * \li 'source' is a valid name.
index fd9a8ced3b7cd9db2b3415cb7b3243a74c9c5dcf..e5715638d0eb68410175f1ec043fa24aa7f617fd 100644 (file)
@@ -2462,24 +2462,23 @@ dns_name_fromstring2(dns_name_t *target, const char *src,
        return (result);
 }
 
-static isc_result_t
-name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target) {
+void
+dns_name_copynf(const dns_name_t *source, dns_name_t *dest) {
+       isc_buffer_t *target = NULL;
        unsigned char *ndata = NULL;
 
-       /*
-        * Make dest a copy of source.
-        */
-
+       REQUIRE(VALID_NAME(source));
+       REQUIRE(VALID_NAME(dest));
        REQUIRE(BINDABLE(dest));
 
-       /*
-        * Set up.
-        */
-       if (target->length - target->used < source->length) {
-               return (ISC_R_NOSPACE);
-       }
+       target = dest->buffer;
 
-       ndata = (unsigned char *)target->base + target->used;
+       REQUIRE(target != NULL);
+       REQUIRE(target->length >= source->length);
+
+       isc_buffer_clear(target);
+
+       ndata = (unsigned char *)target->base;
        dest->ndata = target->base;
 
        if (source->length != 0) {
@@ -2504,28 +2503,6 @@ name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target) {
        }
 
        isc_buffer_add(target, dest->length);
-
-       return (ISC_R_SUCCESS);
-}
-
-isc_result_t
-dns_name_copy(const dns_name_t *source, dns_name_t *dest,
-             isc_buffer_t *target) {
-       REQUIRE(VALID_NAME(source));
-       REQUIRE(VALID_NAME(dest));
-       REQUIRE(target != NULL);
-
-       return (name_copy(source, dest, target));
-}
-
-void
-dns_name_copynf(const dns_name_t *source, dns_name_t *dest) {
-       REQUIRE(VALID_NAME(source));
-       REQUIRE(VALID_NAME(dest));
-       REQUIRE(dest->buffer != NULL);
-
-       isc_buffer_clear(dest->buffer);
-       RUNTIME_CHECK(name_copy(source, dest, dest->buffer) == ISC_R_SUCCESS);
 }
 
 /*
index feedfb94476ea4cf5207d230e4d92a0f460a5520..1eba5af96d384130a7dd77d7658f385907494a24 100644 (file)
@@ -576,7 +576,6 @@ dns_name_caseequal
 dns_name_clone
 dns_name_compare
 dns_name_concatenate
-dns_name_copy
 dns_name_copynf
 dns_name_countlabels
 dns_name_digest