| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 template<typename T> inline typename OwnPtr<T>::PtrType OwnPtr<T>::leakPtr() | 131 template<typename T> inline typename OwnPtr<T>::PtrType OwnPtr<T>::leakPtr() |
| 132 { | 132 { |
| 133 PtrType ptr = m_ptr; | 133 PtrType ptr = m_ptr; |
| 134 m_ptr = 0; | 134 m_ptr = 0; |
| 135 return ptr; | 135 return ptr; |
| 136 } | 136 } |
| 137 | 137 |
| 138 template<typename T> inline OwnPtr<T>& OwnPtr<T>::operator=(const PassOwnPtr
<T>& o) | 138 template<typename T> inline OwnPtr<T>& OwnPtr<T>::operator=(const PassOwnPtr
<T>& o) |
| 139 { | 139 { |
| 140 PtrType ptr = m_ptr; | 140 ASSERT(!o || o != m_ptr); |
| 141 m_ptr = o.leakPtr(); | 141 OwnPtr ptr = o; |
| 142 ASSERT(!ptr || m_ptr != ptr); | 142 swap(ptr); |
| 143 deleteOwnedPtr(ptr); | |
| 144 return *this; | 143 return *this; |
| 145 } | 144 } |
| 146 | 145 |
| 147 template<typename T> template<typename U> inline OwnPtr<T>& OwnPtr<T>::opera
tor=(const PassOwnPtr<U>& o) | 146 template<typename T> template<typename U> inline OwnPtr<T>& OwnPtr<T>::opera
tor=(const PassOwnPtr<U>& o) |
| 148 { | 147 { |
| 149 PtrType ptr = m_ptr; | 148 ASSERT(!o || o != m_ptr); |
| 150 m_ptr = o.leakPtr(); | 149 OwnPtr ptr = o; |
| 151 ASSERT(!ptr || m_ptr != ptr); | 150 swap(ptr); |
| 152 deleteOwnedPtr(ptr); | |
| 153 return *this; | 151 return *this; |
| 154 } | 152 } |
| 155 | 153 |
| 156 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) | 154 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) |
| 157 template<typename T> inline OwnPtr<T>::OwnPtr(OwnPtr<T>&& o) | 155 template<typename T> inline OwnPtr<T>::OwnPtr(OwnPtr<T>&& o) |
| 158 : m_ptr(o.leakPtr()) | 156 : m_ptr(o.leakPtr()) |
| 159 { | 157 { |
| 160 } | 158 } |
| 161 | 159 |
| 162 template<typename T> template<typename U> inline OwnPtr<T>::OwnPtr(OwnPtr<U>
&& o) | 160 template<typename T> template<typename U> inline OwnPtr<T>::OwnPtr(OwnPtr<U>
&& o) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 template<typename T> inline typename OwnPtr<T>::PtrType getPtr(const OwnPtr<
T>& p) | 211 template<typename T> inline typename OwnPtr<T>::PtrType getPtr(const OwnPtr<
T>& p) |
| 214 { | 212 { |
| 215 return p.get(); | 213 return p.get(); |
| 216 } | 214 } |
| 217 | 215 |
| 218 } // namespace WTF | 216 } // namespace WTF |
| 219 | 217 |
| 220 using WTF::OwnPtr; | 218 using WTF::OwnPtr; |
| 221 | 219 |
| 222 #endif // WTF_OwnPtr_h | 220 #endif // WTF_OwnPtr_h |
| OLD | NEW |