Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(756)

Unified Diff: base/memory/scoped_ptr.h

Issue 13433007: Update scoped_array<T>::reset logic to match scoped_ptr. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix dumb typo Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/scoped_ptr.h
diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h
index 7098e14281e4e182517d6700ce3d0b18b73c22b8..96703f5fd7141721b8e8b5245ef4c2a70e490903 100644
--- a/base/memory/scoped_ptr.h
+++ b/base/memory/scoped_ptr.h
@@ -606,15 +606,17 @@ class scoped_array {
return *this;
}
- // Reset. Deletes the current owned object, if any.
- // Then takes ownership of a new object, if given.
- // this->reset(this->get()) works.
+ // Reset. Deletes the current owned object, if any.
void reset(C* p = NULL) {
- if (p != array_) {
- enum { type_must_be_complete = sizeof(C) };
- delete[] array_;
- array_ = p;
- }
+ // This is a self-reset, which is no longer allowed: http://crbug.com/162971
+ if (p != NULL && p == array_)
+ abort();
+
+ C* old = array_;
+ array_ = NULL;
+ if (old != NULL)
+ delete[] old;
+ array_ = p;
}
// Get one element of the current object.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698