summaryrefslogtreecommitdiff
path: root/core/src/fxcrt
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-08-14 22:22:13 -0700
committerLei Zhang <thestig@chromium.org>2015-08-14 22:22:13 -0700
commitda180e9fdd4385df024cc18046f62ca47bc74d74 (patch)
tree931e0e64ac2cbc82e3718e43418ee6bd676da4a5 /core/src/fxcrt
parent2b1a2d528469cda4e9f3e36d3c7a649e0d476480 (diff)
downloadpdfium-da180e9fdd4385df024cc18046f62ca47bc74d74.tar.xz
Merge to XFA: Don't bother checking pointers before delete[] and FX_Free().
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1297713003 . (cherry picked from commit cb62e7657b3a9a04142028a4e6614029a08e894b) Review URL: https://codereview.chromium.org/1287053005 .
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 40269e00c0..19ebfdff42 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;
@@ -381,10 +377,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 {