summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_countedobject.h
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-22 13:01:40 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-22 13:01:40 -0800
commit6136ec6347a5858a85912a805ea41126863558cd (patch)
tree9aee627585a525844e9861fee6012509bbc39a14 /core/fpdfapi/page/cpdf_countedobject.h
parent687fbde2e4ee13637cb3fd9b1fec39a436ef73d7 (diff)
downloadpdfium-6136ec6347a5858a85912a805ea41126863558cd.tar.xz
Ensure CPDF_CountedObjects only made from owned references.
Deletion of said object is still inflicted on the callers. But that's an issue for another day. Review-Url: https://codereview.chromium.org/2523743004
Diffstat (limited to 'core/fpdfapi/page/cpdf_countedobject.h')
-rw-r--r--core/fpdfapi/page/cpdf_countedobject.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/fpdfapi/page/cpdf_countedobject.h b/core/fpdfapi/page/cpdf_countedobject.h
index 97d710cf76..64f936c52c 100644
--- a/core/fpdfapi/page/cpdf_countedobject.h
+++ b/core/fpdfapi/page/cpdf_countedobject.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_PAGE_CPDF_COUNTEDOBJECT_H_
#define CORE_FPDFAPI_PAGE_CPDF_COUNTEDOBJECT_H_
+#include <memory>
+
#include "core/fpdfapi/page/cpdf_colorspace.h"
#include "core/fpdfapi/page/cpdf_pattern.h"
#include "core/fxcrt/fx_system.h"
@@ -14,10 +16,11 @@
template <class T>
class CPDF_CountedObject {
public:
- explicit CPDF_CountedObject(T* ptr) : m_nCount(1), m_pObj(ptr) {}
- void reset(T* ptr) { // CAUTION: tosses prior ref counts.
+ explicit CPDF_CountedObject(std::unique_ptr<T> ptr)
+ : m_nCount(1), m_pObj(ptr.release()) {}
+ void reset(std::unique_ptr<T> ptr) { // CAUTION: tosses prior ref counts.
m_nCount = 1;
- m_pObj = ptr;
+ m_pObj = ptr.release();
}
void clear() { // Now you're all weak ptrs ...
// Guard against accidental re-entry.