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

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

Issue 1297713003: Don't bother checking pointers before delete[] and FX_Free(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years, 4 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 | « core/src/fxcodec/codec/fx_codec_jpeg.cpp ('k') | core/src/fxcrt/fx_basic_maps.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_buffer.cpp
diff --git a/core/src/fxcrt/fx_basic_buffer.cpp b/core/src/fxcrt/fx_basic_buffer.cpp
index deb8133489b74624f4b340eddcc415157e312126..d993e5e56737b005c6af76a7a877442b269a7713 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);
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_jpeg.cpp ('k') | core/src/fxcrt/fx_basic_maps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698