summaryrefslogtreecommitdiff
path: root/fxbarcode
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-30 16:12:02 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-30 20:26:02 +0000
commit0bb1333a9eff1190ddd68f34c71d6a779c69dfef (patch)
tree5a46946c4852f147309e2b1389e6f42d6553abf7 /fxbarcode
parent908c848202ef137e98d96f82a4eadfae551403b7 (diff)
downloadpdfium-0bb1333a9eff1190ddd68f34c71d6a779c69dfef.tar.xz
Add some calls to MakeUnique
This CL replaces some new's with pdfium::MakeUnique. Change-Id: I50faf3ed55e7730b094c14a7989a9dd51cf33cbb Reviewed-on: https://pdfium-review.googlesource.com/3430 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxbarcode')
-rw-r--r--fxbarcode/datamatrix/BC_HighLevelEncoder.cpp13
-rw-r--r--fxbarcode/qrcode/BC_QRCoderEncoder.cpp15
2 files changed, 15 insertions, 13 deletions
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index e2d483cbdf..041272ef8c 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -39,6 +39,7 @@
#include "fxbarcode/datamatrix/BC_TextEncoder.h"
#include "fxbarcode/datamatrix/BC_X12Encoder.h"
#include "fxbarcode/utils.h"
+#include "third_party/base/ptr_util.h"
wchar_t CBC_HighLevelEncoder::LATCH_TO_C40 = 230;
wchar_t CBC_HighLevelEncoder::LATCH_TO_BASE256 = 231;
@@ -95,12 +96,12 @@ CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
}
std::vector<std::unique_ptr<CBC_Encoder>> encoders;
- encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_ASCIIEncoder()));
- encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_C40Encoder()));
- encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_TextEncoder()));
- encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_X12Encoder()));
- encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_EdifactEncoder()));
- encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_Base256Encoder()));
+ encoders.push_back(pdfium::MakeUnique<CBC_ASCIIEncoder>());
+ encoders.push_back(pdfium::MakeUnique<CBC_C40Encoder>());
+ encoders.push_back(pdfium::MakeUnique<CBC_TextEncoder>());
+ encoders.push_back(pdfium::MakeUnique<CBC_X12Encoder>());
+ encoders.push_back(pdfium::MakeUnique<CBC_EdifactEncoder>());
+ encoders.push_back(pdfium::MakeUnique<CBC_Base256Encoder>());
int32_t encodingMode = ASCII_ENCODATION;
while (context.hasMoreCharacters()) {
encoders[encodingMode]->Encode(context, e);
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index b07b700c51..29dc69996b 100644
--- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -39,6 +39,7 @@
#include "fxbarcode/qrcode/BC_QRCoderMatrixUtil.h"
#include "fxbarcode/qrcode/BC_QRCoderMode.h"
#include "fxbarcode/qrcode/BC_QRCoderVersion.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -388,8 +389,8 @@ void CBC_QRCoderEncoder::EncodeWithSpecifyVersion(
if (e != BCExceptionNO)
return;
- std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
- qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
+ auto matrix = pdfium::MakeUnique<CBC_CommonByteMatrix>(
+ qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth());
matrix->Init();
int32_t maskPattern = ChooseMaskPattern(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
@@ -473,8 +474,8 @@ catchException:
if (e != BCExceptionNO)
return;
- std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
- qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
+ auto matrix = pdfium::MakeUnique<CBC_CommonByteMatrix>(
+ qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth());
matrix->Init();
int32_t maskPattern = ChooseMaskPattern(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
@@ -533,8 +534,8 @@ void CBC_QRCoderEncoder::Encode(const CFX_WideString& content,
if (e != BCExceptionNO)
return;
- std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix(
- qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()));
+ auto matrix = pdfium::MakeUnique<CBC_CommonByteMatrix>(
+ qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth());
matrix->Init();
int32_t maskPattern = ChooseMaskPattern(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e);
@@ -878,7 +879,7 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
GetNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes,
numRSBlocks, i, numDataBytesInBlock,
numEcBytesInBlosk);
- std::unique_ptr<CBC_CommonByteArray> dataBytes(new CBC_CommonByteArray);
+ auto dataBytes = pdfium::MakeUnique<CBC_CommonByteArray>();
dataBytes->Set(bits->GetArray(), dataBytesOffset, numDataBytesInBlock);
std::unique_ptr<CBC_CommonByteArray> ecBytes(
GenerateECBytes(dataBytes.get(), numEcBytesInBlosk, e));