diff options
author | weili <weili@chromium.org> | 2016-08-09 10:33:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-09 10:33:10 -0700 |
commit | 16fccc51456dbab7e392c3952cc367723f9694f6 (patch) | |
tree | 0bd44bec6b81213db9d1dc487237164cdcaa43a4 /xfa/fxfa/fm2js/xfa_program.cpp | |
parent | af7ab33c73f58f18d0db0c90d93fa0aab0bc83f3 (diff) | |
download | pdfium-16fccc51456dbab7e392c3952cc367723f9694f6.tar.xz |
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
Diffstat (limited to 'xfa/fxfa/fm2js/xfa_program.cpp')
-rw-r--r-- | xfa/fxfa/fm2js/xfa_program.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/xfa/fxfa/fm2js/xfa_program.cpp b/xfa/fxfa/fm2js/xfa_program.cpp index a5c429765f..5146a5e129 100644 --- a/xfa/fxfa/fm2js/xfa_program.cpp +++ b/xfa/fxfa/fm2js/xfa_program.cpp @@ -6,16 +6,14 @@ #include "xfa/fxfa/fm2js/xfa_program.h" -CXFA_FMProgram::CXFA_FMProgram() : m_globalFunction(0) {} -CXFA_FMProgram::~CXFA_FMProgram() { - if (m_globalFunction != 0) { - delete m_globalFunction; - m_globalFunction = 0; - } -} +CXFA_FMProgram::CXFA_FMProgram() {} + +CXFA_FMProgram::~CXFA_FMProgram() {} + int32_t CXFA_FMProgram::Init(const CFX_WideStringC& wsFormcalc) { return m_parse.Init(wsFormcalc, &m_pErrorInfo); } + int32_t CXFA_FMProgram::ParseProgram() { CFX_ArrayTemplate<CXFA_FMExpression*>* expressions = nullptr; m_parse.NextToken(); @@ -30,10 +28,11 @@ int32_t CXFA_FMProgram::ParseProgram() { delete expressions; return -1; } - m_globalFunction = - new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), 0, expressions); + m_globalFunction.reset( + new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), nullptr, expressions)); return 0; } + int32_t CXFA_FMProgram::TranslateProgram(CFX_WideTextBuf& wsJavaScript) { m_globalFunction->ToJavaScript(wsJavaScript); wsJavaScript.AppendChar(0); |