BIND 10 trac2053, updated. 9771dfb067dc0bf250d69bc4c07c811573d2c656 [2053] Add comment that toText(bool) variant is a helper for Name::toText()

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Jul 5 05:45:01 UTC 2012


The branch, trac2053 has been updated
       via  9771dfb067dc0bf250d69bc4c07c811573d2c656 (commit)
       via  398b2215386cb1c28d764333404c1389cb87999c (commit)
      from  23ae3c2bbdf1a9f22c124aeeac2ac3c1692deb76 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9771dfb067dc0bf250d69bc4c07c811573d2c656
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu Jul 5 11:10:22 2012 +0530

    [2053] Add comment that toText(bool) variant is a helper for Name::toText()

commit 398b2215386cb1c28d764333404c1389cb87999c
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Thu Jul 5 11:08:41 2012 +0530

    [2053] Use getDataLength() to find out the right end to stop

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/labelsequence.cc |   14 +++++---------
 src/lib/dns/labelsequence.h  |    3 +++
 2 files changed, 8 insertions(+), 9 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/labelsequence.cc b/src/lib/dns/labelsequence.cc
index dd5b2c8..4c95632 100644
--- a/src/lib/dns/labelsequence.cc
+++ b/src/lib/dns/labelsequence.cc
@@ -116,23 +116,18 @@ std::string
 LabelSequence::toText(bool omit_final_dot) const {
     Name::NameString::const_iterator np = name_.ndata_.begin() +
         name_.offsets_[first_label_];
-    const Name::NameString::const_iterator np_end = name_.ndata_.end();
+    const Name::NameString::const_iterator np_end = np + getDataLength();
     // use for integrity check
     unsigned int labels = last_label_ - first_label_;
     // init with an impossible value to catch error cases in the end:
     unsigned int count = Name::MAX_LABELLEN + 1;
 
     // result string: it will roughly have the same length as the wire format
-    // name data.  reserve that length to minimize reallocation.
+    // label sequence data.  reserve that length to minimize reallocation.
     std::string result;
-    result.reserve(name_.getLength());
+    result.reserve(getDataLength());
 
     while (np != np_end) {
-        if (labels == 0) {
-            count = 0;
-            break;
-        }
-
         labels--;
         count = *np++;
 
@@ -187,8 +182,9 @@ LabelSequence::toText(bool omit_final_dot) const {
         }
     }
 
+    // We should be at the end of the data and have consumed all labels.
+    assert(np == np_end);
     assert(labels == 0);
-    assert(count == 0);
 
     return (result);
 }
diff --git a/src/lib/dns/labelsequence.h b/src/lib/dns/labelsequence.h
index 7d8827e..d2d9d08 100644
--- a/src/lib/dns/labelsequence.h
+++ b/src/lib/dns/labelsequence.h
@@ -150,6 +150,9 @@ private:
     /// returned string ends with a dot '.' if
     /// <code>omit_final_dot</code> is <code>false</code>.
     ///
+    /// This method is used as a helper for <code>Name::toText()</code>
+    /// only.
+    ///
     /// \param omit_final_dot whether to omit the trailing dot in the output.
     /// \return a string representation of the <code>LabelSequence</code>.
     std::string toText(bool omit_final_dot) const;



More information about the bind10-changes mailing list