summaryrefslogtreecommitdiff
path: root/core/src/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fxcrt')
-rw-r--r--core/src/fxcrt/fx_basic_bstring.cpp4
-rw-r--r--core/src/fxcrt/fx_basic_buffer.cpp6
-rw-r--r--core/src/fxcrt/fx_basic_list.cpp13
-rw-r--r--core/src/fxcrt/fx_basic_maps.cpp30
-rw-r--r--core/src/fxcrt/fx_basic_plex.cpp9
-rw-r--r--core/src/fxcrt/fx_basic_utf.cpp2
-rw-r--r--core/src/fxcrt/fx_basic_wstring.cpp10
-rw-r--r--core/src/fxcrt/fx_extension.cpp18
-rw-r--r--core/src/fxcrt/fx_xml_parser.cpp1
-rw-r--r--core/src/fxcrt/xml_int.h2
10 files changed, 45 insertions, 50 deletions
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp
index 7576ab86eb..cd4770282a 100644
--- a/core/src/fxcrt/fx_basic_bstring.cpp
+++ b/core/src/fxcrt/fx_basic_bstring.cpp
@@ -295,7 +295,7 @@ void CFX_ByteString::CopyBeforeWrite() {
m_pData->Release();
FX_STRSIZE nDataLength = pData->m_nDataLength;
m_pData = StringData::Create(nDataLength);
- if (m_pData != NULL) {
+ if (m_pData) {
FXSYS_memcpy(m_pData->m_String, pData->m_String, nDataLength + 1);
}
}
@@ -698,7 +698,7 @@ FX_STRSIZE CFX_ByteString::Insert(FX_STRSIZE nIndex, FX_CHAR ch) {
if (!m_pData) {
return 0;
}
- if (pOldData != NULL) {
+ if (pOldData) {
FXSYS_memmove(m_pData->m_String, pstr, (pOldData->m_nDataLength + 1));
pOldData->Release();
} else {
diff --git a/core/src/fxcrt/fx_basic_buffer.cpp b/core/src/fxcrt/fx_basic_buffer.cpp
index cc72e471f1..e5c6c6d4b9 100644
--- a/core/src/fxcrt/fx_basic_buffer.cpp
+++ b/core/src/fxcrt/fx_basic_buffer.cpp
@@ -151,7 +151,7 @@ void CFX_WideTextBuf::AppendChar(FX_WCHAR ch) {
if (m_AllocSize < m_DataSize + (FX_STRSIZE)sizeof(FX_WCHAR)) {
ExpandBuf(sizeof(FX_WCHAR));
}
- ASSERT(m_pBuffer != NULL);
+ ASSERT(m_pBuffer);
*(FX_WCHAR*)(m_pBuffer + m_DataSize) = ch;
m_DataSize += sizeof(FX_WCHAR);
}
@@ -170,7 +170,7 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(int i) {
if (m_AllocSize < m_DataSize + (FX_STRSIZE)(len * sizeof(FX_WCHAR))) {
ExpandBuf(len * sizeof(FX_WCHAR));
}
- ASSERT(m_pBuffer != NULL);
+ ASSERT(m_pBuffer);
FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer + m_DataSize);
for (FX_STRSIZE j = 0; j < len; j++) {
*str++ = buf[j];
@@ -184,7 +184,7 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(double f) {
if (m_AllocSize < m_DataSize + (FX_STRSIZE)(len * sizeof(FX_WCHAR))) {
ExpandBuf(len * sizeof(FX_WCHAR));
}
- ASSERT(m_pBuffer != NULL);
+ ASSERT(m_pBuffer);
FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer + m_DataSize);
for (FX_STRSIZE i = 0; i < len; i++) {
*str++ = buf[i];
diff --git a/core/src/fxcrt/fx_basic_list.cpp b/core/src/fxcrt/fx_basic_list.cpp
index de5d9f3269..292e2a7b53 100644
--- a/core/src/fxcrt/fx_basic_list.cpp
+++ b/core/src/fxcrt/fx_basic_list.cpp
@@ -17,7 +17,7 @@ CFX_PtrList::CFX_PtrList(int nBlockSize)
FX_POSITION CFX_PtrList::AddTail(void* newElement) {
CNode* pNewNode = NewNode(m_pNodeTail, NULL);
pNewNode->data = newElement;
- if (m_pNodeTail != NULL) {
+ if (m_pNodeTail) {
m_pNodeTail->pNext = pNewNode;
} else {
m_pNodeHead = pNewNode;
@@ -28,7 +28,7 @@ FX_POSITION CFX_PtrList::AddTail(void* newElement) {
FX_POSITION CFX_PtrList::AddHead(void* newElement) {
CNode* pNewNode = NewNode(NULL, m_pNodeHead);
pNewNode->data = newElement;
- if (m_pNodeHead != NULL) {
+ if (m_pNodeHead) {
m_pNodeHead->pPrev = pNewNode;
} else {
m_pNodeTail = pNewNode;
@@ -43,7 +43,7 @@ FX_POSITION CFX_PtrList::InsertAfter(FX_POSITION position, void* newElement) {
CNode* pOldNode = (CNode*)position;
CNode* pNewNode = NewNode(pOldNode, pOldNode->pNext);
pNewNode->data = newElement;
- if (pOldNode->pNext != NULL) {
+ if (pOldNode->pNext) {
pOldNode->pNext->pPrev = pNewNode;
} else {
m_pNodeTail = pNewNode;
@@ -91,7 +91,6 @@ CFX_PtrList::CNode* CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev,
m_pNodeFree = pNode;
}
}
- ASSERT(m_pNodeFree != NULL);
CFX_PtrList::CNode* pNode = m_pNodeFree;
m_pNodeFree = m_pNodeFree->pNext;
pNode->pPrev = pPrev;
@@ -122,9 +121,9 @@ FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const {
} else {
pNode = pNode->pNext;
}
- for (; pNode != NULL; pNode = pNode->pNext)
- if (pNode->data == searchValue) {
+ for (; pNode; pNode = pNode->pNext) {
+ if (pNode->data == searchValue)
return (FX_POSITION)pNode;
- }
+ }
return NULL;
}
diff --git a/core/src/fxcrt/fx_basic_maps.cpp b/core/src/fxcrt/fx_basic_maps.cpp
index aadeb15cb4..f8751ae340 100644
--- a/core/src/fxcrt/fx_basic_maps.cpp
+++ b/core/src/fxcrt/fx_basic_maps.cpp
@@ -34,15 +34,15 @@ FX_DWORD CFX_MapPtrToPtr::HashKey(void* key) const {
void CFX_MapPtrToPtr::GetNextAssoc(FX_POSITION& rNextPosition,
void*& rKey,
void*& rValue) const {
- ASSERT(m_pHashTable != NULL);
+ ASSERT(m_pHashTable);
CAssoc* pAssocRet = (CAssoc*)rNextPosition;
- ASSERT(pAssocRet != NULL);
+ ASSERT(pAssocRet);
if (pAssocRet == (CAssoc*)-1) {
- for (FX_DWORD nBucket = 0; nBucket < m_nHashTableSize; nBucket++)
- if ((pAssocRet = m_pHashTable[nBucket]) != NULL) {
+ for (FX_DWORD nBucket = 0; nBucket < m_nHashTableSize; nBucket++) {
+ if ((pAssocRet = m_pHashTable[nBucket]) != NULL)
break;
- }
- ASSERT(pAssocRet != NULL);
+ }
+ ASSERT(pAssocRet);
}
CAssoc* pAssocNext;
if ((pAssocNext = pAssocRet->pNext) == NULL) {
@@ -95,10 +95,9 @@ CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::GetAssocAt(void* key,
return NULL;
}
CAssoc* pAssoc;
- for (pAssoc = m_pHashTable[nHash]; pAssoc != NULL; pAssoc = pAssoc->pNext) {
- if (pAssoc->key == key) {
+ for (pAssoc = m_pHashTable[nHash]; pAssoc; pAssoc = pAssoc->pNext) {
+ if (pAssoc->key == key)
return pAssoc;
- }
}
return NULL;
}
@@ -114,7 +113,6 @@ CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::NewAssoc() {
m_pFreeList = pAssoc;
}
}
- ASSERT(m_pFreeList != NULL);
CFX_MapPtrToPtr::CAssoc* pAssoc = m_pFreeList;
m_pFreeList = m_pFreeList->pNext;
m_nCount++;
@@ -140,7 +138,7 @@ FX_BOOL CFX_MapPtrToPtr::RemoveKey(void* key) {
CAssoc** ppAssocPrev;
ppAssocPrev = &m_pHashTable[HashKey(key) % m_nHashTableSize];
CAssoc* pAssoc;
- for (pAssoc = *ppAssocPrev; pAssoc != NULL; pAssoc = pAssoc->pNext) {
+ for (pAssoc = *ppAssocPrev; pAssoc; pAssoc = pAssoc->pNext) {
if (pAssoc->key == key) {
*ppAssocPrev = pAssoc->pNext;
FreeAssoc(pAssoc);
@@ -293,10 +291,10 @@ FX_BOOL CFX_CMapByteStringToPtr::Lookup(const CFX_ByteStringC& key,
return TRUE;
}
void CFX_CMapByteStringToPtr::SetAt(const CFX_ByteStringC& key, void* value) {
- ASSERT(value != NULL);
- int index, key_len = key.GetLength();
+ ASSERT(value);
+ int key_len = key.GetLength();
int size = m_Buffer.GetSize();
- for (index = 0; index < size; index++) {
+ for (int index = 0; index < size; index++) {
_CompactString* pKey = (_CompactString*)m_Buffer.GetAt(index);
if (!_CompactStringSame(pKey, key.GetPtr(), key_len)) {
continue;
@@ -304,7 +302,7 @@ void CFX_CMapByteStringToPtr::SetAt(const CFX_ByteStringC& key, void* value) {
*(void**)(pKey + 1) = value;
return;
}
- for (index = 0; index < size; index++) {
+ for (int index = 0; index < size; index++) {
_CompactString* pKey = (_CompactString*)m_Buffer.GetAt(index);
if (pKey->m_CompactLen) {
continue;
@@ -319,7 +317,7 @@ void CFX_CMapByteStringToPtr::SetAt(const CFX_ByteStringC& key, void* value) {
}
void CFX_CMapByteStringToPtr::AddValue(const CFX_ByteStringC& key,
void* value) {
- ASSERT(value != NULL);
+ ASSERT(value);
_CompactString* pKey = (_CompactString*)m_Buffer.Add();
_CompactStringStore(pKey, key.GetPtr(), key.GetLength());
*(void**)(pKey + 1) = value;
diff --git a/core/src/fxcrt/fx_basic_plex.cpp b/core/src/fxcrt/fx_basic_plex.cpp
index b6383ecf20..91cc1313bd 100644
--- a/core/src/fxcrt/fx_basic_plex.cpp
+++ b/core/src/fxcrt/fx_basic_plex.cpp
@@ -18,10 +18,9 @@ CFX_Plex* CFX_Plex::Create(CFX_Plex*& pHead,
}
void CFX_Plex::FreeDataChain() {
CFX_Plex* p = this;
- while (p != NULL) {
- uint8_t* bytes = (uint8_t*)p;
- CFX_Plex* pNext = p->pNext;
- FX_Free(bytes);
- p = pNext;
+ while (p) {
+ CFX_Plex* old = p;
+ p = p->pNext;
+ FX_Free(old);
}
}
diff --git a/core/src/fxcrt/fx_basic_utf.cpp b/core/src/fxcrt/fx_basic_utf.cpp
index 749e1226d3..3625feb130 100644
--- a/core/src/fxcrt/fx_basic_utf.cpp
+++ b/core/src/fxcrt/fx_basic_utf.cpp
@@ -74,7 +74,7 @@ void CFX_UTF8Encoder::Input(FX_WCHAR unicode) {
}
}
CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len) {
- FXSYS_assert(pwsStr != NULL);
+ FXSYS_assert(pwsStr);
if (len < 0) {
len = FXSYS_wcslen(pwsStr);
}
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index 78746e383c..a3de140e8b 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -258,7 +258,7 @@ void CFX_WideString::CopyBeforeWrite() {
m_pData->Release();
FX_STRSIZE nDataLength = pData->m_nDataLength;
m_pData = StringData::Create(nDataLength);
- if (m_pData != NULL) {
+ if (m_pData) {
FXSYS_memcpy(m_pData->m_String, pData->m_String,
(nDataLength + 1) * sizeof(FX_WCHAR));
}
@@ -540,7 +540,7 @@ FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const {
return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
}
void CFX_WideString::TrimRight(const FX_WCHAR* lpszTargetList) {
- FXSYS_assert(lpszTargetList != NULL);
+ FXSYS_assert(lpszTargetList);
if (m_pData == NULL || *lpszTargetList == 0) {
return;
}
@@ -569,7 +569,7 @@ void CFX_WideString::TrimRight() {
TrimRight(L"\x09\x0a\x0b\x0c\x0d\x20");
}
void CFX_WideString::TrimLeft(const FX_WCHAR* lpszTargets) {
- FXSYS_assert(lpszTargets != NULL);
+ FXSYS_assert(lpszTargets);
if (m_pData == NULL || *lpszTargets == 0) {
return;
}
@@ -617,7 +617,7 @@ FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld,
FX_WCHAR* lpszEnd = m_pData->m_String + m_pData->m_nDataLength;
FX_WCHAR* lpszTarget;
{
- while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) != NULL &&
+ while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) &&
lpszStart < lpszEnd) {
nCount++;
lpszStart = lpszTarget + nSourceLen;
@@ -678,7 +678,7 @@ FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE nIndex, FX_WCHAR ch) {
if (!m_pData) {
return 0;
}
- if (pOldData != NULL) {
+ if (pOldData) {
FXSYS_memmove(m_pData->m_String, pstr,
(pOldData->m_nDataLength + 1) * sizeof(FX_WCHAR));
pOldData->Release();
diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp
index 84186fb769..fd1ecafe06 100644
--- a/core/src/fxcrt/fx_extension.cpp
+++ b/core/src/fxcrt/fx_extension.cpp
@@ -76,7 +76,7 @@ FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) {
FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr,
int32_t iLength,
int32_t* pUsedLen) {
- FXSYS_assert(pcsStr != NULL);
+ FXSYS_assert(pcsStr);
if (iLength < 0) {
iLength = (int32_t)FXSYS_strlen(pcsStr);
}
@@ -86,7 +86,7 @@ FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr,
FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr,
int32_t iLength,
int32_t* pUsedLen) {
- FXSYS_assert(pwsStr != NULL);
+ FXSYS_assert(pwsStr);
if (iLength < 0) {
iLength = (int32_t)FXSYS_wcslen(pwsStr);
}
@@ -132,7 +132,7 @@ FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr,
FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr,
const FX_WCHAR* srcStr,
size_t count) {
- FXSYS_assert(dstStr != NULL && srcStr != NULL && count > 0);
+ FXSYS_assert(dstStr && srcStr && count > 0);
for (size_t i = 0; i < count; ++i)
if ((dstStr[i] = srcStr[i]) == L'\0') {
break;
@@ -140,7 +140,7 @@ FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr,
return dstStr;
}
int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) {
- FXSYS_assert(s1 != NULL && s2 != NULL && count > 0);
+ FXSYS_assert(s1 && s2 && count > 0);
FX_WCHAR wch1 = 0, wch2 = 0;
while (count-- > 0) {
wch1 = (FX_WCHAR)FXSYS_tolower(*s1++);
@@ -152,7 +152,7 @@ int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) {
return wch1 - wch2;
}
int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count) {
- FXSYS_assert(s1 != NULL && s2 != NULL && count > 0);
+ FXSYS_assert(s1 && s2 && count > 0);
FX_CHAR ch1 = 0, ch2 = 0;
while (count-- > 0) {
ch1 = (FX_CHAR)FXSYS_tolower(*s1++);
@@ -166,7 +166,7 @@ int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count) {
FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr,
int32_t iLength,
FX_BOOL bIgnoreCase) {
- FXSYS_assert(pStr != NULL);
+ FXSYS_assert(pStr);
if (iLength < 0) {
iLength = (int32_t)FXSYS_strlen(pStr);
}
@@ -186,7 +186,7 @@ FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr,
FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr,
int32_t iLength,
FX_BOOL bIgnoreCase) {
- FXSYS_assert(pStr != NULL);
+ FXSYS_assert(pStr);
if (iLength < 0) {
iLength = (int32_t)FXSYS_wcslen(pStr);
}
@@ -216,7 +216,7 @@ void* FX_Random_MT_Start(FX_DWORD dwSeed) {
return pContext;
}
FX_DWORD FX_Random_MT_Generate(void* pContext) {
- FXSYS_assert(pContext != NULL);
+ FXSYS_assert(pContext);
FX_LPMTRANDOMCONTEXT pMTC = (FX_LPMTRANDOMCONTEXT)pContext;
FX_DWORD v;
static FX_DWORD mag[2] = {0, MT_Matrix_A};
@@ -247,7 +247,7 @@ FX_DWORD FX_Random_MT_Generate(void* pContext) {
return v;
}
void FX_Random_MT_Close(void* pContext) {
- FXSYS_assert(pContext != NULL);
+ FXSYS_assert(pContext);
FX_Free(pContext);
}
void FX_Random_GenerateMT(FX_DWORD* pBuffer, int32_t iCount) {
diff --git a/core/src/fxcrt/fx_xml_parser.cpp b/core/src/fxcrt/fx_xml_parser.cpp
index dcae0c58c0..56fbada3ad 100644
--- a/core/src/fxcrt/fx_xml_parser.cpp
+++ b/core/src/fxcrt/fx_xml_parser.cpp
@@ -819,7 +819,6 @@ int CXML_AttrMap::GetSize() const {
return m_pMap == NULL ? 0 : m_pMap->GetSize();
}
CXML_AttrItem& CXML_AttrMap::GetAt(int index) const {
- ASSERT(m_pMap != NULL);
return (*m_pMap)[index];
}
void CXML_AttrMap::RemoveAll() {
diff --git a/core/src/fxcrt/xml_int.h b/core/src/fxcrt/xml_int.h
index 39c288afa8..b11a64b505 100644
--- a/core/src/fxcrt/xml_int.h
+++ b/core/src/fxcrt/xml_int.h
@@ -48,7 +48,7 @@ class CXML_DataStmAcc : public IFX_BufferRead {
public:
CXML_DataStmAcc(IFX_FileRead* pFileRead)
: m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) {
- FXSYS_assert(m_pFileRead != NULL);
+ FXSYS_assert(m_pFileRead);
}
~CXML_DataStmAcc() override { FX_Free(m_pBuffer); }