summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-09-17 23:52:37 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-17 23:52:37 +0000
commit638b004e829f0ca84172120af4a0bca436460281 (patch)
treedacd59378eee3e3ec371676471ad1276616eff84
parent0127cdaeff86335e9a2954706bdf0edee79e7975 (diff)
downloadpdfium-638b004e829f0ca84172120af4a0bca436460281.tar.xz
Make fxcrt::Retainable non-copyable.
Because copying ref-counts from one object to another is a bad idea and sure to leak. Change-Id: I5f2c0891d08c893eb1ac8fb8a5908d975295ae2e Reviewed-on: https://pdfium-review.googlesource.com/42670 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fxcrt/retain_ptr.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/fxcrt/retain_ptr.h b/core/fxcrt/retain_ptr.h
index e14b1ef5dc..02faff611d 100644
--- a/core/fxcrt/retain_ptr.h
+++ b/core/fxcrt/retain_ptr.h
@@ -86,6 +86,8 @@ class RetainPtr {
// Trivial implementation - internal ref count with virtual destructor.
class Retainable {
public:
+ Retainable() = default;
+
bool HasOneRef() const { return m_nRefCount == 1; }
protected:
@@ -98,6 +100,9 @@ class Retainable {
template <typename U>
friend class RetainPtr;
+ Retainable(const Retainable& that) = delete;
+ Retainable& operator=(const Retainable& that) = delete;
+
void Retain() { ++m_nRefCount; }
void Release() {
ASSERT(m_nRefCount > 0);