summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/common
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-06-09 18:39:33 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-09 18:39:33 -0700
commit6dc1d7753691c0ff2f390e8ffd95a3182064487e (patch)
tree43d77664973a76c107832ae7b3c3e0f04bba1fe0 /xfa/fxbarcode/common
parentfcf61b39ee597c73e80ba789833fb7fe49878422 (diff)
downloadpdfium-6dc1d7753691c0ff2f390e8ffd95a3182064487e.tar.xz
Get rid of NULLs in xfa/fxbarcode/
Review-Url: https://codereview.chromium.org/2048983002
Diffstat (limited to 'xfa/fxbarcode/common')
-rw-r--r--xfa/fxbarcode/common/BC_CommonBitMatrix.cpp6
-rw-r--r--xfa/fxbarcode/common/BC_CommonByteArray.cpp4
-rw-r--r--xfa/fxbarcode/common/BC_CommonByteMatrix.cpp2
-rw-r--r--xfa/fxbarcode/common/BC_CommonCharacterSetECI.cpp4
-rw-r--r--xfa/fxbarcode/common/BC_CommonDecoderResult.cpp4
-rw-r--r--xfa/fxbarcode/common/BC_CommonECI.cpp8
-rw-r--r--xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp4
-rw-r--r--xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp2
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp4
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp8
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp10
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp18
12 files changed, 35 insertions, 39 deletions
diff --git a/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp b/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp
index 4fff7b1a84..e52f3dca04 100644
--- a/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp
+++ b/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp
@@ -28,7 +28,7 @@ CBC_CommonBitMatrix::CBC_CommonBitMatrix() {
m_width = 0;
m_height = 0;
m_rowSize = 0;
- m_bits = NULL;
+ m_bits = nullptr;
}
void CBC_CommonBitMatrix::Init(int32_t dimension) {
m_width = dimension;
@@ -103,8 +103,8 @@ void CBC_CommonBitMatrix::SetRegion(int32_t left,
}
CBC_CommonBitArray* CBC_CommonBitMatrix::GetRow(int32_t y,
CBC_CommonBitArray* row) {
- CBC_CommonBitArray* rowArray = NULL;
- if (row == NULL || row->GetSize() < m_width) {
+ CBC_CommonBitArray* rowArray = nullptr;
+ if (!row || row->GetSize() < m_width) {
rowArray = new CBC_CommonBitArray(m_width);
} else {
rowArray = new CBC_CommonBitArray(row);
diff --git a/xfa/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/fxbarcode/common/BC_CommonByteArray.cpp
index 1fd6e46420..be48d51b5b 100644
--- a/xfa/fxbarcode/common/BC_CommonByteArray.cpp
+++ b/xfa/fxbarcode/common/BC_CommonByteArray.cpp
@@ -25,7 +25,7 @@
#include "xfa/fxbarcode/common/BC_CommonByteArray.h"
CBC_CommonByteArray::CBC_CommonByteArray() {
- m_bytes = NULL;
+ m_bytes = nullptr;
m_size = 0;
m_index = 0;
}
@@ -65,7 +65,7 @@ void CBC_CommonByteArray::AppendByte(int32_t value) {
m_index++;
}
void CBC_CommonByteArray::Reserve(int32_t capacity) {
- if (m_bytes == NULL || m_size < capacity) {
+ if (!m_bytes || m_size < capacity) {
uint8_t* newArray = FX_Alloc(uint8_t, capacity);
if (m_bytes) {
FXSYS_memcpy(newArray, m_bytes, m_size);
diff --git a/xfa/fxbarcode/common/BC_CommonByteMatrix.cpp b/xfa/fxbarcode/common/BC_CommonByteMatrix.cpp
index 05028bd395..234b384d7a 100644
--- a/xfa/fxbarcode/common/BC_CommonByteMatrix.cpp
+++ b/xfa/fxbarcode/common/BC_CommonByteMatrix.cpp
@@ -26,7 +26,7 @@
CBC_CommonByteMatrix::CBC_CommonByteMatrix(int32_t width, int32_t height) {
m_height = height;
m_width = width;
- m_bytes = NULL;
+ m_bytes = nullptr;
}
void CBC_CommonByteMatrix::Init() {
m_bytes = FX_Alloc2D(uint8_t, m_height, m_width);
diff --git a/xfa/fxbarcode/common/BC_CommonCharacterSetECI.cpp b/xfa/fxbarcode/common/BC_CommonCharacterSetECI.cpp
index d6fa9e472e..ebc5593bf2 100644
--- a/xfa/fxbarcode/common/BC_CommonCharacterSetECI.cpp
+++ b/xfa/fxbarcode/common/BC_CommonCharacterSetECI.cpp
@@ -36,9 +36,9 @@ void CBC_CommonCharacterSetECI::AddCharacterSet(int32_t value,
CFX_ByteString encodingName) {}
CBC_CommonCharacterSetECI* CBC_CommonCharacterSetECI::GetCharacterSetECIByValue(
int32_t value) {
- return NULL;
+ return nullptr;
}
CBC_CommonCharacterSetECI* CBC_CommonCharacterSetECI::GetCharacterSetECIByName(
const CFX_ByteString& name) {
- return NULL;
+ return nullptr;
}
diff --git a/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp b/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp
index 45aff1cae1..ee131e5359 100644
--- a/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp
+++ b/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp
@@ -40,7 +40,7 @@ void CBC_CommonDecoderResult::Init(const CFX_ByteArray& rawBytes,
m_text = text;
m_byteSegments.Copy(byteSegments);
m_ecLevel = ecLevel;
- m_other = NULL;
+ m_other = nullptr;
}
void CBC_CommonDecoderResult::Init(const CFX_ByteArray& rawBytes,
const CFX_ByteString& text,
@@ -53,7 +53,7 @@ void CBC_CommonDecoderResult::Init(const CFX_ByteArray& rawBytes,
m_rawBytes.Copy(rawBytes);
m_text = text;
m_pdf417ecLevel = ecLevel;
- m_other = NULL;
+ m_other = nullptr;
}
void CBC_CommonDecoderResult::setOther(CBC_PDF417ResultMetadata* other) {
m_other = other;
diff --git a/xfa/fxbarcode/common/BC_CommonECI.cpp b/xfa/fxbarcode/common/BC_CommonECI.cpp
index 4e37aec566..30d21310f4 100644
--- a/xfa/fxbarcode/common/BC_CommonECI.cpp
+++ b/xfa/fxbarcode/common/BC_CommonECI.cpp
@@ -32,11 +32,7 @@ int32_t CBC_CommonECI::GetValue() {
return m_value;
}
CBC_CommonECI* CBC_CommonECI::GetEICByValue(int32_t value, int32_t& e) {
- if (value < 0 || value > 999999) {
+ if (value < 0 || value > 999999)
e = BCExceptionBadECI;
- return NULL;
- }
- if (value < 900) {
- }
- return NULL;
+ return nullptr;
}
diff --git a/xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp b/xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
index d4a33229cf..53f18cc21b 100644
--- a/xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
+++ b/xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
@@ -87,7 +87,7 @@ CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) {
for (y = 1; y < 5; y++) {
int32_t row = height * y / 5;
CFX_ByteArray* localLuminances = source->GetRow(row, m_luminance, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
int32_t right = (width << 2) / 5;
int32_t x;
for (x = width / 5; x < right; x++) {
@@ -96,7 +96,7 @@ CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) {
}
}
int32_t blackPoint = EstimateBlackPoint(localBuckets, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CFX_ByteArray> localLuminances(source->GetMatrix());
for (y = 0; y < height; y++) {
int32_t offset = y * width;
diff --git a/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp b/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp
index f64abb61c0..45ffd63858 100644
--- a/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp
+++ b/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp
@@ -197,7 +197,7 @@ CBC_ResultPoint* CBC_WhiteRectangleDetector::GetBlackPointOnSegment(
return new CBC_ResultPoint((FX_FLOAT)x, (FX_FLOAT)y);
}
}
- return NULL;
+ return nullptr;
}
int32_t CBC_WhiteRectangleDetector::DistanceL2(FX_FLOAT aX,
FX_FLOAT aY,
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
index 40e5fa6625..352dc3dab1 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
@@ -44,10 +44,10 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(int32_t degree,
temp.Add(m_field->Exp(d - 1));
CBC_ReedSolomonGF256Poly temp_poly;
temp_poly.Init(m_field, &temp, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
CBC_ReedSolomonGF256Poly* nextGenerator =
lastGenerator->Multiply(&temp_poly, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
m_cachedGenerators.Add(nextGenerator);
lastGenerator = nextGenerator;
}
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
index f31a54747f..8788afbda8 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
@@ -181,13 +181,13 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorLocations(
for (int32_t i = 1; i < 256 && ie < numErrors; i++) {
if (errorLocator->EvaluateAt(i) == 0) {
(*result)[ie] = m_field->Inverse(i, ie);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
ie++;
}
}
if (ie != numErrors) {
e = BCExceptionDegreeNotMatchRoots;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
return result.release();
}
@@ -202,7 +202,7 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes(
std::unique_ptr<CFX_Int32Array> result(tempArray);
for (int32_t i = 0; i < s; i++) {
int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
int32_t denominator = 1;
for (int32_t j = 0; j < s; j++) {
if (i != j) {
@@ -213,7 +213,7 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes(
}
}
int32_t temp = m_field->Inverse(denominator, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
(*result)[i] =
m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse), temp);
}
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
index 33771418d4..da0ad3ff05 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
@@ -23,8 +23,8 @@
#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h"
-CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::QRCodeFild = NULL;
-CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::DataMatrixField = NULL;
+CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::QRCodeFild = nullptr;
+CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::DataMatrixField = nullptr;
void CBC_ReedSolomonGF256::Initialize() {
QRCodeFild = new CBC_ReedSolomonGF256(0x011D);
QRCodeFild->Init();
@@ -73,11 +73,11 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(
int32_t& e) {
if (degree < 0) {
e = BCExceptionDegreeIsNegative;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
if (coefficient == 0) {
CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return temp;
}
CFX_Int32Array coefficients;
@@ -85,7 +85,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(
coefficients[0] = coefficient;
CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly();
temp->Init(this, &coefficients, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return temp;
}
int32_t CBC_ReedSolomonGF256::AddOrSubtract(int32_t a, int32_t b) {
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index aec4a1ca22..0e376ce1a8 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -28,19 +28,19 @@
CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field,
int32_t coefficients) {
- if (field == NULL) {
+ if (!field)
return;
- }
+
m_field = field;
m_coefficients.Add(coefficients);
}
CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly() {
- m_field = NULL;
+ m_field = nullptr;
}
void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field,
CFX_Int32Array* coefficients,
int32_t& e) {
- if (coefficients == NULL || coefficients->GetSize() == 0) {
+ if (!coefficients || coefficients->GetSize() == 0) {
e = BCExceptionCoefficientsSizeIsNull;
BC_EXCEPTION_CHECK_ReturnVoid(e);
}
@@ -98,7 +98,7 @@ int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a) {
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Clone(int32_t& e) {
CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly();
temp->Init(m_field, &m_coefficients, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return temp;
}
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(
@@ -132,7 +132,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(
}
CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly();
temp->Init(m_field, &sumDiff, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return temp;
}
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(
@@ -159,7 +159,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(
}
CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly();
temp->Init(m_field, &product, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return temp;
}
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar,
@@ -177,7 +177,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar,
}
CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly();
temp->Init(m_field, &product, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return temp;
}
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(
@@ -199,7 +199,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(
}
CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly();
temp->Init(m_field, &product, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return temp;
}