Chromium Code Reviews| Index: base/values.cc |
| diff --git a/base/values.cc b/base/values.cc |
| index e55e11af0f3b62b612b4f4ed79118b7d29466728..4772b647748f112260667c75cb570979b034c4b4 100644 |
| --- a/base/values.cc |
| +++ b/base/values.cc |
| @@ -304,12 +304,12 @@ BinaryValue::~BinaryValue() { |
| } |
| // static |
| -BinaryValue* BinaryValue::CreateWithCopiedBuffer(const char* buffer, |
| - size_t size) { |
| - char* buffer_copy = new char[size]; |
| - memcpy(buffer_copy, buffer, size); |
| - std::unique_ptr<char[]> scoped_buffer_copy(buffer_copy); |
| - return new BinaryValue(std::move(scoped_buffer_copy), size); |
| +std::unique_ptr<BinaryValue> BinaryValue::CreateWithCopiedBuffer( |
| + const char* buffer, |
| + size_t size) { |
| + std::unique_ptr<char[]> buffer_copy(new char[size]); |
| + memcpy(buffer_copy.get(), buffer, size); |
| + return base::MakeUnique<BinaryValue>(std::move(buffer_copy), size); |
| } |
| bool BinaryValue::GetAsBinary(const BinaryValue** out_value) const { |
| @@ -319,7 +319,7 @@ bool BinaryValue::GetAsBinary(const BinaryValue** out_value) const { |
| } |
| BinaryValue* BinaryValue::DeepCopy() const { |
| - return CreateWithCopiedBuffer(buffer_.get(), size_); |
| + return CreateWithCopiedBuffer(buffer_.get(), size_).release(); |
|
dcheng
2016/06/13 21:28:38
I wanted to change this to be CreateDeepCopy() bas
|
| } |
| bool BinaryValue::Equals(const Value* other) const { |