Delete always-zero ByteBufferWriter::start_.
Likely a left-over since cl https://codereview.webrtc.org/1821083002
BUG=None
Review-Url: https://codereview.webrtc.org/2440083002
Cr-Commit-Position: refs/heads/master@{#14732}
diff --git a/webrtc/base/bytebuffer.cc b/webrtc/base/bytebuffer.cc
index c2ffe60..317b6f3 100644
--- a/webrtc/base/bytebuffer.cc
+++ b/webrtc/base/bytebuffer.cc
@@ -43,7 +43,6 @@
}
void ByteBufferWriter::Construct(const char* bytes, size_t len) {
- start_ = 0;
size_ = len;
bytes_ = new char[size_];
@@ -119,25 +118,21 @@
}
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;
}
diff --git a/webrtc/base/bytebuffer.h b/webrtc/base/bytebuffer.h
index cd7b2c6..546c447 100644
--- a/webrtc/base/bytebuffer.h
+++ b/webrtc/base/bytebuffer.h
@@ -46,9 +46,9 @@
~ByteBufferWriter();
- const char* Data() const { return bytes_ + start_; }
- size_t Length() const { return end_ - start_; }
- size_t Capacity() const { return size_ - start_; }
+ const char* Data() const { return bytes_; }
+ size_t Length() const { return end_; }
+ size_t Capacity() const { return size_; }
// Write value to the buffer. Resizes the buffer when it is
// neccessary.
@@ -77,7 +77,6 @@
char* bytes_;
size_t size_;
- size_t start_;
size_t end_;
// There are sensible ways to define these, but they aren't needed in our code