summaryrefslogtreecommitdiff
path: root/core/src/fxcrt
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-08-14 15:45:39 -0700
committerLei Zhang <thestig@chromium.org>2015-08-14 15:45:39 -0700
commitcb62e7657b3a9a04142028a4e6614029a08e894b (patch)
treee7fa5f4c7d7f12bff9315475a89872fb044c36b1 /core/src/fxcrt
parent0f6b51c0fdd14f5762bf3c7412ac59c825443cc3 (diff)
downloadpdfium-cb62e7657b3a9a04142028a4e6614029a08e894b.tar.xz
Don't bother checking pointers before delete[] and FX_Free().
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1297713003 .
Diffstat (limited to 'core/src/fxcrt')
-rw-r--r--core/src/fxcrt/fx_basic_buffer.cpp14
-rw-r--r--core/src/fxcrt/fx_basic_maps.cpp18
-rw-r--r--core/src/fxcrt/xml_int.h6
3 files changed, 11 insertions, 27 deletions
diff --git a/core/src/fxcrt/fx_basic_buffer.cpp b/core/src/fxcrt/fx_basic_buffer.cpp
index deb8133489..d993e5e567 100644
--- a/core/src/fxcrt/fx_basic_buffer.cpp
+++ b/core/src/fxcrt/fx_basic_buffer.cpp
@@ -13,9 +13,7 @@ CFX_BinaryBuf::CFX_BinaryBuf(FX_STRSIZE size)
m_pBuffer = FX_Alloc(uint8_t, size);
}
CFX_BinaryBuf::~CFX_BinaryBuf() {
- if (m_pBuffer) {
- FX_Free(m_pBuffer);
- }
+ FX_Free(m_pBuffer);
}
void CFX_BinaryBuf::Delete(int start_index, int count) {
if (!m_pBuffer || start_index < 0 || start_index + count > m_DataSize) {
@@ -34,9 +32,7 @@ void CFX_BinaryBuf::DetachBuffer() {
m_AllocSize = 0;
}
void CFX_BinaryBuf::AttachData(void* buffer, FX_STRSIZE size) {
- if (m_pBuffer) {
- FX_Free(m_pBuffer);
- }
+ FX_Free(m_pBuffer);
m_DataSize = size;
m_pBuffer = (uint8_t*)buffer;
m_AllocSize = size;
@@ -258,10 +254,8 @@ IFX_BufferArchive::IFX_BufferArchive(FX_STRSIZE size)
: m_BufSize(size), m_pBuffer(NULL), m_Length(0) {}
void IFX_BufferArchive::Clear() {
m_Length = 0;
- if (m_pBuffer) {
- FX_Free(m_pBuffer);
- m_pBuffer = NULL;
- }
+ FX_Free(m_pBuffer);
+ m_pBuffer = NULL;
}
FX_BOOL IFX_BufferArchive::Flush() {
FX_BOOL bRet = DoWork(m_pBuffer, m_Length);
diff --git a/core/src/fxcrt/fx_basic_maps.cpp b/core/src/fxcrt/fx_basic_maps.cpp
index 14a681b832..1558ae6f75 100644
--- a/core/src/fxcrt/fx_basic_maps.cpp
+++ b/core/src/fxcrt/fx_basic_maps.cpp
@@ -23,10 +23,8 @@ CFX_MapPtrToPtr::CFX_MapPtrToPtr(int nBlockSize)
ASSERT(m_nBlockSize > 0);
}
void CFX_MapPtrToPtr::RemoveAll() {
- if (m_pHashTable) {
- FX_Free(m_pHashTable);
- m_pHashTable = NULL;
- }
+ FX_Free(m_pHashTable);
+ m_pHashTable = NULL;
m_nCount = 0;
m_pFreeList = NULL;
m_pBlocks->FreeDataChain();
@@ -134,10 +132,8 @@ CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::NewAssoc() {
void CFX_MapPtrToPtr::InitHashTable(FX_DWORD nHashSize, FX_BOOL bAllocNow) {
ASSERT(m_nCount == 0);
ASSERT(nHashSize > 0);
- if (m_pHashTable != NULL) {
- FX_Free(m_pHashTable);
- m_pHashTable = NULL;
- }
+ FX_Free(m_pHashTable);
+ m_pHashTable = NULL;
if (bAllocNow) {
m_pHashTable = FX_Alloc(CAssoc*, nHashSize);
}
@@ -321,10 +317,8 @@ void CFX_MapByteStringToPtr::InitHashTable(FX_DWORD nHashSize,
FX_BOOL bAllocNow) {
ASSERT(m_nCount == 0);
ASSERT(nHashSize > 0);
- if (m_pHashTable != NULL) {
- FX_Free(m_pHashTable);
- m_pHashTable = NULL;
- }
+ FX_Free(m_pHashTable);
+ m_pHashTable = NULL;
if (bAllocNow) {
m_pHashTable = FX_Alloc(CAssoc*, nHashSize);
}
diff --git a/core/src/fxcrt/xml_int.h b/core/src/fxcrt/xml_int.h
index 6020f45819..ccd5bfdb7d 100644
--- a/core/src/fxcrt/xml_int.h
+++ b/core/src/fxcrt/xml_int.h
@@ -47,11 +47,7 @@ class CXML_DataStmAcc : public IFX_BufferRead {
: m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) {
FXSYS_assert(m_pFileRead != NULL);
}
- ~CXML_DataStmAcc() override {
- if (m_pBuffer) {
- FX_Free(m_pBuffer);
- }
- }
+ ~CXML_DataStmAcc() override { FX_Free(m_pBuffer); }
void Release() override { delete this; }
FX_BOOL IsEOF() override {