Commit 24f7de85 authored by dcheng@chromium.org's avatar dcheng@chromium.org

Update scoped_array<T>::reset logic to match scoped_ptr.

This logic was already added in scoped_ptr::reset() in
https://src.chromium.org/viewvc/chrome?view=rev&revision=185551.
this is a straightforward port of the logic to scoped_array to
prevent any accidental regressions during the transition.

BUG=162971,176091

Review URL: https://codereview.chromium.org/13433007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192590 0039d316-1c4b-4281-b951-d872f2087c98
parent 2cadbff3
...@@ -606,15 +606,17 @@ class scoped_array { ...@@ -606,15 +606,17 @@ class scoped_array {
return *this; return *this;
} }
// Reset. Deletes the current owned object, if any. // Reset. Deletes the current owned object, if any.
// Then takes ownership of a new object, if given.
// this->reset(this->get()) works.
void reset(C* p = NULL) { void reset(C* p = NULL) {
if (p != array_) { // This is a self-reset, which is no longer allowed: http://crbug.com/162971
enum { type_must_be_complete = sizeof(C) }; if (p != NULL && p == array_)
delete[] array_; abort();
array_ = p;
} C* old = array_;
array_ = NULL;
if (old != NULL)
delete[] old;
array_ = p;
} }
// Get one element of the current object. // Get one element of the current object.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment