]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] removed the "from-iterator" ctor of InputBuffer and its test.
authorJINMEI Tatuya <jinmei@isc.org>
Fri, 11 May 2012 19:25:24 +0000 (12:25 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Fri, 11 May 2012 19:25:24 +0000 (12:25 -0700)
It's not used anywhere else, and caused build failure on Solaris/SunStudio.
okayed on jabber.
I also made a few minor cleanups: unify string.c/ctring to the latter
and qualify memcpy() with std::

src/lib/util/buffer.h
src/lib/util/tests/buffer_unittest.cc

index 5cd216a6d311a0ed3a11fe92b3a07bd5749dd687..1263636c73f6a1f48c0c3fccd95cc488ffad1578 100644 (file)
@@ -18,8 +18,6 @@
 #include <stdlib.h>
 #include <cstring>
 #include <vector>
-#include <iterator>
-#include <string.h>
 
 #include <stdint.h>
 
@@ -101,17 +99,6 @@ public:
     /// \param len The length of the data in bytes.
     InputBuffer(const void* data, size_t len) :
         position_(0), data_(static_cast<const uint8_t*>(data)), len_(len) {}
-
-    /// @brief Constructor from vector<uint8_t>
-    ///
-    /// It is caller's responsibility to ensure that the data is valid as long
-    /// as the buffer exists.
-    ///
-    /// @param begin iterator to beginning of the vector
-    /// @param end iterator to end of the vector
-    InputBuffer(std::vector<uint8_t>::const_iterator begin,
-                std::vector<uint8_t>::const_iterator end) :
-        position_(0), data_(&(*begin)), len_(std::distance(begin, end)) {}
     //@}
 
     ///
@@ -209,7 +196,7 @@ public:
             throwError("read beyond end of buffer");
         }
 
-        memcpy(data, &data_[position_], len);
+        std::memcpy(data, &data_[position_], len);
         position_ += len;
     }
     //@}
@@ -344,7 +331,7 @@ public:
         if (buffer_ == NULL && allocated_ != 0) {
             throw std::bad_alloc();
         }
-        memcpy(buffer_, other.buffer_, size_);
+        std::memcpy(buffer_, other.buffer_, size_);
     }
 
     /// \brief Destructor
@@ -363,7 +350,7 @@ public:
         buffer_ = newbuff;
         size_ = other.size_;
         allocated_ = other.allocated_;
-        memcpy(buffer_, other.buffer_, size_);
+        std::memcpy(buffer_, other.buffer_, size_);
         return (*this);
     }
 
@@ -504,7 +491,7 @@ public:
     void writeData(const void *data, size_t len)
     {
         ensureAllocated(size_ + len);
-        memcpy(buffer_ + size_, data, len);
+        std::memcpy(buffer_ + size_, data, len);
         size_ += len;
     }
     //@}
index 9d924b3a5d8a7f9e66ec45eda49b9ed87bb827b5..9af3d57c6eaa0b2017f22b084fe24ab40e2b66a8 100644 (file)
@@ -287,19 +287,4 @@ TEST_F(BufferTest, inputBufferReadVectorChunks) {
     EXPECT_EQ(0, memcmp(&vec[0], testdata+3, 2));
 }
 
-TEST_F(BufferTest, inputBufferConstructorVector) {
-    std::vector<uint8_t> vec(17);
-    for (int i = 0; i < vec.size(); i++) {
-        vec[i] = i;
-    }
-
-    InputBuffer buf(vec.begin(), vec.end());
-
-    EXPECT_EQ(buf.getLength(), 17);
-
-    std::vector<uint8_t> vec2;
-    EXPECT_NO_THROW(buf.readVector(vec2, 17));
-    EXPECT_TRUE(vec == vec2);
-}
-
 }