summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
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/BC_CommonByteArray.cpp
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/BC_CommonByteArray.cpp')
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteArray.cpp23
1 files changed, 8 insertions, 15 deletions
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;