Index: webrtc/base/copyonwritebuffer.h |
diff --git a/webrtc/base/copyonwritebuffer.h b/webrtc/base/copyonwritebuffer.h |
index 72fb4eea53495a2575ee435efade9d182afd4a69..ecaca026ea4d00fd7ef7438444dd409293b79e19 100644 |
--- a/webrtc/base/copyonwritebuffer.h |
+++ b/webrtc/base/copyonwritebuffer.h |
@@ -222,7 +222,12 @@ class CopyOnWriteBuffer { |
return; |
} |
- CloneDataIfReferenced(std::max(buffer_->capacity(), size)); |
+ // Clone data if referenced. |
+ if (!buffer_->HasOneRef()) { |
+ buffer_ = new RefCountedObject<Buffer>(buffer_->data(), |
+ std::min(buffer_->size(), size), |
+ std::max(buffer_->capacity(), size)); |
kwiberg-webrtc
2016/09/09 08:28:29
You maintain the capacity of the original buffer h
danilchap
2016/09/09 11:25:33
Yes. there is no need to reallocate with full capa
danilchap
2016/09/09 12:58:44
Actually, it is debatable if SetSize allowed to de
|
+ } |
buffer_->SetSize(size); |
RTC_DCHECK(IsConsistent()); |
} |