Browse Source

[master] removed the "from-iterator" ctor of InputBuffer and its test.

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::
JINMEI Tatuya 13 years ago
parent
commit
ae3f3a6859
2 changed files with 4 additions and 32 deletions
  1. 4 17
      src/lib/util/buffer.h
  2. 0 15
      src/lib/util/tests/buffer_unittest.cc

+ 4 - 17
src/lib/util/buffer.h

@@ -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;
     }
     //@}

+ 0 - 15
src/lib/util/tests/buffer_unittest.cc

@@ -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);
-}
-
 }