summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/common
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2016-02-24 15:26:50 -0800
committerLei Zhang <thestig@chromium.org>2016-02-24 15:26:50 -0800
commit38eaaf36b09b816b963015e33dc4eb02580e0462 (patch)
tree9a2721eb404a2de4ddce91b50cac25b2cac0edb1 /xfa/src/fxbarcode/common
parente1fb98394a6885cf03bdc6391e5a3878aad5b375 (diff)
downloadpdfium-38eaaf36b09b816b963015e33dc4eb02580e0462.tar.xz
Remove foo != NULL checks in xfa/src/fxbarcode.
R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1726373002 .
Diffstat (limited to 'xfa/src/fxbarcode/common')
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp6
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteArray.cpp23
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp5
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp4
-rw-r--r--xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp8
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp10
6 files changed, 17 insertions, 39 deletions
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
index e346967a27..3a8fa15e2b 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
@@ -47,11 +47,7 @@ void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) {
FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
}
CBC_CommonBitMatrix::~CBC_CommonBitMatrix() {
- if (m_bits != NULL) {
- FX_Free(m_bits);
- }
- m_bits = NULL;
- m_height = m_width = m_rowSize = 0;
+ FX_Free(m_bits);
}
FX_BOOL CBC_CommonBitMatrix::Get(int32_t x, int32_t y) {
int32_t offset = y * m_rowSize + (x >> 5);
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
index e085ffcec2..1a6ef9f63f 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
@@ -42,12 +42,7 @@ CBC_CommonByteArray::CBC_CommonByteArray(uint8_t* byteArray, int32_t size) {
m_index = size;
}
CBC_CommonByteArray::~CBC_CommonByteArray() {
- if (m_bytes != NULL) {
- FX_Free(m_bytes);
- m_bytes = NULL;
- }
- m_index = 0;
- m_size = 0;
+ FX_Free(m_bytes);
}
int32_t CBC_CommonByteArray::At(int32_t index) {
return m_bytes[index] & 0xff;
@@ -72,19 +67,19 @@ void CBC_CommonByteArray::AppendByte(int32_t value) {
void CBC_CommonByteArray::Reserve(int32_t capacity) {
if (m_bytes == NULL || m_size < capacity) {
uint8_t* newArray = FX_Alloc(uint8_t, capacity);
- FXSYS_memset(newArray, 0, capacity);
- if (m_bytes != NULL) {
+ if (m_bytes) {
FXSYS_memcpy(newArray, m_bytes, m_size);
- FX_Free(m_bytes);
+ FXSYS_memset(newArray + m_size, 0, capacity - m_size);
+ } else {
+ FXSYS_memset(newArray, 0, capacity);
}
+ FX_Free(m_bytes);
m_bytes = newArray;
m_size = capacity;
}
}
void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count) {
- if (m_bytes != NULL) {
- FX_Free(m_bytes);
- }
+ FX_Free(m_bytes);
m_bytes = FX_Alloc(uint8_t, count);
m_size = count;
FXSYS_memcpy(m_bytes, source + offset, count);
@@ -93,9 +88,7 @@ void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count) {
void CBC_CommonByteArray::Set(CFX_ByteArray* source,
int32_t offset,
int32_t count) {
- if (m_bytes != NULL) {
- FX_Free(m_bytes);
- }
+ FX_Free(m_bytes);
m_bytes = FX_Alloc(uint8_t, count);
m_size = count;
int32_t i;
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
index 656071fa31..69c39a766c 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
@@ -33,10 +33,7 @@ void CBC_CommonByteMatrix::Init() {
FXSYS_memset(m_bytes, 0xff, m_height * m_width);
}
CBC_CommonByteMatrix::~CBC_CommonByteMatrix() {
- if (m_bytes != NULL) {
- FX_Free(m_bytes);
- m_bytes = NULL;
- }
+ FX_Free(m_bytes);
}
int32_t CBC_CommonByteMatrix::GetHeight() {
return m_height;
diff --git a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp
index 5342cfcca7..a4ad0c4e65 100644
--- a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp
@@ -61,9 +61,7 @@ void CBC_CommonDecoderResult::setOther(CBC_PDF417ResultMetadata* other) {
m_other = other;
}
CBC_CommonDecoderResult::~CBC_CommonDecoderResult() {
- if (m_other != NULL) {
- delete m_other;
- }
+ delete m_other;
}
const CFX_ByteArray& CBC_CommonDecoderResult::GetRawBytes() {
return m_rawBytes;
diff --git a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
index 05d079c9c4..ed5899da37 100644
--- a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
+++ b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
@@ -129,7 +129,7 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
z = CBC_AutoPtr<CBC_ResultPoint>(
GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i),
(FX_FLOAT)(left + i), (FX_FLOAT)(down)));
- if (z.get() != NULL) {
+ if (z.get()) {
break;
}
}
@@ -142,7 +142,7 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
t = CBC_AutoPtr<CBC_ResultPoint>(
GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j),
(FX_FLOAT)(left + j), (FX_FLOAT)up));
- if (t.get() != NULL) {
+ if (t.get()) {
break;
}
}
@@ -155,7 +155,7 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
x = CBC_AutoPtr<CBC_ResultPoint>(
GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k),
(FX_FLOAT)(right - k), (FX_FLOAT)up));
- if (x.get() != NULL) {
+ if (x.get()) {
break;
}
}
@@ -168,7 +168,7 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
y = CBC_AutoPtr<CBC_ResultPoint>(
GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m),
(FX_FLOAT)(right - m), (FX_FLOAT)down));
- if (y.get() != NULL) {
+ if (y.get()) {
break;
}
}
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
index 993b9c526a..e5002ce6ee 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
@@ -60,14 +60,8 @@ void CBC_ReedSolomonGF256::Init() {
m_one = new CBC_ReedSolomonGF256Poly(this, 1);
}
CBC_ReedSolomonGF256::~CBC_ReedSolomonGF256() {
- if (m_zero != NULL) {
- delete m_zero;
- m_zero = NULL;
- }
- if (m_one != NULL) {
- delete m_one;
- m_one = NULL;
- }
+ delete m_zero;
+ delete m_one;
}
CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetZero() {
return m_zero;