diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-03-23 14:54:59 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-23 22:15:24 +0000 |
commit | 6bbb6097b7150dcace3e2fd69caff8b73d59647a (patch) | |
tree | fa55afb4ec041f2e861ec14e48b85df3dcf92df7 /core/fxcrt/cfx_retain_ptr.h | |
parent | 7388470573be4437b0062ec16ba2178bf380790d (diff) | |
download | pdfium-6bbb6097b7150dcace3e2fd69caff8b73d59647a.tar.xz |
Fix CFX_RetainPtr move-assign semantics.
Ensure moved value becomes a nullptr after the move.
Update comment while we're at it.
Change-Id: I7a2999d5f5c5142cc7826cd7880b1e2317b5445f
Reviewed-on: https://pdfium-review.googlesource.com/3163
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_retain_ptr.h')
-rw-r--r-- | core/fxcrt/cfx_retain_ptr.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/fxcrt/cfx_retain_ptr.h b/core/fxcrt/cfx_retain_ptr.h index 0267ae04cd..5db384f334 100644 --- a/core/fxcrt/cfx_retain_ptr.h +++ b/core/fxcrt/cfx_retain_ptr.h @@ -44,7 +44,7 @@ class CFX_RetainPtr { T* Get() const { return m_pObj.get(); } void Swap(CFX_RetainPtr& that) { m_pObj.swap(that.m_pObj); } - // TODO(tsepez): temporary scaffolding, to be removed. + // Useful for passing notion of object ownership across a C API. T* Leak() { return m_pObj.release(); } void Unleak(T* ptr) { m_pObj.reset(ptr); } @@ -54,6 +54,11 @@ class CFX_RetainPtr { return *this; } + CFX_RetainPtr& operator=(CFX_RetainPtr&& that) { + m_pObj.reset(that.Leak()); + return *this; + } + bool operator==(const CFX_RetainPtr& that) const { return Get() == that.Get(); } |