summaryrefslogtreecommitdiff
path: root/core/include/fxcrt/fx_basic.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-09-22 21:53:22 -0700
committerLei Zhang <thestig@chromium.org>2015-09-22 21:53:22 -0700
commit13fe8c9d74607610b3a535c7edf911eaa8711318 (patch)
treeabfc392171d0ace3144035903f7d930c78a9c96c /core/include/fxcrt/fx_basic.h
parent0244d40daf39caf97f47de9982f4aac88c0c8644 (diff)
downloadpdfium-13fe8c9d74607610b3a535c7edf911eaa8711318.tar.xz
Merge to XFA: Change nonstd::unique_ptr to take a custom deleter.
Code is mostly stolen from Chromium's scoped_ptr. - Add unit tests. - Use this to fix a leak. BUG=chromium:531408 TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1351383004 . (cherry picked from commit cef2a9c51bee4b987fc813013d45dad6535a9a46) Review URL: https://codereview.chromium.org/1358163003 .
Diffstat (limited to 'core/include/fxcrt/fx_basic.h')
-rw-r--r--core/include/fxcrt/fx_basic.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index 661722e1b2..fa536004d4 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -1085,6 +1085,13 @@ class CFX_AutoRestorer {
T m_OldValue;
};
+// Used with nonstd::unique_ptr to Release() objects that can't be deleted.
+template <class T>
+struct ReleaseDeleter {
+ inline void operator()(T* ptr) const { ptr->Release(); }
+};
+
+// TODO(thestig) Remove in favor of nonstd::unique_ptr.
template <class T>
class CFX_SmartPointer {
public:
@@ -1097,6 +1104,7 @@ class CFX_SmartPointer {
protected:
T* m_pObj;
};
+
#define FX_DATALIST_LENGTH 1024
template <size_t unit>
class CFX_SortListArray {