summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-12-11 16:26:00 -0800
committerTom Sepez <tsepez@chromium.org>2015-12-11 16:26:00 -0800
commitf75bdb181576e4a4cf8291706a0db86c687e5fc3 (patch)
tree4440158d95c723b1ef02753b4dfa9d1a598e1a87 /xfa/src/fxbarcode
parent74aa4e19a332436ff3bcf539c905e992b1d3ac4e (diff)
downloadpdfium-f75bdb181576e4a4cf8291706a0db86c687e5fc3.tar.xz
XFA: avoid multiplications in FX_Allocs
In some cases, we can use the safe FX_Alloc2D, in others there's an extra multiplication by the size of the type. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1519233002 .
Diffstat (limited to 'xfa/src/fxbarcode')
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp4
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp2
-rw-r--r--xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp2
-rw-r--r--xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp2
-rw-r--r--xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp4
-rw-r--r--xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp2
-rw-r--r--xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp2
7 files changed, 9 insertions, 9 deletions
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
index 0a0930d97c..ec2706b122 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
@@ -34,7 +34,7 @@ void CBC_CommonBitMatrix::Init(int32_t dimension) {
m_height = dimension;
int32_t rowSize = (m_height + 31) >> 5;
m_rowSize = rowSize;
- m_bits = FX_Alloc(int32_t, m_rowSize * m_height);
+ m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height);
FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
}
void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) {
@@ -42,7 +42,7 @@ void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) {
m_height = height;
int32_t rowSize = (width + 31) >> 5;
m_rowSize = rowSize;
- m_bits = FX_Alloc(int32_t, m_rowSize * m_height);
+ m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height);
FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
}
CBC_CommonBitMatrix::~CBC_CommonBitMatrix() {
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
index ee4eee26a9..d6208d41b5 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
@@ -28,7 +28,7 @@ CBC_CommonByteMatrix::CBC_CommonByteMatrix(int32_t width, int32_t height) {
m_bytes = NULL;
}
void CBC_CommonByteMatrix::Init() {
- m_bytes = FX_Alloc(uint8_t, m_height * m_width);
+ m_bytes = FX_Alloc2D(uint8_t, m_height, m_width);
FXSYS_memset(m_bytes, 0xff, m_height * m_width);
}
CBC_CommonByteMatrix::~CBC_CommonByteMatrix() {
diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
index 25438f389a..d2f2507729 100644
--- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
+++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
@@ -80,7 +80,7 @@ uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString& contents,
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
outWidth = bytematrix->GetWidth();
outHeight = bytematrix->GetHeight();
- uint8_t* result = FX_Alloc(uint8_t, outWidth * outHeight);
+ uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight);
FXSYS_memcpy(result, bytematrix->GetArray(), outWidth * outHeight);
delete bytematrix;
delete placement;
diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
index eef810ac44..a2e27faff8 100644
--- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
+++ b/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
@@ -159,7 +159,7 @@ uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents,
CBC_OnedCodaBarReader CodaBarR;
CFX_ByteString data = m_chStart + contents + m_chEnd;
m_iContentLen = data.GetLength();
- uint8_t* result = FX_Alloc(uint8_t, m_iWideNarrRatio * 7 * data.GetLength());
+ uint8_t* result = FX_Alloc2D(uint8_t, m_iWideNarrRatio * 7, data.GetLength());
FX_CHAR ch;
int32_t position = 0;
for (int32_t index = 0; index < data.GetLength(); index++) {
diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp
index af63d19bfe..ba822ce1d2 100644
--- a/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp
+++ b/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp
@@ -360,7 +360,7 @@ int32_t CBC_DecodedBitStreamPaser::byteCompaction(int32_t mode,
if (mode == BYTE_COMPACTION_MODE_LATCH) {
int32_t count = 0;
int64_t value = 0;
- FX_WORD* decodedData = FX_Alloc(FX_WORD, 6 * sizeof(FX_WORD));
+ FX_WORD* decodedData = FX_Alloc(FX_WORD, 6);
CFX_Int32Array byteCompactedCodewords;
byteCompactedCodewords.SetSize(6);
FX_BOOL end = FALSE;
@@ -421,7 +421,7 @@ int32_t CBC_DecodedBitStreamPaser::byteCompaction(int32_t mode,
}
}
if ((count % 5 == 0) && (count > 0)) {
- FX_WORD* decodedData = FX_Alloc(FX_WORD, 6 * sizeof(FX_WORD));
+ FX_WORD* decodedData = FX_Alloc(FX_WORD, 6);
int32_t j = 0;
for (; j < 6; ++j) {
decodedData[5 - j] = (FX_WORD)(value & 0xFF);
diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
index 0fd275c4e6..b0518c6f2c 100644
--- a/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
+++ b/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
@@ -135,7 +135,7 @@ CFX_WideString CBC_PDF417ErrorCorrection::generateErrorCorrection(
int32_t& e) {
int32_t k = getErrorCorrectionCodewordCount(errorCorrectionLevel, e);
BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR)' ');
- FX_WCHAR* ech = FX_Alloc(FX_WCHAR, k * sizeof(FX_WCHAR));
+ FX_WCHAR* ech = FX_Alloc(FX_WCHAR, k);
FXSYS_memset(ech, 0, k * sizeof(FX_WCHAR));
int32_t sld = dataCodewords.GetLength();
for (int32_t i = 0; i < sld; i++) {
diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp
index 457b30b750..d922889b3d 100644
--- a/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp
+++ b/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp
@@ -97,7 +97,7 @@ uint8_t* CBC_PDF417Writer::Encode(const CFX_WideString& contents,
outWidth = temp;
}
}
- uint8_t* result = (uint8_t*)FX_Alloc(uint8_t, outHeight * outWidth);
+ uint8_t* result = FX_Alloc2D(uint8_t, outHeight, outWidth);
FXSYS_memcpy(result, originalScale.GetData(), outHeight * outWidth);
return result;
}