From 16fccc51456dbab7e392c3952cc367723f9694f6 Mon Sep 17 00:00:00 2001 From: weili Date: Tue, 9 Aug 2016 10:33:10 -0700 Subject: Use smart pointers for class owned pointers For classes under xfa/fxfa/fm2js, and xfa/fxgraphics, use smart pointers instead of raw pointer to make memory management easier. Also fix some styling issues along the changes. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2222203002 --- xfa/fxgraphics/cfx_path.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'xfa/fxgraphics/cfx_path.cpp') diff --git a/xfa/fxgraphics/cfx_path.cpp b/xfa/fxgraphics/cfx_path.cpp index 892a339469..5adeded977 100644 --- a/xfa/fxgraphics/cfx_path.cpp +++ b/xfa/fxgraphics/cfx_path.cpp @@ -9,22 +9,17 @@ #include "core/fxge/include/cfx_pathdata.h" #include "xfa/fxgraphics/cfx_path_generator.h" -CFX_Path::CFX_Path() { - m_generator = nullptr; -} +CFX_Path::CFX_Path() {} FWL_Error CFX_Path::Create() { if (m_generator) return FWL_Error::PropertyInvalid; - m_generator = new CFX_PathGenerator; - m_generator->Create(); + m_generator.reset(new CFX_PathGenerator()); return FWL_Error::Succeeded; } -CFX_Path::~CFX_Path() { - delete m_generator; -} +CFX_Path::~CFX_Path() {} FWL_Error CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { if (!m_generator) @@ -167,7 +162,7 @@ FWL_Error CFX_Path::Clear() { return FWL_Error::Succeeded; } -FX_BOOL CFX_Path::IsEmpty() { +FX_BOOL CFX_Path::IsEmpty() const { if (!m_generator) return FALSE; if (m_generator->GetPathData()->GetPointCount() == 0) @@ -175,7 +170,7 @@ FX_BOOL CFX_Path::IsEmpty() { return FALSE; } -CFX_PathData* CFX_Path::GetPathData() { +CFX_PathData* CFX_Path::GetPathData() const { if (!m_generator) return nullptr; return m_generator->GetPathData(); -- cgit v1.2.3