Index: webrtc/base/bytebuffer.cc |
diff --git a/webrtc/base/bytebuffer.cc b/webrtc/base/bytebuffer.cc |
index c2ffe609341fbb74339d2c2101cfc298741bf342..317b6f383a564c904a1ea1d891b5cf90a38f2b6b 100644 |
--- a/webrtc/base/bytebuffer.cc |
+++ b/webrtc/base/bytebuffer.cc |
@@ -43,7 +43,6 @@ ByteBufferWriter::ByteBufferWriter(const char* bytes, size_t len, |
} |
void ByteBufferWriter::Construct(const char* bytes, size_t len) { |
- start_ = 0; |
size_ = len; |
bytes_ = new char[size_]; |
@@ -119,25 +118,21 @@ char* ByteBufferWriter::ReserveWriteBuffer(size_t len) { |
} |
void ByteBufferWriter::Resize(size_t size) { |
- size_t len = std::min(end_ - start_, size); |
- if (size <= size_) { |
- // Don't reallocate, just move data backwards |
- memmove(bytes_, bytes_ + start_, len); |
- } else { |
+ size_t len = std::min(end_, size); |
+ if (size > size_) { |
// Reallocate a larger buffer. |
size_ = std::max(size, 3 * size_ / 2); |
char* new_bytes = new char[size_]; |
- memcpy(new_bytes, bytes_ + start_, len); |
+ memcpy(new_bytes, bytes_, len); |
delete [] bytes_; |
bytes_ = new_bytes; |
} |
- start_ = 0; |
end_ = len; |
} |
void ByteBufferWriter::Clear() { |
memset(bytes_, 0, size_); |
- start_ = end_ = 0; |
+ end_ = 0; |
} |