Browse Source

[1774] Added NameOffsets typedef

Mukund Sivaraman 13 years ago
parent
commit
3dab9ab494
2 changed files with 7 additions and 5 deletions
  1. 4 4
      src/lib/dns/name.cc
  2. 3 1
      src/lib/dns/name.h

+ 4 - 4
src/lib/dns/name.cc

@@ -147,7 +147,7 @@ Name::Name(const std::string &namestring, bool downcase) {
     bool is_root = false;
     ft_state state = ft_init;
 
-    std::vector<uint8_t> offsets;
+    NameOffsets offsets;
     offsets.reserve(Name::MAX_LABELS);
     offsets.push_back(0);
 
@@ -310,7 +310,7 @@ typedef enum {
 }
 
 Name::Name(InputBuffer& buffer, bool downcase) {
-    std::vector<uint8_t> offsets;
+    NameOffsets offsets;
     offsets.reserve(Name::MAX_LABELS);
 
     /*
@@ -663,8 +663,8 @@ Name::reverse() const {
     retname.ndata_.reserve(length_);
 
     // Copy the original name, label by label, from tail to head.
-    vector<uint8_t>::const_reverse_iterator rit0 = offsets_.rbegin();
-    vector<uint8_t>::const_reverse_iterator rit1 = rit0 + 1;
+    NameOffsets::const_reverse_iterator rit0 = offsets_.rbegin();
+    NameOffsets::const_reverse_iterator rit1 = rit0 + 1;
     NameString::const_iterator n0 = ndata_.begin();
     retname.offsets_.push_back(0);
     while (rit1 != offsets_.rend()) {

+ 3 - 1
src/lib/dns/name.h

@@ -231,6 +231,8 @@ class Name {
 private:
     /// \brief Name data string
     typedef std::basic_string<uint8_t> NameString;
+    /// \brief Name offsets type
+    typedef std::vector<uint8_t> NameOffsets;
 
     /// The default constructor
     ///
@@ -683,7 +685,7 @@ public:
 
 private:
     NameString ndata_;
-    std::vector<uint8_t> offsets_;
+    NameOffsets offsets_;
     unsigned int length_;
     unsigned int labelcount_;
 };