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

Side by Side Diff: src/smart-pointers.h

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/small-pointer-list.h ('k') | src/snapshot-external.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_SMART_POINTERS_H_ 5 #ifndef V8_SMART_POINTERS_H_
6 #define V8_SMART_POINTERS_H_ 6 #define V8_SMART_POINTERS_H_
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // If you want to take out the plain pointer and don't want it automatically 49 // If you want to take out the plain pointer and don't want it automatically
50 // deleted then call Detach(). Afterwards, the smart pointer is empty 50 // deleted then call Detach(). Afterwards, the smart pointer is empty
51 // (NULL). 51 // (NULL).
52 T* Detach() { 52 T* Detach() {
53 T* temp = p_; 53 T* temp = p_;
54 p_ = NULL; 54 p_ = NULL;
55 return temp; 55 return temp;
56 } 56 }
57 57
58 void Reset(T* new_value) { 58 void Reset(T* new_value) {
59 ASSERT(p_ == NULL || p_ != new_value); 59 DCHECK(p_ == NULL || p_ != new_value);
60 if (p_) Deallocator::Delete(p_); 60 if (p_) Deallocator::Delete(p_);
61 p_ = new_value; 61 p_ = new_value;
62 } 62 }
63 63
64 // Assignment requires an empty (NULL) SmartArrayPointer as the receiver. Like 64 // Assignment requires an empty (NULL) SmartArrayPointer as the receiver. Like
65 // the copy constructor it removes the pointer in the original to avoid 65 // the copy constructor it removes the pointer in the original to avoid
66 // double freeing. 66 // double freeing.
67 SmartPointerBase<Deallocator, T>& operator=( 67 SmartPointerBase<Deallocator, T>& operator=(
68 const SmartPointerBase<Deallocator, T>& rhs) { 68 const SmartPointerBase<Deallocator, T>& rhs) {
69 ASSERT(is_empty()); 69 DCHECK(is_empty());
70 T* tmp = rhs.p_; // swap to handle self-assignment 70 T* tmp = rhs.p_; // swap to handle self-assignment
71 const_cast<SmartPointerBase<Deallocator, T>&>(rhs).p_ = NULL; 71 const_cast<SmartPointerBase<Deallocator, T>&>(rhs).p_ = NULL;
72 p_ = tmp; 72 p_ = tmp;
73 return *this; 73 return *this;
74 } 74 }
75 75
76 bool is_empty() const { return p_ == NULL; } 76 bool is_empty() const { return p_ == NULL; }
77 77
78 protected: 78 protected:
79 // When the destructor of the scoped pointer is executed the plain pointer 79 // When the destructor of the scoped pointer is executed the plain pointer
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 SmartPointer() { } 121 SmartPointer() { }
122 explicit SmartPointer(T* ptr) 122 explicit SmartPointer(T* ptr)
123 : SmartPointerBase<ObjectDeallocator<T>, T>(ptr) { } 123 : SmartPointerBase<ObjectDeallocator<T>, T>(ptr) { }
124 SmartPointer(const SmartPointer<T>& rhs) 124 SmartPointer(const SmartPointer<T>& rhs)
125 : SmartPointerBase<ObjectDeallocator<T>, T>(rhs) { } 125 : SmartPointerBase<ObjectDeallocator<T>, T>(rhs) { }
126 }; 126 };
127 127
128 } } // namespace v8::internal 128 } } // namespace v8::internal
129 129
130 #endif // V8_SMART_POINTERS_H_ 130 #endif // V8_SMART_POINTERS_H_
OLDNEW
« no previous file with comments | « src/small-pointer-list.h ('k') | src/snapshot-external.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698