Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1163)

Unified Diff: xfa/src/fxbarcode/common/BC_CommonByteArray.cpp

Issue 1726373002: Remove foo != NULL checks in xfa/src/fxbarcode. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp ('k') | xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
index e085ffcec2c192269d01416fe3f2d0fdba101049..1a6ef9f63fa59e67325f0a4ad33eefcd05e1d81b 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;
« no previous file with comments | « xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp ('k') | xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698