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

Unified Diff: core/fxcodec/codec/fx_codec_progress.cpp

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Git rid of comparisons against NULL Created 4 years, 7 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
Index: core/fxcodec/codec/fx_codec_progress.cpp
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index 95a90b3e6898a50e9ed761c7ced7a1e35aa4db00..ec890f0febdc7188c7922cc27aab8bba8a2673df 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -39,9 +39,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len,
sizeof(int) * (FXSYS_ceil(FXSYS_fabs((FX_FLOAT)scale)) + 1));
m_DestMin = dest_min;
m_pWeightTables = FX_Alloc(uint8_t, (dest_max - dest_min) * m_ItemSize + 4);
- if (m_pWeightTables == NULL) {
- return;
- }
if (FXSYS_fabs((FX_FLOAT)scale) < 1.0f) {
for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel++) {
PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel);
@@ -131,9 +128,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len,
m_ItemSize = sizeof(int) * 4;
int size = dest_len * m_ItemSize + 4;
m_pWeightTables = FX_Alloc(uint8_t, size);
- if (m_pWeightTables == NULL) {
- return;
- }
FXSYS_memset(m_pWeightTables, 0, size);
if (scale > 1) {
int pre_des_col = 0;
@@ -192,9 +186,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
m_ItemSize = sizeof(int) * 4;
int size = dest_len * m_ItemSize + 4;
m_pWeightTables = FX_Alloc(uint8_t, size);
- if (m_pWeightTables == NULL) {
- return;
- }
FXSYS_memset(m_pWeightTables, 0, size);
if (scale > 1) {
double step = 0.0;
@@ -349,7 +340,7 @@ FX_BOOL CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule,
int* color_type,
double* gamma) {
CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
- if (pCodec->m_pDeviceBitmap == NULL) {
+ if (!pCodec->m_pDeviceBitmap) {
pCodec->m_SrcWidth = width;
pCodec->m_SrcHeight = height;
pCodec->m_SrcBPC = bpc;
@@ -638,14 +629,14 @@ FX_BOOL CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback(
pal_num = pCodec->m_GifPltNumber;
pPalette = pCodec->m_pGifPalette;
}
- if (pCodec->m_pSrcPalette == NULL) {
+ if (!pCodec->m_pSrcPalette) {
pCodec->m_pSrcPalette = FX_Alloc(FX_ARGB, pal_num);
} else if (pal_num > pCodec->m_SrcPaletteNumber) {
pCodec->m_pSrcPalette = FX_Realloc(FX_ARGB, pCodec->m_pSrcPalette, pal_num);
}
- if (pCodec->m_pSrcPalette == NULL) {
+ if (!pCodec->m_pSrcPalette)
return FALSE;
- }
+
pCodec->m_SrcPaletteNumber = pal_num;
for (int i = 0; i < pal_num; i++) {
uint32_t j = i * 3;
@@ -1020,7 +1011,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
switch (imageType) {
case FXCODEC_IMAGE_BMP: {
CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
- if (pBmpModule == NULL) {
+ if (!pBmpModule) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1028,7 +1019,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
BmpInputImagePositionBufCallback;
pBmpModule->ReadScanlineCallback = BmpReadScanlineCallback;
m_pBmpContext = pBmpModule->Start((void*)this);
- if (m_pBmpContext == NULL) {
+ if (!m_pBmpContext) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1075,12 +1066,12 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
} break;
case FXCODEC_IMAGE_JPG: {
CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
- if (pJpegModule == NULL) {
+ if (!pJpegModule) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
m_pJpegContext = pJpegModule->Start();
- if (m_pJpegContext == NULL) {
+ if (!m_pJpegContext) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1118,7 +1109,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
} break;
case FXCODEC_IMAGE_PNG: {
CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
- if (pPngModule == NULL) {
+ if (!pPngModule) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1129,7 +1120,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
pPngModule->FillScanlineBufCompletedCallback =
CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc;
m_pPngContext = pPngModule->Start((void*)this);
- if (m_pPngContext == NULL) {
+ if (!m_pPngContext) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1179,7 +1170,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
} break;
case FXCODEC_IMAGE_GIF: {
CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
- if (pGifModule == NULL) {
+ if (!pGifModule) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1192,7 +1183,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
pGifModule->ReadScanlineCallback =
CCodec_ProgressiveDecoder::GifReadScanlineCallback;
m_pGifContext = pGifModule->Start((void*)this);
- if (m_pGifContext == NULL) {
+ if (!m_pGifContext) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1231,12 +1222,12 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
} break;
case FXCODEC_IMAGE_TIF: {
CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
- if (pTiffModule == NULL) {
+ if (!pTiffModule) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
}
m_pTiffContext = pTiffModule->CreateDecoder(m_pFile);
- if (m_pTiffContext == NULL) {
+ if (!m_pTiffContext) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
}
@@ -1274,7 +1265,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo(
default:
break;
}
- if (pFile == NULL) {
+ if (!pFile) {
m_status = FXCODEC_STATUS_ERR_PARAMS;
m_pFile = NULL;
return m_status;
@@ -1847,10 +1838,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
int size_y,
int32_t frames,
FX_BOOL bInterpol) {
- if (m_status != FXCODEC_STATUS_DECODE_READY) {
+ if (m_status != FXCODEC_STATUS_DECODE_READY)
return FXCODEC_STATUS_ERROR;
- }
- if (pDIBitmap == NULL || pDIBitmap->GetBPP() < 8 || frames < 0 ||
+
+ if (!pDIBitmap || pDIBitmap->GetBPP() < 8 || frames < 0 ||
frames >= m_FrameNumber) {
return FXCODEC_STATUS_ERR_PARAMS;
}
@@ -1936,7 +1927,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
} break;
case FXCODEC_IMAGE_PNG: {
CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
- if (pPngModule == NULL) {
+ if (!pPngModule) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
@@ -1946,7 +1937,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
m_pPngContext = NULL;
}
m_pPngContext = pPngModule->Start((void*)this);
- if (m_pPngContext == NULL) {
+ if (!m_pPngContext) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
@@ -1984,7 +1975,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
} break;
case FXCODEC_IMAGE_GIF: {
CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
- if (pGifModule == NULL) {
+ if (!pGifModule) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
@@ -2003,7 +1994,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
} break;
case FXCODEC_IMAGE_BMP: {
CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
- if (pBmpModule == NULL) {
+ if (!pBmpModule) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
@@ -2183,7 +2174,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
} else {
CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap;
pDIBitmap->Create(m_SrcWidth, m_SrcHeight, FXDIB_Argb);
- if (pDIBitmap->GetBuffer() == NULL) {
+ if (!pDIBitmap->GetBuffer()) {
delete pDIBitmap;
m_pDeviceBitmap = NULL;
m_pFile = NULL;
@@ -2204,7 +2195,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
if (pDIBitmap != pClipBitmap) {
delete pDIBitmap;
}
- if (pClipBitmap == NULL) {
+ if (!pClipBitmap) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
@@ -2279,7 +2270,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
if (pClipBitmap != pFormatBitmap) {
delete pClipBitmap;
}
- if (pFormatBitmap == NULL) {
+ if (!pFormatBitmap) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
@@ -2288,7 +2279,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
m_sizeX, m_sizeY, m_bInterpol ? FXDIB_INTERPOL : FXDIB_DOWNSAMPLE);
delete pFormatBitmap;
pFormatBitmap = NULL;
- if (pStrechBitmap == NULL) {
+ if (!pStrechBitmap) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
return m_status = FXCODEC_STATUS_ERR_MEMORY;

Powered by Google App Engine
This is Rietveld 408576698