rtc::Buffer: Replace an internal rtc::scoped_ptr with std::unique_ptr

We'd like to completely replace rtc::scoped_ptr with std::unique_ptr.
This is a first trial CL to see if using unique_ptr causes any
problems.

(As a side effect of removing the scoped_ptr.h include in buffer.h,
I had to fix broken includes in no less than three files.)

BUG=webrtc:5520

Review URL: https://codereview.webrtc.org/1687833006

Cr-Commit-Position: refs/heads/master@{#11588}
This commit is contained in:
kwiberg 2016-02-11 13:36:43 -08:00 committed by Commit bot
parent 9b7a289301
commit 8fb3557052
3 changed files with 7 additions and 3 deletions

View File

@ -32,6 +32,7 @@
#import "RTCDataChannel+Internal.h"
#include "webrtc/api/datachannelinterface.h"
#include "webrtc/base/scoped_ptr.h"
namespace webrtc {

View File

@ -13,6 +13,8 @@
#import "webrtc/api/objc/RTCDataChannel+Private.h"
#import "webrtc/base/objc/NSString+StdString.h"
#include "webrtc/base/scoped_ptr.h"
namespace webrtc {
class DataChannelDelegateAdapter : public DataChannelObserver {

View File

@ -14,10 +14,11 @@
#include <algorithm> // std::swap (pre-C++11)
#include <cassert>
#include <cstring>
#include <memory>
#include <utility> // std::swap (C++11 and later)
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/deprecation.h"
#include "webrtc/base/scoped_ptr.h"
namespace rtc {
@ -164,7 +165,7 @@ class Buffer {
assert(IsConsistent());
if (capacity <= capacity_)
return;
scoped_ptr<uint8_t[]> new_data(new uint8_t[capacity]);
std::unique_ptr<uint8_t[]> new_data(new uint8_t[capacity]);
std::memcpy(new_data.get(), data_.get(), size_);
data_ = std::move(new_data);
capacity_ = capacity;
@ -222,7 +223,7 @@ class Buffer {
size_t size_;
size_t capacity_;
scoped_ptr<uint8_t[]> data_;
std::unique_ptr<uint8_t[]> data_;
};
} // namespace rtc