summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-06-07 10:46:22 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-07 10:46:23 -0700
commit4997b22f84307521a62838f874928bf56cd3423c (patch)
treead11d99ac0a491ee222e9d0a42ec3b6ad3354e2a /core/fxcodec/jbig2
parent0687e76dc259c678b3f29a6608331f07ffd8f1e2 (diff)
downloadpdfium-4997b22f84307521a62838f874928bf56cd3423c.tar.xz
Get rid of NULLs in core/
Review-Url: https://codereview.chromium.org/2032613003
Diffstat (limited to 'core/fxcodec/jbig2')
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.cpp20
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.h2
-rw-r--r--core/fxcodec/jbig2/JBig2_Image.cpp33
-rw-r--r--core/fxcodec/jbig2/JBig2_PatternDict.cpp2
-rw-r--r--core/fxcodec/jbig2/JBig2_Segment.cpp4
5 files changed, 31 insertions, 30 deletions
diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
index 25c9ff7649..8dde290be6 100644
--- a/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -69,7 +69,7 @@ CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream,
m_PauseStep(10),
m_pPause(pPause),
m_ProcessingStatus(FXCODEC_STATUS_FRAME_READY),
- m_gbContext(NULL),
+ m_gbContext(nullptr),
m_dwOffset(0),
m_pSymbolDictCache(pSymbolDictCache),
m_bIsGlobal(bIsGlobal) {
@@ -85,9 +85,9 @@ CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream,
CJBig2_Context::~CJBig2_Context() {
FX_Free(m_gbContext);
- m_gbContext = NULL;
+ m_gbContext = nullptr;
delete m_pGlobalContext;
- m_pGlobalContext = NULL;
+ m_pGlobalContext = nullptr;
}
int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) {
@@ -259,7 +259,7 @@ CJBig2_Segment* CJBig2_Context::findReferredSegmentByTypeAndIndex(
++count;
}
}
- return NULL;
+ return nullptr;
}
int32_t CJBig2_Context::parseSegmentHeader(CJBig2_Segment* pSegment) {
if (m_pStream->readInteger(&pSegment->m_dwNumber) != 0 ||
@@ -737,7 +737,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
pTRD->SBSYMS = SBSYMS.get();
} else {
- pTRD->SBSYMS = NULL;
+ pTRD->SBSYMS = nullptr;
}
std::unique_ptr<JBig2HuffmanCode, FxFreeDeleter> SBSYMCODES;
@@ -946,7 +946,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im,
(JBig2ComposeOp)(ri.flags & 0x03));
delete pSegment->m_Result.im;
- pSegment->m_Result.im = NULL;
+ pSegment->m_Result.im = nullptr;
}
return JBIG2_SUCCESS;
}
@@ -1064,7 +1064,7 @@ int32_t CJBig2_Context::parseHalftoneRegion(CJBig2_Segment* pSegment,
m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im,
(JBig2ComposeOp)(ri.flags & 0x03));
delete pSegment->m_Result.im;
- pSegment->m_Result.im = NULL;
+ pSegment->m_Result.im = nullptr;
}
return JBIG2_SUCCESS;
}
@@ -1137,7 +1137,7 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
} else {
m_pArithDecoder.reset();
FX_Free(m_gbContext);
- m_gbContext = NULL;
+ m_gbContext = nullptr;
if (!pSegment->m_Result.im) {
m_ProcessingStatus = FXCODEC_STATUS_ERROR;
m_pGRD.reset();
@@ -1168,7 +1168,7 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
pSegment->m_Result.im,
(JBig2ComposeOp)(m_ri.flags & 0x03), &Rect);
delete pSegment->m_Result.im;
- pSegment->m_Result.im = NULL;
+ pSegment->m_Result.im = nullptr;
}
m_pGRD.reset();
return JBIG2_SUCCESS;
@@ -1238,7 +1238,7 @@ int32_t CJBig2_Context::parseGenericRefinementRegion(CJBig2_Segment* pSegment) {
m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im,
(JBig2ComposeOp)(ri.flags & 0x03));
delete pSegment->m_Result.im;
- pSegment->m_Result.im = NULL;
+ pSegment->m_Result.im = nullptr;
}
return JBIG2_SUCCESS;
}
diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h
index fa68588a4a..950ad130d7 100644
--- a/core/fxcodec/jbig2/JBig2_Context.h
+++ b/core/fxcodec/jbig2/JBig2_Context.h
@@ -44,7 +44,7 @@ class CJBig2_Context {
CPDF_StreamAcc* pGlobalStream,
CPDF_StreamAcc* pSrcStream,
std::list<CJBig2_CachePair>* pSymbolDictCache,
- IFX_Pause* pPause = NULL);
+ IFX_Pause* pPause = nullptr);
static void DestroyContext(CJBig2_Context* pContext);
diff --git a/core/fxcodec/jbig2/JBig2_Image.cpp b/core/fxcodec/jbig2/JBig2_Image.cpp
index 6a1c060b75..cf0ee3bbbc 100644
--- a/core/fxcodec/jbig2/JBig2_Image.cpp
+++ b/core/fxcodec/jbig2/JBig2_Image.cpp
@@ -14,7 +14,7 @@ CJBig2_Image::CJBig2_Image(int32_t w, int32_t h) {
m_nWidth = w;
m_nHeight = h;
if (m_nWidth <= 0 || m_nHeight <= 0 || m_nWidth > INT_MAX - 31) {
- m_pData = NULL;
+ m_pData = nullptr;
m_bNeedFree = FALSE;
return;
}
@@ -22,7 +22,7 @@ CJBig2_Image::CJBig2_Image(int32_t w, int32_t h) {
if (m_nStride * m_nHeight > 0 && 104857600 / (int)m_nStride > m_nHeight) {
m_pData = FX_Alloc2D(uint8_t, m_nStride, m_nHeight);
} else {
- m_pData = NULL;
+ m_pData = nullptr;
}
m_bNeedFree = TRUE;
}
@@ -44,7 +44,7 @@ CJBig2_Image::CJBig2_Image(const CJBig2_Image& im) {
m_pData = FX_Alloc2D(uint8_t, m_nStride, m_nHeight);
JBIG2_memcpy(m_pData, im.m_pData, m_nStride * m_nHeight);
} else {
- m_pData = NULL;
+ m_pData = nullptr;
}
m_bNeedFree = TRUE;
}
@@ -120,12 +120,12 @@ FX_BOOL CJBig2_Image::composeTo(CJBig2_Image* pDst,
int32_t y,
JBig2ComposeOp op,
const FX_RECT* pSrcRect) {
- if (!m_pData) {
+ if (!m_pData)
return FALSE;
- }
- if (NULL == pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight)) {
+
+ if (!pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight))
return composeTo_opt2(pDst, x, y, op);
- }
+
return composeTo_opt2(pDst, x, y, op, pSrcRect);
}
@@ -159,7 +159,7 @@ CJBig2_Image* CJBig2_Image::subImage(int32_t x,
uint32_t wTmp;
uint8_t *pSrc, *pSrcEnd, *pDst, *pDstEnd;
if (w == 0 || h == 0) {
- return NULL;
+ return nullptr;
}
CJBig2_Image* pImage = new CJBig2_Image(w, h);
if (!m_pData) {
@@ -243,14 +243,12 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst,
uint32_t s1 = 0, d1 = 0, d2 = 0, shift = 0, shift1 = 0, shift2 = 0, tmp = 0,
tmp1 = 0, tmp2 = 0, maskL = 0, maskR = 0, maskM = 0;
- uint8_t *lineSrc = NULL, *lineDst = NULL, *sp = NULL, *dp = NULL;
-
- if (!m_pData) {
+ if (!m_pData)
return FALSE;
- }
- if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) {
+
+ if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576)
return FALSE;
- }
+
if (y < 0) {
ys0 = -y;
}
@@ -286,9 +284,9 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst,
maskL = 0xffffffff >> d1;
maskR = 0xffffffff << ((32 - (xd1 & 31)) % 32);
maskM = maskL & maskR;
- lineSrc = m_pData + ys0 * m_nStride + ((xs0 >> 5) << 2);
+ uint8_t* lineSrc = m_pData + ys0 * m_nStride + ((xs0 >> 5) << 2);
lineLeft = m_nStride - ((xs0 >> 5) << 2);
- lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2);
+ uint8_t* lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2);
if ((xd0 & ~31) == ((xd1 - 1) & ~31)) {
if ((xs0 & ~31) == ((xs1 - 1) & ~31)) {
if (s1 > d1) {
@@ -383,6 +381,9 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst,
}
}
} else {
+ uint8_t* sp = nullptr;
+ uint8_t* dp = nullptr;
+
if (s1 > d1) {
shift1 = s1 - d1;
shift2 = 32 - shift1;
diff --git a/core/fxcodec/jbig2/JBig2_PatternDict.cpp b/core/fxcodec/jbig2/JBig2_PatternDict.cpp
index e74d83647c..9598dc4bae 100644
--- a/core/fxcodec/jbig2/JBig2_PatternDict.cpp
+++ b/core/fxcodec/jbig2/JBig2_PatternDict.cpp
@@ -10,7 +10,7 @@
CJBig2_PatternDict::CJBig2_PatternDict() {
NUMPATS = 0;
- HDPATS = NULL;
+ HDPATS = nullptr;
}
CJBig2_PatternDict::~CJBig2_PatternDict() {
diff --git a/core/fxcodec/jbig2/JBig2_Segment.cpp b/core/fxcodec/jbig2/JBig2_Segment.cpp
index 64df0db5f7..0f53abcee3 100644
--- a/core/fxcodec/jbig2/JBig2_Segment.cpp
+++ b/core/fxcodec/jbig2/JBig2_Segment.cpp
@@ -12,7 +12,7 @@ CJBig2_Segment::CJBig2_Segment() {
m_dwNumber = 0;
m_cFlags.c = 0;
m_nReferred_to_segment_count = 0;
- m_pReferred_to_segment_numbers = NULL;
+ m_pReferred_to_segment_numbers = nullptr;
m_dwPage_association = 0;
m_dwData_length = 0;
m_dwHeader_Length = 0;
@@ -20,7 +20,7 @@ CJBig2_Segment::CJBig2_Segment() {
m_dwDataOffset = 0;
m_State = JBIG2_SEGMENT_HEADER_UNPARSED;
m_nResultType = JBIG2_VOID_POINTER;
- m_Result.vd = NULL;
+ m_Result.vd = nullptr;
}
CJBig2_Segment::~CJBig2_Segment() {
FX_Free(m_pReferred_to_segment_numbers);