summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2016-02-22 20:32:21 -0800
committerLei Zhang <thestig@chromium.org>2016-02-22 20:32:21 -0800
commit5eca305b1586b2107566a5c124baa5f2e00096c0 (patch)
treed2b6b17b62995b2249a28956a17ae87122f83124 /core/src
parentd2019df0a77c5d01a336f16be054d2f373e38c54 (diff)
downloadpdfium-5eca305b1586b2107566a5c124baa5f2e00096c0.tar.xz
Remove foo != NULL outside of xfa/
Most of these are from the XFA branch. R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1720043003 .
Diffstat (limited to 'core/src')
-rw-r--r--core/src/fpdfdoc/doc_form.cpp2
-rw-r--r--core/src/fpdfdoc/doc_tagged.cpp2
-rw-r--r--core/src/fxcodec/codec/fx_codec_bmp.cpp6
-rw-r--r--core/src/fxcodec/codec/fx_codec_gif.cpp6
-rw-r--r--core/src/fxcodec/codec/fx_codec_png.cpp10
-rw-r--r--core/src/fxcodec/codec/fx_codec_progress.cpp131
-rw-r--r--core/src/fxcodec/codec/fx_codec_progress.h18
-rw-r--r--core/src/fxcodec/lbmp/fx_bmp.cpp26
-rw-r--r--core/src/fxcodec/lbmp/fx_bmp.h5
-rw-r--r--core/src/fxcodec/lgif/fx_gif.cpp185
-rw-r--r--core/src/fxcodec/lgif/fx_gif.h5
-rw-r--r--core/src/fxcrt/fx_basic_maps.cpp4
12 files changed, 107 insertions, 293 deletions
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index 9252e073e0..f40f447a68 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -393,7 +393,7 @@ static FX_BOOL RetrieveStockFont(int iFontObject,
uint8_t charSet,
LOGFONTA& lf) {
HFONT hFont = (HFONT)::GetStockObject(iFontObject);
- if (hFont != NULL) {
+ if (hFont) {
memset(&lf, 0, sizeof(LOGFONTA));
int iRet = ::GetObject(hFont, sizeof(LOGFONTA), &lf);
if (iRet > 0 && (lf.lfCharSet == charSet || charSet == 255)) {
diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp
index e16d852ccb..a7eea11b02 100644
--- a/core/src/fpdfdoc/doc_tagged.cpp
+++ b/core/src/fpdfdoc/doc_tagged.cpp
@@ -13,7 +13,7 @@ const int nMaxRecursion = 32;
static FX_BOOL IsTagged(const CPDF_Document* pDoc) {
CPDF_Dictionary* pCatalog = pDoc->GetRoot();
CPDF_Dictionary* pMarkInfo = pCatalog->GetDictBy("MarkInfo");
- return pMarkInfo != NULL && pMarkInfo->GetIntegerBy("Marked");
+ return pMarkInfo && pMarkInfo->GetIntegerBy("Marked");
}
CPDF_StructTree* CPDF_StructTree::LoadPage(const CPDF_Document* pDoc,
const CPDF_Dictionary* pPageDict) {
diff --git a/core/src/fxcodec/codec/fx_codec_bmp.cpp b/core/src/fxcodec/codec/fx_codec_bmp.cpp
index 4e5fef0d1d..042392c0d1 100644
--- a/core/src/fxcodec/codec/fx_codec_bmp.cpp
+++ b/core/src/fxcodec/codec/fx_codec_bmp.cpp
@@ -21,9 +21,7 @@ static void* _bmp_alloc_func(unsigned int size) {
return FX_Alloc(char, size);
}
static void _bmp_free_func(void* p) {
- if (p != NULL) {
- FX_Free(p);
- }
+ FX_Free(p);
}
};
static void _bmp_error_data(bmp_decompress_struct_p bmp_ptr,
@@ -72,7 +70,7 @@ void* CCodec_BmpModule::Start(void* pModule) {
}
void CCodec_BmpModule::Finish(void* pContext) {
FXBMP_Context* p = (FXBMP_Context*)pContext;
- if (p != NULL) {
+ if (p) {
_bmp_destroy_decompress(&p->bmp_ptr);
p->m_FreeFunc(p);
}
diff --git a/core/src/fxcodec/codec/fx_codec_gif.cpp b/core/src/fxcodec/codec/fx_codec_gif.cpp
index 4c60a0392c..af0c32ea9d 100644
--- a/core/src/fxcodec/codec/fx_codec_gif.cpp
+++ b/core/src/fxcodec/codec/fx_codec_gif.cpp
@@ -21,9 +21,7 @@ static void* _gif_alloc_func(unsigned int size) {
return FX_Alloc(char, size);
}
static void _gif_free_func(void* p) {
- if (p != NULL) {
- FX_Free(p);
- }
+ FX_Free(p);
}
};
static void _gif_error_data(gif_decompress_struct_p gif_ptr,
@@ -98,7 +96,7 @@ void* CCodec_GifModule::Start(void* pModule) {
}
void CCodec_GifModule::Finish(void* pContext) {
FXGIF_Context* p = (FXGIF_Context*)pContext;
- if (p != NULL) {
+ if (p) {
_gif_destroy_decompress(&p->gif_ptr);
p->m_FreeFunc(p);
}
diff --git a/core/src/fxcodec/codec/fx_codec_png.cpp b/core/src/fxcodec/codec/fx_codec_png.cpp
index 0df3455522..c8cb1b8a6a 100644
--- a/core/src/fxcodec/codec/fx_codec_png.cpp
+++ b/core/src/fxcodec/codec/fx_codec_png.cpp
@@ -105,9 +105,7 @@ static void* _png_alloc_func(unsigned int size) {
return FX_Alloc(char, size);
}
static void _png_free_func(void* p) {
- if (p != NULL) {
- FX_Free(p);
- }
+ FX_Free(p);
}
};
static void _png_get_header_func(png_structp png_ptr, png_infop info_ptr) {
@@ -192,7 +190,7 @@ static void _png_get_row_func(png_structp png_ptr,
if (!pModule->AskScanlineBufCallback(p->child_ptr, row_num, src_buf)) {
png_error(png_ptr, "Ask Scanline buffer Callback Error");
}
- if (src_buf != NULL) {
+ if (src_buf) {
png_progressive_combine_row(png_ptr, src_buf, new_row);
}
pModule->FillScanlineBufCompletedCallback(p->child_ptr, pass, row_num);
@@ -220,7 +218,7 @@ void* CCodec_PngModule::Start(void* pModule) {
return NULL;
}
if (setjmp(png_jmpbuf(p->png_ptr))) {
- if (p != NULL) {
+ if (p) {
png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), (png_infopp)NULL);
FX_Free(p);
}
@@ -234,7 +232,7 @@ void* CCodec_PngModule::Start(void* pModule) {
}
void CCodec_PngModule::Finish(void* pContext) {
FXPNG_Context* p = (FXPNG_Context*)pContext;
- if (p != NULL) {
+ if (p) {
png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), (png_infopp)NULL);
p->m_FreeFunc(p);
}
diff --git a/core/src/fxcodec/codec/fx_codec_progress.cpp b/core/src/fxcodec/codec/fx_codec_progress.cpp
index 2edf750d7f..2e9b1dce3e 100644
--- a/core/src/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/src/fxcodec/codec/fx_codec_progress.cpp
@@ -272,30 +272,24 @@ CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder(
}
CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() {
m_pFile = NULL;
- if (m_pJpegContext != NULL) {
+ if (m_pJpegContext) {
m_pCodecMgr->GetJpegModule()->Finish(m_pJpegContext);
}
- if (m_pPngContext != NULL) {
+ if (m_pPngContext) {
m_pCodecMgr->GetPngModule()->Finish(m_pPngContext);
}
- if (m_pGifContext != NULL) {
+ if (m_pGifContext) {
m_pCodecMgr->GetGifModule()->Finish(m_pGifContext);
}
- if (m_pBmpContext != NULL) {
+ if (m_pBmpContext) {
m_pCodecMgr->GetBmpModule()->Finish(m_pBmpContext);
}
- if (m_pTiffContext != NULL) {
+ if (m_pTiffContext) {
m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext);
}
- if (m_pSrcBuf != NULL) {
- FX_Free(m_pSrcBuf);
- }
- if (m_pDecodeBuf != NULL) {
- FX_Free(m_pDecodeBuf);
- }
- if (m_pSrcPalette != NULL) {
- FX_Free(m_pSrcPalette);
- }
+ FX_Free(m_pSrcBuf);
+ FX_Free(m_pDecodeBuf);
+ FX_Free(m_pSrcPalette);
}
FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData(
ICodec_JpegModule* pJpegModule,
@@ -387,8 +381,8 @@ FX_BOOL CCodec_ProgressiveDecoder::PngAskScanlineBufFunc(void* pModule,
uint8_t*& src_buf) {
CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap;
- ASSERT(pDIBitmap != NULL);
- if (pDIBitmap == NULL) {
+ if (!pDIBitmap) {
+ ASSERT(false);
return FALSE;
}
if (line >= pCodec->m_clipBox.top && line < pCodec->m_clipBox.bottom) {
@@ -418,7 +412,7 @@ FX_BOOL CCodec_ProgressiveDecoder::PngAskScanlineBufFunc(void* pModule,
return FALSE;
case FXDIB_8bppMask:
case FXDIB_8bppRgb: {
- if (pDIBitmap->GetPalette() != NULL) {
+ if (pDIBitmap->GetPalette()) {
return FALSE;
}
FX_DWORD des_g = 0;
@@ -477,7 +471,7 @@ void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz(
return;
case FXDIB_8bppMask:
case FXDIB_8bppRgb: {
- if (pDeviceBitmap->GetPalette() != NULL) {
+ if (pDeviceBitmap->GetPalette()) {
return;
}
FX_DWORD des_g = 0;
@@ -532,7 +526,7 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc(void* pModule,
int line) {
CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap;
- ASSERT(pDIBitmap != NULL);
+ ASSERT(pDIBitmap);
int src_top = pCodec->m_clipBox.top;
int src_bottom = pCodec->m_clipBox.bottom;
int des_top = pCodec->m_startY;
@@ -700,7 +694,7 @@ void CCodec_ProgressiveDecoder::GifReadScanlineCallback(void* pModule,
uint8_t* row_buf) {
CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap;
- ASSERT(pDIBitmap != NULL);
+ ASSERT(pDIBitmap);
int32_t img_width = pCodec->m_GifFrameRect.Width();
if (!pDIBitmap->HasAlpha()) {
uint8_t* byte_ptr = row_buf;
@@ -788,7 +782,7 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert(
return;
case FXDIB_8bppMask:
case FXDIB_8bppRgb: {
- if (pDeviceBitmap->GetPalette() != NULL) {
+ if (pDeviceBitmap->GetPalette()) {
return;
}
int des_g = 0;
@@ -891,7 +885,7 @@ void CCodec_ProgressiveDecoder::BmpReadScanlineCallback(void* pModule,
uint8_t* row_buf) {
CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
CFX_DIBitmap* pDIBitmap = pCodec->m_pDeviceBitmap;
- ASSERT(pDIBitmap != NULL);
+ ASSERT(pDIBitmap);
FXSYS_memcpy(pCodec->m_pDecodeBuf, row_buf, pCodec->m_ScanlineSize);
int src_top = pCodec->m_clipBox.top;
int src_bottom = pCodec->m_clipBox.bottom;
@@ -953,7 +947,7 @@ void CCodec_ProgressiveDecoder::ResampleVertBT(CFX_DIBitmap* pDeviceBitmap,
return;
case FXDIB_8bppMask:
case FXDIB_8bppRgb: {
- if (pDeviceBitmap->GetPalette() != NULL) {
+ if (pDeviceBitmap->GetPalette()) {
return;
}
int des_g = 0;
@@ -1006,15 +1000,8 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
if (size > FXCODEC_BLOCK_SIZE) {
size = FXCODEC_BLOCK_SIZE;
}
- if (m_pSrcBuf != NULL) {
- FX_Free(m_pSrcBuf);
- m_pSrcBuf = NULL;
- }
+ FX_Free(m_pSrcBuf);
m_pSrcBuf = FX_Alloc(uint8_t, size);
- if (m_pSrcBuf == NULL) {
- m_status = FXCODEC_STATUS_ERR_MEMORY;
- return FALSE;
- }
FXSYS_memset(m_pSrcBuf, 0, size);
m_SrcSize = size;
switch (imageType) {
@@ -1056,22 +1043,17 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
if (readResult == 1) {
m_SrcBPC = 8;
m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
- if (m_pSrcPalette != NULL) {
- FX_Free(m_pSrcPalette);
- m_pSrcPalette = NULL;
- }
+ FX_Free(m_pSrcPalette);
if (m_SrcPaletteNumber) {
m_pSrcPalette = FX_Alloc(FX_ARGB, m_SrcPaletteNumber);
- if (m_pSrcPalette == NULL) {
- m_status = FXCODEC_STATUS_ERR_MEMORY;
- return FALSE;
- }
FXSYS_memcpy(m_pSrcPalette, pPalette,
m_SrcPaletteNumber * sizeof(FX_DWORD));
+ } else {
+ m_pSrcPalette = nullptr;
}
return TRUE;
}
- if (m_pBmpContext != NULL) {
+ if (m_pBmpContext) {
pBmpModule->Finish(m_pBmpContext);
m_pBmpContext = NULL;
}
@@ -1114,7 +1096,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
return TRUE;
}
- if (m_pJpegContext != NULL) {
+ if (m_pJpegContext) {
pJpegModule->Finish(m_pJpegContext);
m_pJpegContext = NULL;
}
@@ -1150,20 +1132,16 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
FX_DWORD input_size =
remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size;
if (input_size == 0) {
- if (m_pPngContext != NULL) {
+ if (m_pPngContext) {
pPngModule->Finish(m_pPngContext);
}
m_pPngContext = NULL;
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
}
- if (m_pSrcBuf != NULL && input_size > m_SrcSize) {
+ if (m_pSrcBuf && input_size > m_SrcSize) {
FX_Free(m_pSrcBuf);
m_pSrcBuf = FX_Alloc(uint8_t, input_size);
- if (m_pSrcBuf == NULL) {
- m_status = FXCODEC_STATUS_ERR_MEMORY;
- return FALSE;
- }
FXSYS_memset(m_pSrcBuf, 0, input_size);
m_SrcSize = input_size;
}
@@ -1177,7 +1155,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, pAttribute);
}
ASSERT(!bResult);
- if (m_pPngContext != NULL) {
+ if (m_pPngContext) {
pPngModule->Finish(m_pPngContext);
m_pPngContext = NULL;
}
@@ -1231,7 +1209,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
return TRUE;
}
- if (m_pGifContext != NULL) {
+ if (m_pGifContext) {
pGifModule->Finish(m_pGifContext);
m_pGifContext = NULL;
}
@@ -1711,7 +1689,7 @@ void CCodec_ProgressiveDecoder::ResampleVert(CFX_DIBitmap* pDeviceBitmap,
return;
case FXDIB_8bppMask:
case FXDIB_8bppRgb: {
- if (pDeviceBitmap->GetPalette() != NULL) {
+ if (pDeviceBitmap->GetPalette()) {
return;
}
int des_g = 0;
@@ -1836,7 +1814,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames,
frames = m_FrameNumber;
return m_status = FXCODEC_STATUS_DECODE_READY;
}
- if (m_pGifContext != NULL) {
+ if (m_pGifContext) {
pGifModule->Finish(m_pGifContext);
m_pGifContext = NULL;
}
@@ -1921,16 +1899,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
}
int scanline_size = (m_SrcWidth + down_scale - 1) / down_scale;
scanline_size = (scanline_size * m_SrcComponents + 3) / 4 * 4;
- if (m_pDecodeBuf != NULL) {
- FX_Free(m_pDecodeBuf);
- m_pDecodeBuf = NULL;
- }
+ FX_Free(m_pDecodeBuf);
m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size);
- if (m_pDecodeBuf == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
- return m_status = FXCODEC_STATUS_ERR_MEMORY;
- }
FXSYS_memset(m_pDecodeBuf, 0, scanline_size);
m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0,
m_clipBox.Width(), m_bInterpol);
@@ -1956,7 +1926,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
m_pFile = NULL;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
}
- if (m_pPngContext != NULL) {
+ if (m_pPngContext) {
pPngModule->Finish(m_pPngContext);
m_pPngContext = NULL;
}
@@ -1990,16 +1960,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
}
GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
int scanline_size = (m_SrcWidth * m_SrcComponents + 3) / 4 * 4;
- if (m_pDecodeBuf != NULL) {
- FX_Free(m_pDecodeBuf);
- m_pDecodeBuf = NULL;
- }
+ FX_Free(m_pDecodeBuf);
m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size);
- if (m_pDecodeBuf == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
- return m_status = FXCODEC_STATUS_ERR_MEMORY;
- }
FXSYS_memset(m_pDecodeBuf, 0, scanline_size);
m_WeightHorzOO.Calc(m_sizeX, m_clipBox.Width(), m_bInterpol);
m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
@@ -2015,16 +1977,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
m_SrcFormat = FXCodec_8bppRgb;
GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
int scanline_size = (m_SrcWidth + 3) / 4 * 4;
- if (m_pDecodeBuf != NULL) {
- FX_Free(m_pDecodeBuf);
- m_pDecodeBuf = NULL;
- }
+ FX_Free(m_pDecodeBuf);
m_pDecodeBuf = FX_Alloc(uint8_t, scanline_size);
- if (m_pDecodeBuf == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
- return m_status = FXCODEC_STATUS_ERR_MEMORY;
- }
FXSYS_memset(m_pDecodeBuf, 0, scanline_size);
m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0,
m_clipBox.Width(), m_bInterpol);
@@ -2052,16 +2006,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
}
GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
m_ScanlineSize = (m_SrcWidth * m_SrcComponents + 3) / 4 * 4;
- if (m_pDecodeBuf != NULL) {
- FX_Free(m_pDecodeBuf);
- m_pDecodeBuf = NULL;
- }
+ FX_Free(m_pDecodeBuf);
m_pDecodeBuf = FX_Alloc(uint8_t, m_ScanlineSize);
- if (m_pDecodeBuf == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
- return m_status = FXCODEC_STATUS_ERR_MEMORY;
- }
FXSYS_memset(m_pDecodeBuf, 0, m_ScanlineSize);
m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0,
m_clipBox.Width(), m_bInterpol);
@@ -2117,7 +2063,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
FX_DWORD input_size =
remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size;
if (input_size == 0) {
- if (m_pPngContext != NULL) {
+ if (m_pPngContext) {
pPngModule->Finish(m_pPngContext);
}
m_pPngContext = NULL;
@@ -2125,14 +2071,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
m_pFile = NULL;
return m_status = FXCODEC_STATUS_DECODE_FINISH;
}
- if (m_pSrcBuf != NULL && input_size > m_SrcSize) {
+ if (m_pSrcBuf && input_size > m_SrcSize) {
FX_Free(m_pSrcBuf);
m_pSrcBuf = FX_Alloc(uint8_t, input_size);
- if (m_pSrcBuf == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
- return m_status = FXCODEC_STATUS_ERR_MEMORY;
- }
FXSYS_memset(m_pSrcBuf, 0, input_size);
m_SrcSize = input_size;
}
diff --git a/core/src/fxcodec/codec/fx_codec_progress.h b/core/src/fxcodec/codec/fx_codec_progress.h
index 45fde21338..4fb13640ff 100644
--- a/core/src/fxcodec/codec/fx_codec_progress.h
+++ b/core/src/fxcodec/codec/fx_codec_progress.h
@@ -21,11 +21,7 @@ struct PixelWeight {
class CFXCODEC_WeightTable {
public:
CFXCODEC_WeightTable() { m_pWeightTables = NULL; }
- ~CFXCODEC_WeightTable() {
- if (m_pWeightTables != NULL) {
- FX_Free(m_pWeightTables);
- }
- }
+ ~CFXCODEC_WeightTable() { FX_Free(m_pWeightTables); }
void Calc(int dest_len,
int dest_min,
@@ -44,11 +40,7 @@ class CFXCODEC_WeightTable {
class CFXCODEC_HorzTable {
public:
CFXCODEC_HorzTable() { m_pWeightTables = NULL; }
- ~CFXCODEC_HorzTable() {
- if (m_pWeightTables != NULL) {
- FX_Free(m_pWeightTables);
- }
- }
+ ~CFXCODEC_HorzTable() { FX_Free(m_pWeightTables); }
void Calc(int dest_len, int src_len, FX_BOOL bInterpol);
PixelWeight* GetPixelWeight(int pixel) {
@@ -61,11 +53,7 @@ class CFXCODEC_HorzTable {
class CFXCODEC_VertTable {
public:
CFXCODEC_VertTable() { m_pWeightTables = NULL; }
- ~CFXCODEC_VertTable() {
- if (m_pWeightTables != NULL) {
- FX_Free(m_pWeightTables);
- }
- }
+ ~CFXCODEC_VertTable() { FX_Free(m_pWeightTables); }
void Calc(int dest_len, int src_len);
PixelWeight* GetPixelWeight(int pixel) {
return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize);
diff --git a/core/src/fxcodec/lbmp/fx_bmp.cpp b/core/src/fxcodec/lbmp/fx_bmp.cpp
index bfcf2f4722..ec7490fdd1 100644
--- a/core/src/fxcodec/lbmp/fx_bmp.cpp
+++ b/core/src/fxcodec/lbmp/fx_bmp.cpp
@@ -32,7 +32,7 @@ void _SetWord_LSBFirst(uint8_t* p, FX_WORD v) {
p[1] = (uint8_t)(v >> 8);
}
void _bmp_error(bmp_decompress_struct_p bmp_ptr, const FX_CHAR* err_msg) {
- if (bmp_ptr != NULL && bmp_ptr->_bmp_error_fn != NULL) {
+ if (bmp_ptr && bmp_ptr->_bmp_error_fn) {
bmp_ptr->_bmp_error_fn(bmp_ptr, err_msg);
}
}
@@ -52,15 +52,11 @@ void _bmp_destroy_decompress(bmp_decompress_struct_pp bmp_ptr_ptr) {
}
bmp_decompress_struct_p bmp_ptr = *bmp_ptr_ptr;
*bmp_ptr_ptr = NULL;
- if (bmp_ptr->out_row_buffer != NULL) {
+ if (bmp_ptr->out_row_buffer) {
FX_Free(bmp_ptr->out_row_buffer);
}
- if (bmp_ptr->pal_ptr != NULL) {
- FX_Free(bmp_ptr->pal_ptr);
- }
- if (bmp_ptr->bmp_header_ptr != NULL) {
- FX_Free(bmp_ptr->bmp_header_ptr);
- }
+ FX_Free(bmp_ptr->pal_ptr);
+ FX_Free(bmp_ptr->bmp_header_ptr);
FX_Free(bmp_ptr);
}
int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
@@ -218,12 +214,8 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
bmp_ptr->components = 4;
break;
}
- if (bmp_ptr->out_row_buffer != NULL) {
- FX_Free(bmp_ptr->out_row_buffer);
- bmp_ptr->out_row_buffer = NULL;
- }
+ FX_Free(bmp_ptr->out_row_buffer);
bmp_ptr->out_row_buffer = FX_Alloc(uint8_t, bmp_ptr->out_row_bytes);
- BMP_PTR_NOT_NULL(bmp_ptr->out_row_buffer, bmp_ptr);
FXSYS_memset(bmp_ptr->out_row_buffer, 0, bmp_ptr->out_row_bytes);
_bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_PAL);
}
@@ -279,12 +271,8 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
- if (bmp_ptr->pal_ptr != NULL) {
- FX_Free(bmp_ptr->pal_ptr);
- bmp_ptr->pal_ptr = NULL;
- }
+ FX_Free(bmp_ptr->pal_ptr);
bmp_ptr->pal_ptr = FX_Alloc(FX_DWORD, bmp_ptr->pal_num);
- BMP_PTR_NOT_NULL(bmp_ptr->pal_ptr, bmp_ptr);
int32_t src_pal_index = 0;
if (bmp_ptr->pal_type == BMP_PAL_OLD) {
while (src_pal_index < bmp_ptr->pal_num) {
@@ -652,7 +640,7 @@ void _bmp_input_buffer(bmp_decompress_struct_p bmp_ptr,
}
FX_DWORD _bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr,
uint8_t** avial_buf_ptr) {
- if (avial_buf_ptr != NULL) {
+ if (avial_buf_ptr) {
*avial_buf_ptr = NULL;
if (bmp_ptr->avail_in > 0) {
*avial_buf_ptr = bmp_ptr->next_in;
diff --git a/core/src/fxcodec/lbmp/fx_bmp.h b/core/src/fxcodec/lbmp/fx_bmp.h
index 610cffc0df..dc90f5f740 100644
--- a/core/src/fxcodec/lbmp/fx_bmp.h
+++ b/core/src/fxcodec/lbmp/fx_bmp.h
@@ -129,11 +129,6 @@ void _bmp_input_buffer(bmp_decompress_struct_p bmp_ptr,
FX_DWORD src_size);
FX_DWORD _bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr,
uint8_t** avial_buf_ptr);
-#define BMP_PTR_NOT_NULL(ptr, bmp_ptr) \
- if (ptr == NULL) { \
- _bmp_error(bmp_ptr, "Out Of Memory"); \
- return 0; \
- }
typedef struct tag_bmp_compress_struct bmp_compress_struct;
typedef bmp_compress_struct* bmp_compress_struct_p;
typedef bmp_compress_struct_p* bmp_compress_struct_pp;
diff --git a/core/src/fxcodec/lgif/fx_gif.cpp b/core/src/fxcodec/lgif/fx_gif.cpp
index 0be7caad12..ffac891032 100644
--- a/core/src/fxcodec/lgif/fx_gif.cpp
+++ b/core/src/fxcodec/lgif/fx_gif.cpp
@@ -376,27 +376,16 @@ void _gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
}
gif_decompress_struct_p gif_ptr = *gif_ptr_ptr;
*gif_ptr_ptr = NULL;
- if (gif_ptr->global_pal_ptr != NULL) {
- FX_Free(gif_ptr->global_pal_ptr);
- }
- if (gif_ptr->img_decoder_ptr != NULL) {
- delete gif_ptr->img_decoder_ptr;
- }
- if (gif_ptr->img_ptr_arr_ptr != NULL) {
+ FX_Free(gif_ptr->global_pal_ptr);
+ delete gif_ptr->img_decoder_ptr;
+ if (gif_ptr->img_ptr_arr_ptr) {
int32_t size_img_arr = gif_ptr->img_ptr_arr_ptr->GetSize();
for (int32_t i = 0; i < size_img_arr; i++) {
GifImage* p = gif_ptr->img_ptr_arr_ptr->GetAt(i);
- if (p->image_info_ptr != NULL) {
- FX_Free(p->image_info_ptr);
- }
- if (p->image_gce_ptr != NULL) {
- FX_Free(p->image_gce_ptr);
- }
- if (p->image_row_buf != NULL) {
- FX_Free(p->image_row_buf);
- }
- if (p->local_pal_ptr != NULL &&
- p->local_pal_ptr != gif_ptr->global_pal_ptr) {
+ FX_Free(p->image_info_ptr);
+ FX_Free(p->image_gce_ptr);
+ FX_Free(p->image_row_buf);
+ if (p->local_pal_ptr && p->local_pal_ptr != gif_ptr->global_pal_ptr) {
FX_Free(p->local_pal_ptr);
}
FX_Free(p);
@@ -405,34 +394,22 @@ void _gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
delete gif_ptr->img_ptr_arr_ptr;
}
#ifdef GIF_SUPPORT_APPLICATION_EXTENSION
- if (gif_ptr->app_data != NULL) {
- FX_Free(gif_ptr->app_data);
- }
+ FX_Free(gif_ptr->app_data);
#endif
#ifdef GIF_SUPPORT_COMMENT_EXTENSION
- if (gif_ptr->cmt_data_ptr != NULL) {
- delete gif_ptr->cmt_data_ptr;
- }
+ delete gif_ptr->cmt_data_ptr;
#endif
#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
- if (gif_ptr->gce_ptr != NULL) {
- FX_Free(gif_ptr->gce_ptr);
- }
+ FX_Free(gif_ptr->gce_ptr);
#endif
#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
- if (gif_ptr->pt_ptr_arr_ptr != NULL) {
+ if (gif_ptr->pt_ptr_arr_ptr) {
int32_t size_pt_arr = gif_ptr->pt_ptr_arr_ptr->GetSize();
for (int32_t i = 0; i < size_pt_arr; i++) {
GifPlainText* p = gif_ptr->pt_ptr_arr_ptr->GetAt(i);
- if (p->gce_ptr != NULL) {
- FX_Free(p->gce_ptr);
- }
- if (p->pte_ptr != NULL) {
- FX_Free(p->pte_ptr);
- }
- if (p->string_ptr != NULL) {
- delete p->string_ptr;
- }
+ FX_Free(p->gce_ptr);
+ FX_Free(p->pte_ptr);
+ delete p->string_ptr;
}
gif_ptr->pt_ptr_arr_ptr->RemoveAll();
delete gif_ptr->pt_ptr_arr_ptr;
@@ -511,48 +488,28 @@ void _gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr) {
}
gif_compress_struct_p gif_ptr = *gif_ptr_ptr;
*gif_ptr_ptr = NULL;
- if (gif_ptr->header_ptr != NULL) {
- FX_Free(gif_ptr->header_ptr);
- }
- if (gif_ptr->lsd_ptr != NULL) {
- FX_Free(gif_ptr->lsd_ptr);
- }
- if (gif_ptr->global_pal != NULL) {
- FX_Free(gif_ptr->global_pal);
- }
- if (gif_ptr->image_info_ptr != NULL) {
- FX_Free(gif_ptr->image_info_ptr);
- }
- if (gif_ptr->local_pal != NULL) {
- FX_Free(gif_ptr->local_pal);
- }
- if (gif_ptr->img_encoder_ptr != NULL) {
- delete gif_ptr->img_encoder_ptr;
- }
+ FX_Free(gif_ptr->header_ptr);
+ FX_Free(gif_ptr->lsd_ptr);
+ FX_Free(gif_ptr->global_pal);
+ FX_Free(gif_ptr->image_info_ptr);
+ FX_Free(gif_ptr->local_pal);
+ delete gif_ptr->img_encoder_ptr;
#ifdef GIF_SUPPORT_APPLICATION_EXTENSION
- if (gif_ptr->app_data != NULL) {
- FX_Free(gif_ptr->app_data);
- }
+ FX_Free(gif_ptr->app_data);
#endif
#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
- if (gif_ptr->gce_ptr != NULL) {
- FX_Free(gif_ptr->gce_ptr);
- }
+ FX_Free(gif_ptr->gce_ptr);
#endif
#ifdef GIF_SUPPORT_COMMENT_EXTENSION
- if (gif_ptr->cmt_data_ptr != NULL) {
- FX_Free(gif_ptr->cmt_data_ptr);
- }
+ FX_Free(gif_ptr->cmt_data_ptr);
#endif
#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
- if (gif_ptr->pte_ptr != NULL) {
- FX_Free(gif_ptr->pte_ptr);
- }
+ FX_Free(gif_ptr->pte_ptr);
#endif
FX_Free(gif_ptr);
}
void _gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) {
- if (gif_ptr != NULL && gif_ptr->_gif_error_fn != NULL) {
+ if (gif_ptr && gif_ptr->_gif_error_fn) {
gif_ptr->_gif_error_fn(gif_ptr, err_msg);
}
}
@@ -591,12 +548,8 @@ int32_t _gif_read_header(gif_decompress_struct_p gif_ptr) {
gif_ptr->global_sort_flag = ((GifGF*)&gif_lsd_ptr->global_flag)->sort_flag;
gif_ptr->global_color_resolution =
((GifGF*)&gif_lsd_ptr->global_flag)->color_resolution;
- if (gif_ptr->global_pal_ptr != NULL) {
- FX_Free(gif_ptr->global_pal_ptr);
- }
- gif_ptr->global_pal_ptr = NULL;
+ FX_Free(gif_ptr->global_pal_ptr);
gif_ptr->global_pal_ptr = (GifPalette*)FX_Alloc(uint8_t, global_pal_size);
- GIF_PTR_NOT_NULL(gif_ptr->global_pal_ptr, gif_ptr);
FXSYS_memcpy(gif_ptr->global_pal_ptr, global_pal_ptr, global_pal_size);
}
gif_ptr->width = (int)_GetWord_LSBFirst((uint8_t*)&gif_lsd_ptr->width);
@@ -720,7 +673,7 @@ void _gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr,
GifGCE** gce_ptr_ptr) {
*gce_ptr_ptr = NULL;
#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
- if (gif_ptr->gce_ptr != NULL && gce_ptr_ptr != NULL) {
+ if (gif_ptr->gce_ptr && gce_ptr_ptr) {
*gce_ptr_ptr = gif_ptr->gce_ptr;
gif_ptr->gce_ptr = NULL;
}
@@ -756,12 +709,8 @@ int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
FXSYS_memcpy(gif_ptr->app_authentication, gif_ae_ptr->app_authentication,
3);
gif_ptr->app_data_size = gif_ae_data_str.GetLength();
- if (gif_ptr->app_data != NULL) {
- FX_Free(gif_ptr->app_data);
- gif_ptr->app_data = NULL;
- }
+ FX_Free(gif_ptr->app_data);
gif_ptr->app_data = FX_Alloc(uint8_t, gif_ptr->app_data_size);
- GIF_PTR_NOT_NULL(gif_ptr->app_data, gif_ptr);
FXSYS_memcpy(gif_ptr->app_data, const uint8_t*(gif_ae_data_str),
gif_ptr->app_data_size);
} break;
@@ -793,13 +742,10 @@ int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
return 2;
}
GifPlainText* gif_pt_ptr = FX_Alloc(GifPlainText, 1);
- GIF_PTR_NOT_NULL(gif_pt_ptr, gif_ptr);
FXSYS_memset(gif_pt_ptr, 0, sizeof(GifPlainText));
_gif_takeover_gce_ptr(gif_ptr, &gif_pt_ptr->gce_ptr);
gif_pt_ptr->pte_ptr = (GifPTE*)FX_Alloc(uint8_t, sizeof(GifPTE));
- GIF_PTR_NOT_NULL(gif_pt_ptr->pte_ptr, gif_ptr);
gif_pt_ptr->string_ptr = new CFX_ByteString;
- GIF_PTR_NOT_NULL(gif_pt_ptr->string_ptr, gif_ptr);
gif_pt_ptr->pte_ptr->block_size = gif_pte_ptr->block_size;
gif_pt_ptr->pte_ptr->grid_left =
_GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_left);
@@ -815,16 +761,10 @@ int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
gif_pt_ptr->pte_ptr->bc_index = gif_pte_ptr->bc_index;
if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
gif_ptr->skip_size = skip_size_org;
- if (gif_pt_ptr != NULL) {
- if (gif_pt_ptr->gce_ptr != NULL) {
- FX_Free(gif_pt_ptr->gce_ptr);
- }
- if (gif_pt_ptr->pte_ptr != NULL) {
- FX_Free(gif_pt_ptr->pte_ptr);
- }
- if (gif_pt_ptr->string_ptr != NULL) {
- delete gif_pt_ptr->string_ptr;
- }
+ if (gif_pt_ptr) {
+ FX_Free(gif_pt_ptr->gce_ptr);
+ FX_Free(gif_pt_ptr->pte_ptr);
+ delete gif_pt_ptr->string_ptr;
FX_Free(gif_pt_ptr);
}
return 2;
@@ -834,16 +774,10 @@ int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
gif_ptr->skip_size = skip_size_org;
- if (gif_pt_ptr != NULL) {
- if (gif_pt_ptr->gce_ptr != NULL) {
- FX_Free(gif_pt_ptr->gce_ptr);
- }
- if (gif_pt_ptr->pte_ptr != NULL) {
- FX_Free(gif_pt_ptr->pte_ptr);
- }
- if (gif_pt_ptr->string_ptr != NULL) {
- delete gif_pt_ptr->string_ptr;
- }
+ if (gif_pt_ptr) {
+ FX_Free(gif_pt_ptr->gce_ptr);
+ FX_Free(gif_pt_ptr->pte_ptr);
+ delete gif_pt_ptr->string_ptr;
FX_Free(gif_pt_ptr);
}
return 2;
@@ -863,7 +797,6 @@ int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
}
if (gif_ptr->gce_ptr == NULL) {
gif_ptr->gce_ptr = (GifGCE*)FX_Alloc(uint8_t, sizeof(GifGCE));
- GIF_PTR_NOT_NULL(gif_ptr->gce_ptr, gif_ptr);
}
gif_ptr->gce_ptr->block_size = gif_gce_ptr->block_size;
gif_ptr->gce_ptr->gce_flag = gif_gce_ptr->gce_flag;
@@ -874,15 +807,13 @@ int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
#endif
default: {
#ifndef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
- if (gif_ptr->decode_status == GIF_D_STATUS_EXT_PTE) {
#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
- if (gif_ptr->gce_ptr != NULL) {
- FX_Free(gif_ptr->gce_ptr);
- gif_ptr->gce_ptr = NULL;
- }
-#endif
+ if (gif_ptr->decode_status == GIF_D_STATUS_EXT_PTE) {
+ FX_Free(gif_ptr->gce_ptr);
+ gif_ptr->gce_ptr = NULL;
}
#endif
+#endif
if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
return 2;
}
@@ -910,11 +841,9 @@ int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
return 2;
}
GifImage* gif_image_ptr = (GifImage*)FX_Alloc(uint8_t, sizeof(GifImage));
- GIF_PTR_NOT_NULL(gif_image_ptr, gif_ptr);
FXSYS_memset(gif_image_ptr, 0, sizeof(GifImage));
gif_image_ptr->image_info_ptr =
(GifImageInfo*)FX_Alloc(uint8_t, sizeof(GifImageInfo));
- GIF_PTR_NOT_NULL(gif_image_ptr->image_info_ptr, gif_ptr);
gif_image_ptr->image_info_ptr->left =
_GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->left);
gif_image_ptr->image_info_ptr->top =
@@ -930,12 +859,8 @@ int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
gif_image_ptr->image_info_ptr->top +
gif_image_ptr->image_info_ptr->height >
gif_ptr->height) {
- if (gif_image_ptr->image_info_ptr != NULL) {
- FX_Free(gif_image_ptr->image_info_ptr);
- }
- if (gif_image_ptr->image_row_buf != NULL) {
- FX_Free(gif_image_ptr->image_row_buf);
- }
+ FX_Free(gif_image_ptr->image_info_ptr);
+ FX_Free(gif_image_ptr->image_row_buf);
FX_Free(gif_image_ptr);
_gif_error(gif_ptr, "Image Data Out Of LSD, The File May Be Corrupt");
return 0;
@@ -947,18 +872,14 @@ int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
uint8_t* loc_pal_ptr = NULL;
if (_gif_read_data(gif_ptr, &loc_pal_ptr, loc_pal_size) == NULL) {
gif_ptr->skip_size = skip_size_org;
- if (gif_image_ptr->image_info_ptr != NULL) {
- FX_Free(gif_image_ptr->image_info_ptr);
- }
- if (gif_image_ptr->image_row_buf != NULL) {
- FX_Free(gif_image_ptr->image_row_buf);
- }
+ FX_Free(gif_image_ptr->image_info_ptr);
+ FX_Free(gif_image_ptr->image_row_buf);
FX_Free(gif_image_ptr);
return 2;
}
gif_image_ptr->local_pal_ptr =
(GifPalette*)gif_ptr->_gif_ask_buf_for_pal_fn(gif_ptr, loc_pal_size);
- if (gif_image_ptr->local_pal_ptr != NULL) {
+ if (gif_image_ptr->local_pal_ptr) {
FXSYS_memcpy((uint8_t*)gif_image_ptr->local_pal_ptr, loc_pal_ptr,
loc_pal_size);
}
@@ -966,15 +887,9 @@ int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
uint8_t* code_size_ptr = NULL;
if (_gif_read_data(gif_ptr, &code_size_ptr, 1) == NULL) {
gif_ptr->skip_size = skip_size_org;
- if (gif_image_ptr->image_info_ptr != NULL) {
- FX_Free(gif_image_ptr->image_info_ptr);
- }
- if (gif_image_ptr->local_pal_ptr != NULL) {
- FX_Free(gif_image_ptr->local_pal_ptr);
- }
- if (gif_image_ptr->image_row_buf != NULL) {
- FX_Free(gif_image_ptr->image_row_buf);
- }
+ FX_Free(gif_image_ptr->image_info_ptr);
+ FX_Free(gif_image_ptr->local_pal_ptr);
+ FX_Free(gif_image_ptr->image_row_buf);
FX_Free(gif_image_ptr);
return 2;
}
@@ -1003,7 +918,6 @@ int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
gif_image_ptr->image_row_buf = NULL;
}
gif_image_ptr->image_row_buf = FX_Alloc(uint8_t, gif_img_row_bytes);
- GIF_PTR_NOT_NULL(gif_image_ptr->image_row_buf, gif_ptr);
GifGCE* gif_img_gce_ptr = gif_image_ptr->image_gce_ptr;
int32_t loc_pal_num =
((GifLF*)&gif_image_ptr->image_info_ptr->local_flag)->local_pal
@@ -1054,7 +968,6 @@ int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
}
if (gif_ptr->img_decoder_ptr == NULL) {
gif_ptr->img_decoder_ptr = new CGifLZWDecoder(gif_ptr->err_ptr);
- GIF_PTR_NOT_NULL(gif_ptr->img_decoder_ptr, gif_ptr);
}
gif_ptr->img_decoder_ptr->InitTable(gif_image_ptr->image_code_size);
gif_ptr->img_row_offset = 0;
@@ -1179,7 +1092,7 @@ void _gif_input_buffer(gif_decompress_struct_p gif_ptr,
}
FX_DWORD _gif_get_avail_input(gif_decompress_struct_p gif_ptr,
uint8_t** avial_buf_ptr) {
- if (avial_buf_ptr != NULL) {
+ if (avial_buf_ptr) {
*avial_buf_ptr = NULL;
if (gif_ptr->avail_in > 0) {
*avial_buf_ptr = gif_ptr->next_in;
diff --git a/core/src/fxcodec/lgif/fx_gif.h b/core/src/fxcodec/lgif/fx_gif.h
index 2c755d6cde..2b14115ede 100644
--- a/core/src/fxcodec/lgif/fx_gif.h
+++ b/core/src/fxcodec/lgif/fx_gif.h
@@ -329,10 +329,5 @@ void interlace_buf(const uint8_t* buf, FX_DWORD width, FX_DWORD height);
FX_BOOL _gif_encode(gif_compress_struct_p gif_ptr,
uint8_t*& dst_buf,
FX_DWORD& dst_len);
-#define GIF_PTR_NOT_NULL(ptr, gif_ptr) \
- if (ptr == NULL) { \
- _gif_error(gif_ptr, "Out Of Memory"); \
- return 0; \
- }
#endif // CORE_SRC_FXCODEC_LGIF_FX_GIF_H_
diff --git a/core/src/fxcrt/fx_basic_maps.cpp b/core/src/fxcrt/fx_basic_maps.cpp
index 2aa63fb088..60d75b610c 100644
--- a/core/src/fxcrt/fx_basic_maps.cpp
+++ b/core/src/fxcrt/fx_basic_maps.cpp
@@ -39,7 +39,7 @@ void CFX_MapPtrToPtr::GetNextAssoc(FX_POSITION& rNextPosition,
ASSERT(pAssocRet);
if (pAssocRet == (CAssoc*)-1) {
for (FX_DWORD nBucket = 0; nBucket < m_nHashTableSize; nBucket++) {
- if ((pAssocRet = m_pHashTable[nBucket]) != NULL)
+ if ((pAssocRet = m_pHashTable[nBucket]))
break;
}
ASSERT(pAssocRet);
@@ -48,7 +48,7 @@ void CFX_MapPtrToPtr::GetNextAssoc(FX_POSITION& rNextPosition,
if ((pAssocNext = pAssocRet->pNext) == NULL) {
for (FX_DWORD nBucket = (HashKey(pAssocRet->key) % m_nHashTableSize) + 1;
nBucket < m_nHashTableSize; nBucket++) {
- if ((pAssocNext = m_pHashTable[nBucket]) != NULL) {
+ if ((pAssocNext = m_pHashTable[nBucket])) {
break;
}
}