diff options
author | tsepez <tsepez@chromium.org> | 2016-04-29 11:24:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-29 11:24:15 -0700 |
commit | d5d07dcf59ddc6439f73382c6e0b9e6d1851000d (patch) | |
tree | 3430639a1c286570a60e946e1b850aeeedaaa05a /xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp | |
parent | cd1e9ff4f432cbc29ed279e6891fb7ddc2ea3734 (diff) | |
download | pdfium-d5d07dcf59ddc6439f73382c6e0b9e6d1851000d.tar.xz |
Replace CFX_PtrArray with typesafe CFX_ArrayTemplate, part 8
This also removes another hand-written bubblesort in favor of
the std::sort() STL function.
Review-Url: https://codereview.chromium.org/1937513002
Diffstat (limited to 'xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp')
-rw-r--r-- | xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp index 3f765aa8f9..4276066444 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp @@ -42,40 +42,37 @@ void CBC_DataMatrixDecoder::Init() { CBC_DataMatrixDecoder::~CBC_DataMatrixDecoder() { delete m_rsDecoder; } + CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode( CBC_CommonBitMatrix* bits, int32_t& e) { CBC_DataMatrixBitMatrixParser parser; parser.Init(bits, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); CBC_DataMatrixVersion* version = parser.GetVersion(); std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CFX_PtrArray* dataBlocks = + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>* dataBlocks = CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); int32_t dataBlocksCount = dataBlocks->GetSize(); int32_t totalBytes = 0; int32_t i, j; for (i = 0; i < dataBlocksCount; i++) { - totalBytes += - ((CBC_DataMatrixDataBlock*)(*dataBlocks)[i])->GetNumDataCodewords(); + totalBytes += (*dataBlocks)[i]->GetNumDataCodewords(); } CFX_ByteArray resultBytes; resultBytes.SetSize(totalBytes); for (j = 0; j < dataBlocksCount; j++) { - CFX_ByteArray* codewordBytes = - ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetCodewords(); - int32_t numDataCodewords = - ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetNumDataCodewords(); + CFX_ByteArray* codewordBytes = (*dataBlocks)[j]->GetCodewords(); + int32_t numDataCodewords = (*dataBlocks)[j]->GetNumDataCodewords(); CorrectErrors(*codewordBytes, numDataCodewords, e); if (e != BCExceptionNO) { for (int32_t i = 0; i < dataBlocks->GetSize(); i++) { - delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i]; + delete (*dataBlocks)[i]; } delete dataBlocks; - dataBlocks = NULL; - return NULL; + return nullptr; } int32_t i; for (i = 0; i < numDataCodewords; i++) { @@ -83,15 +80,15 @@ CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode( } } for (i = 0; i < (dataBlocks->GetSize()); i++) { - delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i]; + delete (*dataBlocks)[i]; } delete dataBlocks; - dataBlocks = NULL; CBC_CommonDecoderResult* resultR = CBC_DataMatrixDecodedBitStreamParser::Decode(resultBytes, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); return resultR; } + void CBC_DataMatrixDecoder::CorrectErrors(CFX_ByteArray& codewordBytes, int32_t numDataCodewords, int32_t& e) { |