Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Unified Diff: xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp

Issue 1734823002: Get rid of CBC_AutoPtr and use std::unique_ptr instead. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index a451ab50b8273afd6879500fb82fa1627c71af71..eb31ddc30179badab70dbd3f2b7606d4ac75c3c3 100644
--- a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -20,7 +20,10 @@
* limitations under the License.
*/
+#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h"
+
#include <algorithm>
+#include <memory>
#include "xfa/src/fxbarcode/BC_UtilCodingConvert.h"
#include "xfa/src/fxbarcode/common/BC_CommonByteArray.h"
@@ -31,8 +34,6 @@
#include "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h"
#include "xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.h"
#include "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h"
-#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h"
-#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h"
#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h"
#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h"
#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h"
@@ -408,10 +409,9 @@ void CBC_QRCoderEncoder::EncodeWithSpecifyVersion(
qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(),
&finalBits, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_CommonByteMatrix* pDecoder = new CBC_CommonByteMatrix(
- qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth());
- pDecoder->Init();
- CBC_AutoPtr<CBC_CommonByteMatrix> matrix(pDecoder);
+ std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
+ qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
+ matrix->Init();
int32_t maskPattern = ChooseMaskPattern(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
@@ -499,10 +499,9 @@ catchException:
qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(),
&finalBits, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_CommonByteMatrix* pDecoder = new CBC_CommonByteMatrix(
- qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth());
- pDecoder->Init();
- CBC_AutoPtr<CBC_CommonByteMatrix> matrix(pDecoder);
+ std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
+ qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
+ matrix->Init();
int32_t maskPattern = ChooseMaskPattern(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
@@ -550,10 +549,9 @@ void CBC_QRCoderEncoder::Encode(const CFX_WideString& content,
qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(),
&finalBits, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_CommonByteMatrix* pDecoder = new CBC_CommonByteMatrix(
- qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth());
- pDecoder->Init();
- CBC_AutoPtr<CBC_CommonByteMatrix> matrix(pDecoder);
+ std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
+ qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
+ matrix->Init();
int32_t maskPattern = ChooseMaskPattern(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
BC_EXCEPTION_CHECK_ReturnVoid(e);

Powered by Google App Engine
This is Rietveld 408576698