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>
diff --git a/core/fxcrt/retain_ptr.h b/core/fxcrt/retain_ptr.h
index e14b1ef..02faff6 100644
--- a/core/fxcrt/retain_ptr.h
+++ b/core/fxcrt/retain_ptr.h
@@ -86,6 +86,8 @@
// 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 @@
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);