From 82e1875c7d8f07dd5da500f3502b66bf80a0361f Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Thu, 7 Jan 2021 13:38:48 +0100 Subject: [PATCH] Introduce CopyOnWriteBuffer::MutableData() function With intent to replace non-const data() and operator[] Bug: webrtc:12334 Change-Id: Ib81f8607b96045ca517159d6d0c9d8a07bda5fd0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/200802 Commit-Queue: Danil Chapovalov Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/master@{#32919} --- rtc_base/copy_on_write_buffer.h | 13 +++++++++++-- rtc_base/copy_on_write_buffer_unittest.cc | 15 ++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/rtc_base/copy_on_write_buffer.h b/rtc_base/copy_on_write_buffer.h index 68c6ad53d6..87bf625fea 100644 --- a/rtc_base/copy_on_write_buffer.h +++ b/rtc_base/copy_on_write_buffer.h @@ -86,7 +86,7 @@ class RTC_EXPORT CopyOnWriteBuffer { template ::value>::type* = nullptr> - T* data() { + T* MutableData() { RTC_DCHECK(IsConsistent()); if (!buffer_) { return nullptr; @@ -95,6 +95,14 @@ class RTC_EXPORT CopyOnWriteBuffer { return buffer_->data() + offset_; } + // TODO(bugs.webrtc.org/12334): Delete when all usage updated to MutableData() + template ::value>::type* = nullptr> + T* data() { + return MutableData(); + } + // Get const pointer to the data. This will not create a copy of the // underlying data if it is shared with other buffers. template