throwError("read beyond end of buffer");
}
- std::memcpy(data, &data_[position_], len);
+ static_cast<void>(std::memmove(data, &data_[position_], len));
position_ += len;
}
//@}
if (buffer_ == NULL) {
throw std::bad_alloc();
}
- std::memcpy(buffer_, other.buffer_, other.size_);
+ static_cast<void>(std::memmove(buffer_, other.buffer_, other.size_));
}
}
// across.
free(buffer_);
buffer_ = newbuff;
- static_cast<void>(std::memcpy(buffer_, other.buffer_, other.size_));
+ static_cast<void>(std::memmove(buffer_, other.buffer_, other.size_));
} else {
/// This method is the destructive alternative to clear().
void wipe() {
if (buffer_ != NULL) {
- memset(buffer_, 0, allocated_);
+ static_cast<void>(std::memset(buffer_, 0, allocated_));
}
size_ = 0;
}
/// \param len The length of the data in bytes.
void writeData(const void *data, size_t len) {
ensureAllocated(size_ + len);
- std::memcpy(buffer_ + size_, data, len);
+ static_cast<void>(std::memmove(buffer_ + size_, data, len));
size_ += len;
}
//@}
/// \brief Ensure buffer is appropriate size
///
- /// Checks that the buffer is at least equal to the size passed in as the
+ /// Checks that the buffer equal to or larger than the size given as
/// argument and extends it to at least that size if not.
///
/// \param needed_size The number of bytes required in the buffer
}
TEST_F(BufferTest, outputEmptyBufferAssign) {
- EXPECT_NO_THROW({
- OutputBuffer copy(0);
+ OutputBuffer copy(0);
+ ASSERT_NO_THROW({
copy = obuffer;
- ASSERT_EQ(0, copy.getLength());
});
+ ASSERT_EQ(0, copy.getLength());
+ EXPECT_EQ(NULL, copy.getData());
}
// Check assign to self doesn't break stuff