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

Unified Diff: core/src/fxcrt/fx_basic_array.cpp

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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 | « core/src/fxcodec/codec/fx_codec_jpx_opj.cpp ('k') | core/src/fxcrt/fx_basic_bstring.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_array.cpp
diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp
index ccb80eba23e43c8e2857ba3054319e26fb2d1a9c..9c4aa0fa35af35ba8886cbaaafad8b3ea42e4350 100644
--- a/core/src/fxcrt/fx_basic_array.cpp
+++ b/core/src/fxcrt/fx_basic_array.cpp
@@ -26,7 +26,7 @@ FX_BOOL CFX_BasicArray::SetSize(int nNewSize) {
return 0 == nNewSize;
}
- if (m_pData == NULL) {
+ if (!m_pData) {
pdfium::base::CheckedNumeric<int> totalSize = nNewSize;
totalSize *= m_nUnitSize;
if (!totalSize.IsValid()) {
@@ -49,7 +49,7 @@ FX_BOOL CFX_BasicArray::SetSize(int nNewSize) {
return FALSE;
}
uint8_t* pNewData = FX_Realloc(uint8_t, m_pData, totalSize.ValueOrDie());
- if (pNewData == NULL) {
+ if (!pNewData) {
return FALSE;
}
FXSYS_memset(pNewData + m_nSize * m_nUnitSize, 0,
@@ -115,7 +115,7 @@ FX_BOOL CFX_BasicArray::RemoveAt(int nIndex, int nCount) {
}
FX_BOOL CFX_BasicArray::InsertAt(int nStartIndex,
const CFX_BasicArray* pNewArray) {
- if (pNewArray == NULL) {
+ if (!pNewArray) {
return FALSE;
}
if (pNewArray->m_nSize == 0) {
@@ -129,7 +129,7 @@ FX_BOOL CFX_BasicArray::InsertAt(int nStartIndex,
return TRUE;
}
const void* CFX_BasicArray::GetDataPtr(int index) const {
- if (index < 0 || index >= m_nSize || m_pData == NULL) {
+ if (index < 0 || index >= m_nSize || !m_pData) {
return NULL;
}
return m_pData + index * m_nUnitSize;
@@ -159,16 +159,14 @@ static void _ClearIndex(int level, int size, void** pIndex) {
FX_Free(pIndex);
return;
}
- for (int i = 0; i < size; i++) {
- if (pIndex[i] == NULL) {
- continue;
- }
- _ClearIndex(level - 1, size, (void**)pIndex[i]);
+ for (int i = 0; i < size; ++i) {
+ if (pIndex[i])
+ _ClearIndex(level - 1, size, (void**)pIndex[i]);
}
FX_Free(pIndex);
}
void CFX_BaseSegmentedArray::RemoveAll() {
- if (m_pIndex == NULL) {
+ if (!m_pIndex) {
return;
}
_ClearIndex(m_IndexDepth, m_IndexSize, (void**)m_pIndex);
@@ -181,7 +179,7 @@ void* CFX_BaseSegmentedArray::Add() {
return GetAt(m_DataSize++);
}
void* pSegment = FX_Alloc2D(uint8_t, m_UnitSize, m_SegmentSize);
- if (m_pIndex == NULL) {
+ if (!m_pIndex) {
m_pIndex = pSegment;
m_DataSize++;
return pSegment;
@@ -217,7 +215,7 @@ void* CFX_BaseSegmentedArray::Add() {
}
void** pSpot = (void**)m_pIndex;
for (i = 1; i < m_IndexDepth; i++) {
- if (pSpot[seg_index / tree_size] == NULL) {
+ if (!pSpot[seg_index / tree_size]) {
pSpot[seg_index / tree_size] = FX_Alloc(void*, m_IndexSize);
}
pSpot = (void**)pSpot[seg_index / tree_size];
@@ -281,7 +279,7 @@ void* CFX_BaseSegmentedArray::IterateIndex(int level,
return IterateSegment((const uint8_t*)pIndex, count, callback, param);
}
for (int i = 0; i < m_IndexSize; i++) {
- if (pIndex[i] == NULL) {
+ if (!pIndex[i]) {
continue;
}
void* p =
@@ -295,7 +293,7 @@ void* CFX_BaseSegmentedArray::IterateIndex(int level,
void* CFX_BaseSegmentedArray::Iterate(FX_BOOL (*callback)(void* param,
void* pData),
void* param) const {
- if (m_pIndex == NULL) {
+ if (!m_pIndex) {
return NULL;
}
int start = 0;
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_jpx_opj.cpp ('k') | core/src/fxcrt/fx_basic_bstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698