From e76203dbefd1df075a063ee019c3908513f6bee5 Mon Sep 17 00:00:00 2001 From: weili Date: Tue, 9 Aug 2016 13:45:03 -0700 Subject: Use smart pointers for class owned pointers in xfa/fxbarcode For classes under xfa/fxbarcode, 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/2221023003 --- xfa/fxbarcode/BC_TwoDimWriter.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'xfa/fxbarcode/BC_TwoDimWriter.cpp') diff --git a/xfa/fxbarcode/BC_TwoDimWriter.cpp b/xfa/fxbarcode/BC_TwoDimWriter.cpp index 91ea57097a..e4cc6e890a 100644 --- a/xfa/fxbarcode/BC_TwoDimWriter.cpp +++ b/xfa/fxbarcode/BC_TwoDimWriter.cpp @@ -13,14 +13,10 @@ #include "xfa/fxbarcode/BC_Writer.h" #include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" -CBC_TwoDimWriter::CBC_TwoDimWriter() { - m_iCorrectLevel = 1; - m_bFixedSize = TRUE; - m_output = nullptr; -} -CBC_TwoDimWriter::~CBC_TwoDimWriter() { - delete m_output; -} +CBC_TwoDimWriter::CBC_TwoDimWriter() : m_iCorrectLevel(1), m_bFixedSize(TRUE) {} + +CBC_TwoDimWriter::~CBC_TwoDimWriter() {} + void CBC_TwoDimWriter::RenderDeviceResult(CFX_RenderDevice* device, const CFX_Matrix* matrix) { CFX_GraphStateData stateData; @@ -55,7 +51,7 @@ void CBC_TwoDimWriter::RenderDeviceResult(CFX_RenderDevice* device, } } -int32_t CBC_TwoDimWriter::GetErrorCorrectionLevel() { +int32_t CBC_TwoDimWriter::GetErrorCorrectionLevel() const { return m_iCorrectLevel; } @@ -136,7 +132,7 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code, if (topPadding < 0) { topPadding = 0; } - m_output = new CBC_CommonBitMatrix; + m_output.reset(new CBC_CommonBitMatrix); m_output->Init(outputWidth, outputHeight); for (int32_t inputY = 0, outputY = topPadding; (inputY < inputHeight) && (outputY < outputHeight - multiY); -- cgit v1.2.3