summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/common
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-29 11:24:14 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-29 11:24:15 -0700
commitd5d07dcf59ddc6439f73382c6e0b9e6d1851000d (patch)
tree3430639a1c286570a60e946e1b850aeeedaaa05a /xfa/fxbarcode/common
parentcd1e9ff4f432cbc29ed279e6891fb7ddc2ea3734 (diff)
downloadpdfium-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/common')
-rw-r--r--xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp62
-rw-r--r--xfa/fxbarcode/common/BC_WhiteRectangleDetector.h12
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp8
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp66
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h16
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp26
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h16
7 files changed, 113 insertions, 93 deletions
diff --git a/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp b/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp
index 2aeacd1399..f64abb61c0 100644
--- a/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp
+++ b/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp
@@ -59,8 +59,11 @@ CBC_WhiteRectangleDetector::CBC_WhiteRectangleDetector(
m_upInit = y - halfsize;
m_downInit = y + halfsize;
}
+
CBC_WhiteRectangleDetector::~CBC_WhiteRectangleDetector() {}
-CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
+
+CFX_ArrayTemplate<CBC_ResultPoint*>* CBC_WhiteRectangleDetector::Detect(
+ int32_t& e) {
int32_t left = m_leftInit;
int32_t right = m_rightInit;
int32_t up = m_upInit;
@@ -131,9 +134,9 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
if (z)
break;
}
- if (z.get() == NULL) {
+ if (!z.get()) {
e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
std::unique_ptr<CBC_ResultPoint> t;
for (int32_t j = 1; j < maxSize; j++) {
@@ -142,9 +145,9 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
if (t)
break;
}
- if (t.get() == NULL) {
+ if (!t.get()) {
e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
std::unique_ptr<CBC_ResultPoint> x;
for (int32_t k = 1; k < maxSize; k++) {
@@ -153,9 +156,9 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
if (x)
break;
}
- if (x.get() == NULL) {
+ if (!x.get()) {
e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
std::unique_ptr<CBC_ResultPoint> y;
for (int32_t m = 1; m < maxSize; m++) {
@@ -164,17 +167,18 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
if (y)
break;
}
- if (y.get() == NULL) {
+ if (!y.get()) {
e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
return CenterEdges(y.get(), z.get(), x.get(), t.get());
- } else {
- e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- return NULL;
+
+ e = BCExceptionNotFound;
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ return nullptr;
}
+
int32_t CBC_WhiteRectangleDetector::Round(FX_FLOAT d) {
return (int32_t)(d + 0.5f);
}
@@ -203,10 +207,16 @@ int32_t CBC_WhiteRectangleDetector::DistanceL2(FX_FLOAT aX,
float yDiff = aY - bY;
return Round((float)sqrt(xDiff * xDiff + yDiff * yDiff));
}
-CFX_PtrArray* CBC_WhiteRectangleDetector::CenterEdges(CBC_ResultPoint* y,
- CBC_ResultPoint* z,
- CBC_ResultPoint* x,
- CBC_ResultPoint* t) {
+
+CFX_ArrayTemplate<CBC_ResultPoint*>* CBC_WhiteRectangleDetector::CenterEdges(
+ CBC_ResultPoint* y,
+ CBC_ResultPoint* z,
+ CBC_ResultPoint* x,
+ CBC_ResultPoint* t) const {
+ CFX_ArrayTemplate<CBC_ResultPoint*>* result =
+ new CFX_ArrayTemplate<CBC_ResultPoint*>();
+ result->SetSize(4);
+
float yi = y->GetX();
float yj = y->GetY();
float zi = z->GetX();
@@ -215,24 +225,22 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::CenterEdges(CBC_ResultPoint* y,
float xj = x->GetY();
float ti = t->GetX();
float tj = t->GetY();
+
if (yi < m_width / 2) {
- CFX_PtrArray* result = new CFX_PtrArray;
- result->SetSize(4);
(*result)[0] = new CBC_ResultPoint(ti - CORR, tj + CORR);
(*result)[1] = new CBC_ResultPoint(zi + CORR, zj + CORR);
(*result)[2] = new CBC_ResultPoint(xi - CORR, xj - CORR);
(*result)[3] = new CBC_ResultPoint(yi + CORR, yj - CORR);
return result;
- } else {
- CFX_PtrArray* result = new CFX_PtrArray;
- result->SetSize(4);
- (*result)[0] = new CBC_ResultPoint(ti + CORR, tj + CORR);
- (*result)[1] = new CBC_ResultPoint(zi + CORR, zj - CORR);
- (*result)[2] = new CBC_ResultPoint(xi - CORR, xj + CORR);
- (*result)[3] = new CBC_ResultPoint(yi - CORR, yj - CORR);
- return result;
}
+
+ (*result)[0] = new CBC_ResultPoint(ti + CORR, tj + CORR);
+ (*result)[1] = new CBC_ResultPoint(zi + CORR, zj - CORR);
+ (*result)[2] = new CBC_ResultPoint(xi - CORR, xj + CORR);
+ (*result)[3] = new CBC_ResultPoint(yi - CORR, yj - CORR);
+ return result;
}
+
FX_BOOL CBC_WhiteRectangleDetector::ContainsBlackPoint(int32_t a,
int32_t b,
int32_t fixed,
diff --git a/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h b/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h
index d713d0fa99..f3ac77a9c0 100644
--- a/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h
+++ b/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h
@@ -20,9 +20,10 @@ class CBC_WhiteRectangleDetector {
int32_t x,
int32_t y);
virtual ~CBC_WhiteRectangleDetector();
- CFX_PtrArray* Detect(int32_t& e);
virtual void Init(int32_t& e);
+ CFX_ArrayTemplate<CBC_ResultPoint*>* Detect(int32_t& e);
+
private:
int32_t Round(float d);
CBC_ResultPoint* GetBlackPointOnSegment(FX_FLOAT aX,
@@ -30,10 +31,11 @@ class CBC_WhiteRectangleDetector {
FX_FLOAT bX,
FX_FLOAT bY);
int32_t DistanceL2(FX_FLOAT aX, FX_FLOAT aY, FX_FLOAT bX, FX_FLOAT bY);
- CFX_PtrArray* CenterEdges(CBC_ResultPoint* y,
- CBC_ResultPoint* z,
- CBC_ResultPoint* x,
- CBC_ResultPoint* t);
+ CFX_ArrayTemplate<CBC_ResultPoint*>* CenterEdges(CBC_ResultPoint* y,
+ CBC_ResultPoint* z,
+ CBC_ResultPoint* x,
+ CBC_ResultPoint* t) const;
+
FX_BOOL ContainsBlackPoint(int32_t a,
int32_t b,
int32_t fixed,
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
index 00bd7811d8..40e5fa6625 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
@@ -79,10 +79,10 @@ void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode,
std::unique_ptr<CBC_ReedSolomonGF256Poly> infoTemp(
info.MultiplyByMonomial(ecBytes, 1, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- std::unique_ptr<CFX_PtrArray> temp(infoTemp->Divide(generator, e));
+ std::unique_ptr<CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>> temp(
+ infoTemp->Divide(generator, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_ReedSolomonGF256Poly* remainder =
- (CBC_ReedSolomonGF256Poly*)(temp->operator[](1));
+ CBC_ReedSolomonGF256Poly* remainder = (*temp)[1];
CFX_Int32Array* coefficients = remainder->GetCoefficients();
int32_t numZeroCoefficients = ecBytes - coefficients->GetSize();
for (int32_t i = 0; i < numZeroCoefficients; i++) {
@@ -93,7 +93,7 @@ void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode,
coefficients->operator[](y);
}
for (int32_t k = 0; k < temp->GetSize(); k++) {
- delete (CBC_ReedSolomonGF256Poly*)(*temp)[k];
+ delete (*temp)[k];
}
}
CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder() {
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
index ff91c9ddc3..81abd56370 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
@@ -58,13 +58,11 @@ void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received,
std::unique_ptr<CBC_ReedSolomonGF256Poly> temp(
m_field->BuildMonomial(twoS, 1, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- std::unique_ptr<CFX_PtrArray> sigmaOmega(
+ std::unique_ptr<CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>> sigmaOmega(
RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(
- (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[0]);
- std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(
- (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[1]);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma((*sigmaOmega)[0]);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> omega((*sigmaOmega)[1]);
std::unique_ptr<CFX_Int32Array> errorLocations(
FindErrorLocations(sigma.get(), e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
@@ -83,28 +81,29 @@ void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received,
(*received)[position], (*errorMagnitudes)[k]);
}
}
-CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(
- CBC_ReedSolomonGF256Poly* a,
- CBC_ReedSolomonGF256Poly* b,
- int32_t R,
- int32_t& e) {
+
+CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>*
+CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(CBC_ReedSolomonGF256Poly* a,
+ CBC_ReedSolomonGF256Poly* b,
+ int32_t R,
+ int32_t& e) {
if (a->GetDegree() < b->GetDegree()) {
CBC_ReedSolomonGF256Poly* temp = a;
a = b;
b = temp;
}
std::unique_ptr<CBC_ReedSolomonGF256Poly> rLast(a->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> r(b->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> sLast(m_field->GetOne()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> s(m_field->GetZero()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> tLast(m_field->GetZero()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> t(m_field->GetOne()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
while (r->GetDegree() >= R / 2) {
std::unique_ptr<CBC_ReedSolomonGF256Poly> rLastLast = std::move(rLast);
std::unique_ptr<CBC_ReedSolomonGF256Poly> sLastLast = std::move(sLast);
@@ -114,53 +113,54 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(
tLast = std::move(t);
if (rLast->IsZero()) {
e = BCExceptionR_I_1IsZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
r.reset(rLastLast->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> q(m_field->GetZero()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree());
int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
while (r->GetDegree() >= rLast->GetDegree() && !(r->IsZero())) {
int32_t degreeDiff = r->GetDegree() - rLast->GetDegree();
int32_t scale =
m_field->Multiply(r->GetCoefficients(r->GetDegree()), dltInverse);
std::unique_ptr<CBC_ReedSolomonGF256Poly> build(
m_field->BuildMonomial(degreeDiff, scale, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
q.reset(q->AddOrSubtract(build.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> multiply(
rLast->MultiplyByMonomial(degreeDiff, scale, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
r.reset(r->AddOrSubtract(multiply.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
std::unique_ptr<CBC_ReedSolomonGF256Poly> temp1(
q->Multiply(sLast.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
s.reset(temp1->AddOrSubtract(sLastLast.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> temp5(
q->Multiply(tLast.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
t.reset(temp5->AddOrSubtract(tLastlast.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
int32_t sigmaTildeAtZero = t->GetCoefficients(0);
if (sigmaTildeAtZero == 0) {
e = BCExceptionIsZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(t->Multiply(inverse, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(r->Multiply(inverse, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CFX_PtrArray* temp = new CFX_PtrArray;
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* temp =
+ new CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>();
temp->Add(sigma.release());
temp->Add(omega.release());
return temp;
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
index f44f92072e..d42af6a27a 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
@@ -13,23 +13,25 @@ class CBC_ReedSolomonGF256;
class CBC_ReedSolomonGF256Poly;
class CBC_ReedSolomonDecoder {
- private:
- CBC_ReedSolomonGF256* m_field;
-
public:
CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256* field);
virtual ~CBC_ReedSolomonDecoder();
+
void Decode(CFX_Int32Array* received, int32_t twoS, int32_t& e);
- CFX_PtrArray* RunEuclideanAlgorithm(CBC_ReedSolomonGF256Poly* a,
- CBC_ReedSolomonGF256Poly* b,
- int32_t R,
- int32_t& e);
+ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* RunEuclideanAlgorithm(
+ CBC_ReedSolomonGF256Poly* a,
+ CBC_ReedSolomonGF256Poly* b,
+ int32_t R,
+ int32_t& e);
CFX_Int32Array* FindErrorLocations(CBC_ReedSolomonGF256Poly* errorLocator,
int32_t& e);
CFX_Int32Array* FindErrorMagnitudes(CBC_ReedSolomonGF256Poly* errorEvaluator,
CFX_Int32Array* errorLocations,
FX_BOOL dataMatrix,
int32_t& e);
+
+ private:
+ CBC_ReedSolomonGF256* m_field;
};
#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONDECODER_H_
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index ee22390df6..b3c4326ed6 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -213,21 +213,23 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
}
-CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other,
- int32_t& e) {
+
+CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* CBC_ReedSolomonGF256Poly::Divide(
+ CBC_ReedSolomonGF256Poly* other,
+ int32_t& e) {
if (other->IsZero()) {
e = BCExceptionDivideByZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient(
m_field->GetZero()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> remainder(Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree());
int32_t inverseDenominatorLeadingTeam =
m_field->Inverse(denominatorLeadingTerm, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
while (remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero()) {
int32_t degreeDifference = remainder->GetDegree() - other->GetDegree();
int32_t scale =
@@ -235,20 +237,22 @@ CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other,
inverseDenominatorLeadingTeam);
std::unique_ptr<CBC_ReedSolomonGF256Poly> term(
other->MultiplyByMonomial(degreeDifference, scale, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> iteratorQuotient(
m_field->BuildMonomial(degreeDifference, scale, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
remainder.reset(remainder->AddOrSubtract(term.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
- CFX_PtrArray* tempPtrA = new CFX_PtrArray;
+ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* tempPtrA =
+ new CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>();
tempPtrA->Add(quotient.release());
tempPtrA->Add(remainder.release());
return tempPtrA;
}
+
CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() {
m_coefficients.RemoveAll();
}
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
index aa549efe60..03580c2350 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
@@ -11,11 +11,15 @@
class CBC_ReedSolomonGF256;
-class CBC_ReedSolomonGF256Poly {
+class CBC_ReedSolomonGF256Poly final {
public:
CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients);
CBC_ReedSolomonGF256Poly();
- virtual ~CBC_ReedSolomonGF256Poly();
+ ~CBC_ReedSolomonGF256Poly();
+ void Init(CBC_ReedSolomonGF256* field,
+ CFX_Int32Array* coefficients,
+ int32_t& e);
+
int32_t GetCoefficients(int32_t degree);
CFX_Int32Array* GetCoefficients();
int32_t GetDegree();
@@ -29,11 +33,11 @@ class CBC_ReedSolomonGF256Poly {
CBC_ReedSolomonGF256Poly* MultiplyByMonomial(int32_t degree,
int32_t coefficient,
int32_t& e);
- CFX_PtrArray* Divide(CBC_ReedSolomonGF256Poly* other, int32_t& e);
+ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* Divide(
+ CBC_ReedSolomonGF256Poly* other,
+ int32_t& e);
+
CBC_ReedSolomonGF256Poly* Clone(int32_t& e);
- virtual void Init(CBC_ReedSolomonGF256* field,
- CFX_Int32Array* coefficients,
- int32_t& e);
private:
CBC_ReedSolomonGF256* m_field;