diff options
author | weili <weili@chromium.org> | 2016-08-09 13:45:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-09 13:45:03 -0700 |
commit | e76203dbefd1df075a063ee019c3908513f6bee5 (patch) | |
tree | 2a763852e1d1de3eee6a67285ea96be2874bfb00 /xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp | |
parent | ad5ac7584844b03c5ceed082e5f5158a632405cc (diff) | |
download | pdfium-e76203dbefd1df075a063ee019c3908513f6bee5.tar.xz |
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
Diffstat (limited to 'xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp')
-rw-r--r-- | xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp index b8a032ae68..8dc73c4be4 100644 --- a/xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp +++ b/xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp @@ -20,22 +20,25 @@ * limitations under the License. */ -#include "xfa/fxbarcode/common/BC_CommonByteArray.h" #include "xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.h" +#include <utility> + +#include "xfa/fxbarcode/common/BC_CommonByteArray.h" + CBC_QRCoderBlockPair::CBC_QRCoderBlockPair( - CBC_CommonByteArray* data, - CBC_CommonByteArray* errorCorrection) { - m_dataBytes = data; - m_errorCorrectionBytes = errorCorrection; -} -CBC_QRCoderBlockPair::~CBC_QRCoderBlockPair() { - delete m_dataBytes; - delete m_errorCorrectionBytes; -} -CBC_CommonByteArray* CBC_QRCoderBlockPair::GetDataBytes() { - return m_dataBytes; + std::unique_ptr<CBC_CommonByteArray> data, + std::unique_ptr<CBC_CommonByteArray> errorCorrection) + : m_dataBytes(std::move(data)), + m_errorCorrectionBytes(std::move(errorCorrection)) {} + +CBC_QRCoderBlockPair::~CBC_QRCoderBlockPair() {} + +const CBC_CommonByteArray* CBC_QRCoderBlockPair::GetDataBytes() const { + return m_dataBytes.get(); } -CBC_CommonByteArray* CBC_QRCoderBlockPair::GetErrorCorrectionBytes() { - return m_errorCorrectionBytes; + +const CBC_CommonByteArray* CBC_QRCoderBlockPair::GetErrorCorrectionBytes() + const { + return m_errorCorrectionBytes.get(); } |