summaryrefslogtreecommitdiff
path: root/core/fxcrt/include
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-07-21 14:44:17 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-21 14:44:17 -0700
commitc38cd6eb274429a5755e04d2e22a606375851717 (patch)
tree158c1e58b7d66a715cd7ba1459c55d329f08c49d /core/fxcrt/include
parent1d3348ce0092d6d2a40de5f8433c0d0c16a1e12e (diff)
downloadpdfium-c38cd6eb274429a5755e04d2e22a606375851717.tar.xz
Use smart pointers for graphics device classes
Use unique_ptr for class owned member variables. Also clean up some style issues such as removing unused functions and casting to raw pointer. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2163103002
Diffstat (limited to 'core/fxcrt/include')
-rw-r--r--core/fxcrt/include/fx_memory.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/fxcrt/include/fx_memory.h b/core/fxcrt/include/fx_memory.h
index fa8da6067c..53e6b9d1eb 100644
--- a/core/fxcrt/include/fx_memory.h
+++ b/core/fxcrt/include/fx_memory.h
@@ -23,6 +23,7 @@ void FXMEM_DefaultFree(void* pointer, int flags);
#include <stdlib.h>
#include <limits>
+#include <memory>
#include <new>
NEVER_INLINE void FX_OutOfMemoryTerminate();
@@ -100,6 +101,12 @@ struct ReleaseDeleter {
inline void operator()(T* ptr) const { ptr->Release(); }
};
+// Used to help transfer ownership of a raw pointer to std::unique_ptr.
+template <typename T>
+std::unique_ptr<T> WrapUnique(T* ptr) {
+ return std::unique_ptr<T>(ptr);
+}
+
class CFX_Deletable {
public:
virtual ~CFX_Deletable() {}