From cef2a9c51bee4b987fc813013d45dad6535a9a46 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 22 Sep 2015 19:15:49 -0700 Subject: 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 R=jyasskin@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/1351383004 . --- core/include/fxcrt/fx_basic.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/include') diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h index bc3d81200f..3e556f5439 100644 --- a/core/include/fxcrt/fx_basic.h +++ b/core/include/fxcrt/fx_basic.h @@ -947,6 +947,13 @@ class CFX_AutoRestorer { T m_OldValue; }; +// Used with nonstd::unique_ptr to Release() objects that can't be deleted. +template +struct ReleaseDeleter { + inline void operator()(T* ptr) const { ptr->Release(); } +}; + +// TODO(thestig) Remove in favor of nonstd::unique_ptr. template class CFX_SmartPointer { public: @@ -959,6 +966,7 @@ class CFX_SmartPointer { protected: T* m_pObj; }; + #define FX_DATALIST_LENGTH 1024 template class CFX_SortListArray { -- cgit v1.2.3