diff options
author | Lei Zhang <thestig@chromium.org> | 2016-02-24 15:26:50 -0800 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2016-02-24 15:26:50 -0800 |
commit | 38eaaf36b09b816b963015e33dc4eb02580e0462 (patch) | |
tree | 9a2721eb404a2de4ddce91b50cac25b2cac0edb1 /xfa/src/fxbarcode/oned | |
parent | e1fb98394a6885cf03bdc6391e5a3878aad5b375 (diff) | |
download | pdfium-38eaaf36b09b816b963015e33dc4eb02580e0462.tar.xz |
Remove foo != NULL checks in xfa/src/fxbarcode.
R=dsinclair@chromium.org
Review URL: https://codereview.chromium.org/1726373002 .
Diffstat (limited to 'xfa/src/fxbarcode/oned')
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OneDReader.cpp | 19 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OneDimReader.cpp | 5 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp | 9 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp | 4 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp | 5 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp | 5 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.cpp | 14 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.cpp | 5 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.cpp | 8 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OnedUPCAReader.cpp | 5 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.cpp | 23 |
11 files changed, 35 insertions, 67 deletions
diff --git a/xfa/src/fxbarcode/oned/BC_OneDReader.cpp b/xfa/src/fxbarcode/oned/BC_OneDReader.cpp index 0b699c9624..7cb8ba51fa 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDReader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OneDReader.cpp @@ -21,6 +21,7 @@ */ #include <algorithm> +#include <memory> #include "xfa/src/fxbarcode/BC_BinaryBitmap.h" #include "xfa/src/fxbarcode/BC_Reader.h" @@ -49,7 +50,6 @@ CFX_ByteString CBC_OneDReader::DeDecode(CBC_BinaryBitmap* image, int32_t hints, int32_t& e) { int32_t height = image->GetHeight(); - CBC_CommonBitArray* row = NULL; int32_t middle = height >> 1; FX_BOOL tryHarder = FALSE; int32_t rowStep = std::max(1, height >> (tryHarder ? 8 : 5)); @@ -68,34 +68,23 @@ CFX_ByteString CBC_OneDReader::DeDecode(CBC_BinaryBitmap* image, if (rowNumber < 0 || rowNumber >= height) { break; } - row = image->GetBlackRow(rowNumber, NULL, e); + std::unique_ptr<CBC_CommonBitArray> row( + image->GetBlackRow(rowNumber, nullptr, e)); if (e != BCExceptionNO) { e = BCExceptionNO; - if (row != NULL) { - delete row; - row = NULL; - } continue; } for (int32_t attempt = 0; attempt < 2; attempt++) { if (attempt == 1) { row->Reverse(); } - CFX_ByteString result = DecodeRow(rowNumber, row, hints, e); + CFX_ByteString result = DecodeRow(rowNumber, row.get(), hints, e); if (e != BCExceptionNO) { e = BCExceptionNO; continue; } - if (row != NULL) { - delete row; - row = NULL; - } return result; } - if (row != NULL) { - delete row; - row = NULL; - } } e = BCExceptionNotFound; return ""; diff --git a/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp b/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp index 075e69f219..74f0db4068 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp @@ -52,10 +52,7 @@ CFX_Int32Array* CBC_OneDimReader::FindStartGuardPattern(CBC_CommonBitArray* row, startEndPattern[2] = START_END_PATTERN[2]; int32_t nextStart = 0; while (!foundStart) { - if (startRange != NULL) { - delete startRange; - startRange = NULL; - } + delete startRange; startRange = FindGuardPattern(row, nextStart, FALSE, &startEndPattern, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); int32_t start = (*startRange)[0]; diff --git a/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp index ed93e9852b..121b72cb05 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp @@ -43,10 +43,7 @@ CBC_OneDimWriter::CBC_OneDimWriter() { m_output = NULL; } CBC_OneDimWriter::~CBC_OneDimWriter() { - if (m_output != NULL) { - delete m_output; - m_output = NULL; - } + delete m_output; } void CBC_OneDimWriter::SetPrintChecksum(FX_BOOL checksum) { m_bPrintChecksum = checksum; @@ -196,7 +193,7 @@ void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, device->FillRect(&re, m_backgroundColor); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, (FX_FLOAT)locX, (FX_FLOAT)(locY + iFontSize)); - if (matrix != NULL) { + if (matrix) { affine_matrix.Concat(*matrix); } device->DrawNormalText(str.GetLength(), pCharPos, m_pFont, @@ -284,7 +281,7 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, geWidth = (FX_FLOAT)barWidth; break; } - if (device != NULL) { + if (device) { ShowDeviceChars(device, matrix, str, geWidth, pCharPos, (FX_FLOAT)locX, (FX_FLOAT)locY, barWidth); } else { diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp index 8d9671089b..582f93bc15 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp @@ -190,7 +190,7 @@ CFX_ByteString CBC_OnedCode128Reader::DecodeRow(int32_t rowNumber, codeSet = CODE_CODE_C; break; default: - if (startPatternInfo != NULL) { + if (startPatternInfo) { startPatternInfo->RemoveAll(); delete startPatternInfo; startPatternInfo = NULL; @@ -203,7 +203,7 @@ CFX_ByteString CBC_OnedCode128Reader::DecodeRow(int32_t rowNumber, CFX_ByteString result; int32_t lastStart = (*startPatternInfo)[0]; int32_t nextStart = (*startPatternInfo)[1]; - if (startPatternInfo != NULL) { + if (startPatternInfo) { startPatternInfo->RemoveAll(); delete startPatternInfo; startPatternInfo = NULL; diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp index 73999a4818..5f0ad98d65 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp @@ -58,10 +58,7 @@ CFX_ByteString CBC_OnedCode39Reader::DecodeRow(int32_t rowNumber, CFX_Int32Array* start = FindAsteriskPattern(row, e); BC_EXCEPTION_CHECK_ReturnValue(e, ""); int32_t nextStart = (*start)[1]; - if (start != NULL) { - delete start; - start = NULL; - } + delete start; int32_t end = row->GetSize(); while (nextStart < end && !row->Get(nextStart)) { nextStart++; diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp index fe05069d4f..1cb08cd9b8 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp @@ -81,10 +81,7 @@ int32_t CBC_OnedEAN13Reader::DecodeMiddle(CBC_CommonBitArray* row, FindGuardPattern(row, rowOffset, TRUE, &result, e); BC_EXCEPTION_CHECK_ReturnValue(e, 0); rowOffset = (*middleRange)[1]; - if (middleRange != NULL) { - delete middleRange; - middleRange = NULL; - } + delete middleRange; for (int32_t Y = 0; Y < 6 && rowOffset < end; Y++) { int32_t bestMatch = DecodeDigit(row, &counters, rowOffset, diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.cpp index 9b8456d6ed..de71b2074a 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -171,7 +171,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); CFX_FxgeDevice geBitmap; - if (pOutBitmap != NULL) { + if (pOutBitmap) { geBitmap.Attach(pOutBitmap); } int32_t iFontSize = (int32_t)fabs(m_fFontSize); @@ -216,7 +216,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, blank); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; - if (pOutBitmap != NULL) { + if (pOutBitmap) { ge.Create(strWidth, iTextHeight, FXDIB_Argb); FX_RECT rect(0, 0, strWidth, iTextHeight); ge.FillRect(&rect, m_backgroundColor); @@ -229,7 +229,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, (FX_FLOAT)leftPosition * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight) + iFontSize); - if (matrix != NULL) { + if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText(iLen, pCharPos + 1, m_pFont, @@ -242,7 +242,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, charsWidth = 0.0f; CalcTextInfo(tempStr, pCharPos + 7, m_pFont, (FX_FLOAT)strWidth, iFontSize, blank); - if (pOutBitmap != NULL) { + if (pOutBitmap) { FX_RECT rect1(0, 0, strWidth, iTextHeight); ge.FillRect(&rect1, m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 7, m_pFont, @@ -256,7 +256,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, 1.0, 0.0, 0.0, -1.0, (FX_FLOAT)(leftPosition + 47 * multiple) * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix != NULL) { + if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText(iLen, pCharPos + 7, m_pFont, @@ -272,7 +272,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, } CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, blank); - if (pOutBitmap != NULL) { + if (pOutBitmap) { delete ge.GetBitmap(); ge.Create(strWidth, iTextHeight, FXDIB_Argb); ge.GetBitmap()->Clear(m_backgroundColor); @@ -284,7 +284,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, } else { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix != NULL) { + if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText(iLen, pCharPos, m_pFont, diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.cpp index 503454f71f..8d13d26347 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.cpp @@ -67,10 +67,7 @@ int32_t CBC_OnedEAN8Reader::DecodeMiddle(CBC_CommonBitArray* row, e = BCExceptionNotFound; BC_EXCEPTION_CHECK_ReturnValue(e, 0); } - if (middleRange != NULL) { - delete middleRange; - middleRange = NULL; - } + delete middleRange; for (int32_t y = 0; y < 4 && rowOffset < end; y++) { int32_t bestMatch = DecodeDigit(row, &counters, rowOffset, diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.cpp index f552531e63..61fe75aae3 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -179,7 +179,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, int32_t strWidth = 7 * multiple * 4; FX_FLOAT blank = 0.0; CFX_FxgeDevice geBitmap; - if (pOutBitmap != NULL) { + if (pOutBitmap) { geBitmap.Attach(pOutBitmap); } FX_FLOAT charsWidth = 0; @@ -212,7 +212,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, blank); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; - if (pOutBitmap != NULL) { + if (pOutBitmap) { delete ge.GetBitmap(); ge.Create(strWidth, iTextHeight, FXDIB_Argb); ge.GetBitmap()->Clear(m_backgroundColor); @@ -236,7 +236,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, charsWidth = 0.0f; CalcTextInfo(tempStr, pCharPos + 4, m_pFont, (FX_FLOAT)strWidth, iFontSize, blank); - if (pOutBitmap != NULL) { + if (pOutBitmap) { delete ge.GetBitmap(); ge.Create(strWidth, iTextHeight, FXDIB_Argb); ge.GetBitmap()->Clear(m_backgroundColor); @@ -251,7 +251,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, 1.0, 0.0, 0.0, -1.0, (FX_FLOAT)(leftPosition + 33 * multiple) * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix != NULL) { + if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText(iLen, pCharPos + 4, m_pFont, diff --git a/xfa/src/fxbarcode/oned/BC_OnedUPCAReader.cpp b/xfa/src/fxbarcode/oned/BC_OnedUPCAReader.cpp index 14040632a7..416b08ae9a 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedUPCAReader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedUPCAReader.cpp @@ -35,10 +35,7 @@ void CBC_OnedUPCAReader::Init() { m_ean13Reader = new CBC_OnedEAN13Reader; } CBC_OnedUPCAReader::~CBC_OnedUPCAReader() { - if (m_ean13Reader != NULL) { - delete m_ean13Reader; - } - m_ean13Reader = NULL; + delete m_ean13Reader; } CFX_ByteString CBC_OnedUPCAReader::DecodeRow(int32_t rowNumber, CBC_CommonBitArray* row, diff --git a/xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.cpp index 08a849f362..55c50318a5 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -34,10 +34,7 @@ void CBC_OnedUPCAWriter::Init() { m_subWriter = new CBC_OnedEAN13Writer; } CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() { - if (m_subWriter != NULL) { - delete m_subWriter; - } - m_subWriter = NULL; + delete m_subWriter; } FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity( const CFX_WideStringC& contents) { @@ -130,7 +127,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; FX_FLOAT blank = 0.0; CFX_FxgeDevice geBitmap; - if (pOutBitmap != NULL) { + if (pOutBitmap) { geBitmap.Attach(pOutBitmap); } FX_FLOAT charsWidth = 0; @@ -181,7 +178,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; - if (pOutBitmap != NULL) { + if (pOutBitmap) { ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, @@ -193,7 +190,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, (FX_FLOAT)leftPosition * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix != NULL) { + if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText(iLen, pCharPos + 1, m_pFont, @@ -205,7 +202,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, iLen = tempStr.GetLength(); charsWidth = 0.0f; CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); - if (pOutBitmap != NULL) { + if (pOutBitmap) { FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); ge.FillRect(&rect2, m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, @@ -219,7 +216,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, 1.0, 0.0, 0.0, -1.0, (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix != NULL) { + if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText(iLen, pCharPos + 6, m_pFont, @@ -234,7 +231,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, strWidth = strWidth * m_outputHScale; } CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); - if (pOutBitmap != NULL) { + if (pOutBitmap) { delete ge.GetBitmap(); ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); ge.GetBitmap()->Clear(m_backgroundColor); @@ -246,7 +243,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, } else { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix != NULL) { + if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText(iLen, pCharPos, m_pFont, @@ -257,7 +254,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, tempStr = str.Mid(11, 1); iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); - if (pOutBitmap != NULL) { + if (pOutBitmap) { delete ge.GetBitmap(); ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); ge.GetBitmap()->Clear(m_backgroundColor); @@ -272,7 +269,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, 1.0, 0.0, 0.0, -1.0, (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix != NULL) { + if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText(iLen, pCharPos + 11, m_pFont, |