summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-14 05:57:10 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-14 05:57:10 -0800
commita9caab94c1f16929e5acf2676117224617d80f53 (patch)
treed71ff9a82fae6e6080deb76375f43056127b3ee2 /core
parent992ecf7c189e5cabf43e5ad862511cf63d030966 (diff)
downloadpdfium-a9caab94c1f16929e5acf2676117224617d80f53.tar.xz
Avoid the ptr.reset(new XXX()) anti-pattern
Be suspicious of |new|. This removes some of the easy cases. Review-Url: https://codereview.chromium.org/2571913002
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/cpdf_modulemgr.cpp3
-rw-r--r--core/fpdfapi/edit/fpdf_edit_create.cpp5
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.cpp5
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp12
-rw-r--r--core/fpdfapi/font/fpdf_font.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_contentparser.cpp15
-rw-r--r--core/fpdfapi/page/cpdf_form.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_page.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_tilingpattern.cpp3
-rw-r--r--core/fpdfapi/page/fpdf_page_func.cpp11
-rw-r--r--core/fpdfapi/parser/cpdf_document_unittest.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp5
-rw-r--r--core/fpdfapi/parser/cpdf_stream.cpp3
-rw-r--r--core/fpdfapi/render/cpdf_devicebuffer.cpp3
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp5
-rw-r--r--core/fpdfapi/render/cpdf_progressiverenderer.cpp3
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp9
-rw-r--r--core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp3
-rw-r--r--core/fpdfapi/render/fpdf_render_loadimage.cpp11
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp3
-rw-r--r--core/fpdfdoc/cpvt_sectioninfo.cpp6
-rw-r--r--core/fpdfdoc/cpvt_wordinfo.cpp3
-rw-r--r--core/fxcodec/codec/fx_codec_jbig.cpp7
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.cpp109
-rw-r--r--core/fxcodec/jbig2/JBig2_HtrdProc.cpp3
-rw-r--r--core/fxcodec/jbig2/JBig2_SddProc.cpp9
-rw-r--r--core/fxcodec/jbig2/JBig2_TrdProc.cpp21
27 files changed, 148 insertions, 120 deletions
diff --git a/core/fpdfapi/cpdf_modulemgr.cpp b/core/fpdfapi/cpdf_modulemgr.cpp
index 8ae8464ef5..ac28b36663 100644
--- a/core/fpdfapi/cpdf_modulemgr.cpp
+++ b/core/fpdfapi/cpdf_modulemgr.cpp
@@ -8,6 +8,7 @@
#include "core/fpdfapi/page/cpdf_pagemodule.h"
#include "core/fxcodec/fx_codec.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -33,7 +34,7 @@ CPDF_ModuleMgr::CPDF_ModuleMgr() : m_pCodecModule(nullptr) {}
CPDF_ModuleMgr::~CPDF_ModuleMgr() {}
void CPDF_ModuleMgr::InitPageModule() {
- m_pPageModule.reset(new CPDF_PageModule);
+ m_pPageModule = pdfium::MakeUnique<CPDF_PageModule>();
}
CCodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() {
diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp
index 62314f43f5..7b38883ef8 100644
--- a/core/fpdfapi/edit/fpdf_edit_create.cpp
+++ b/core/fpdfapi/edit/fpdf_edit_create.cpp
@@ -25,6 +25,7 @@
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/fx_ext.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024)
@@ -1446,7 +1447,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) {
CPDF_Dictionary* pDict = m_pDocument->GetRoot();
m_pMetadata = pDict ? pDict->GetDirectObjectFor("Metadata") : nullptr;
if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) {
- m_pXRefStream.reset(new CPDF_XRefStream);
+ m_pXRefStream = pdfium::MakeUnique<CPDF_XRefStream>();
m_pXRefStream->Start();
if ((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser) {
FX_FILESIZE prev = m_pParser->GetLastXRefOffset();
@@ -1929,7 +1930,7 @@ void CPDF_Creator::InitID(bool bDefault) {
CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : nullptr;
bool bNewId = !m_pIDArray;
if (bNewId) {
- m_pIDArray.reset(new CPDF_Array);
+ m_pIDArray = pdfium::MakeUnique<CPDF_Array>();
CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr;
if (pID1) {
m_pIDArray->Add(pID1->Clone());
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 0217391c12..91df025e0f 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -19,6 +19,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "third_party/base/numerics/safe_math.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -398,7 +399,7 @@ bool CPDF_CIDFont::Load() {
CPDF_Object* pmap = pCIDFontDict->GetDirectObjectFor("CIDToGIDMap");
if (pmap) {
if (CPDF_Stream* pStream = pmap->AsStream()) {
- m_pStreamAcc.reset(new CPDF_StreamAcc);
+ m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pStreamAcc->LoadAllData(pStream, false);
} else if (pmap->GetString() == "Identity") {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
@@ -581,7 +582,7 @@ int CPDF_CIDFont::GetGlyphIndex(uint32_t unicode, bool* pVertGlyph) {
if (error || !m_Font.GetSubData())
return index;
- m_pTTGSUBTable.reset(new CFX_CTTGSUBTable);
+ m_pTTGSUBTable = pdfium::MakeUnique<CFX_CTTGSUBTable>();
m_pTTGSUBTable->LoadGSUBTable((FT_Bytes)m_Font.GetSubData());
return GetVerticalGlyph(index, pVertGlyph);
}
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index 0b76ceedff..5563202455 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -279,7 +279,7 @@ void CPDF_Font::LoadUnicodeMap() const {
if (!pStream) {
return;
}
- m_pToUnicodeMap.reset(new CPDF_ToUnicodeMap);
+ m_pToUnicodeMap = pdfium::MakeUnique<CPDF_ToUnicodeMap>();
m_pToUnicodeMap->Load(pStream);
}
@@ -324,18 +324,18 @@ std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc,
if (tag == CFX_ByteString(kChineseFontNames[i], 4)) {
CPDF_Dictionary* pFontDesc = pFontDict->GetDictFor("FontDescriptor");
if (!pFontDesc || !pFontDesc->KeyExist("FontFile2"))
- pFont.reset(new CPDF_CIDFont);
+ pFont = pdfium::MakeUnique<CPDF_CIDFont>();
break;
}
}
if (!pFont)
- pFont.reset(new CPDF_TrueTypeFont);
+ pFont = pdfium::MakeUnique<CPDF_TrueTypeFont>();
} else if (type == "Type3") {
- pFont.reset(new CPDF_Type3Font);
+ pFont = pdfium::MakeUnique<CPDF_Type3Font>();
} else if (type == "Type0") {
- pFont.reset(new CPDF_CIDFont);
+ pFont = pdfium::MakeUnique<CPDF_CIDFont>();
} else {
- pFont.reset(new CPDF_Type1Font);
+ pFont = pdfium::MakeUnique<CPDF_Type1Font>();
}
pFont->m_pFontDict = pFontDict;
pFont->m_pDocument = pDoc;
diff --git a/core/fpdfapi/font/fpdf_font.cpp b/core/fpdfapi/font/fpdf_font.cpp
index bf1fac4518..7bbd637177 100644
--- a/core/fpdfapi/font/fpdf_font.cpp
+++ b/core/fpdfapi/font/fpdf_font.cpp
@@ -24,6 +24,7 @@
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/fx_freetype.h"
#include "third_party/base/numerics/safe_conversions.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
int TT2PDF(int m, FXFT_Face face) {
@@ -87,7 +88,7 @@ CPDF_Font* CPDF_FontGlobals::Set(CPDF_Document* pDoc,
uint32_t index,
std::unique_ptr<CPDF_Font> pFont) {
if (!pdfium::ContainsKey(m_StockMap, pDoc))
- m_StockMap[pDoc].reset(new CFX_StockFontArray);
+ m_StockMap[pDoc] = pdfium::MakeUnique<CFX_StockFontArray>();
return m_StockMap[pDoc]->SetFont(index, std::move(pFont));
}
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 0b8574bfd4..1e0fe62e09 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -17,6 +17,7 @@
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
#define PARSE_STEP_LIMIT 100
@@ -54,7 +55,7 @@ void CPDF_ContentParser::Start(CPDF_Page* pPage) {
}
if (CPDF_Stream* pStream = pContent->AsStream()) {
m_nStreams = 0;
- m_pSingleStream.reset(new CPDF_StreamAcc);
+ m_pSingleStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pSingleStream->LoadAllData(pStream, false);
} else if (CPDF_Array* pArray = pContent->AsArray()) {
m_nStreams = pArray->GetCount();
@@ -94,9 +95,9 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
form_bbox.Transform(pParentMatrix);
}
CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources");
- m_pParser.reset(new CPDF_StreamContentParser(
+ m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>(
pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources,
- pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level));
+ pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level);
m_pParser->GetCurStates()->m_CTM = form_matrix;
m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
if (ClipPath) {
@@ -111,7 +112,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
pState->SetSoftMask(nullptr);
}
m_nStreams = 0;
- m_pSingleStream.reset(new CPDF_StreamAcc);
+ m_pSingleStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pSingleStream->LoadAllData(pForm->m_pFormStream, false);
m_pData = (uint8_t*)m_pSingleStream->GetData();
m_Size = m_pSingleStream->GetSize();
@@ -153,7 +154,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
} else {
CPDF_Array* pContent =
m_pObjectHolder->m_pFormDict->GetArrayFor("Contents");
- m_StreamArray[m_CurrentOffset].reset(new CPDF_StreamAcc);
+ m_StreamArray[m_CurrentOffset] = pdfium::MakeUnique<CPDF_StreamAcc>();
CPDF_Stream* pStreamObj = ToStream(
pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr);
m_StreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, false);
@@ -162,10 +163,10 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
}
if (m_InternalStage == STAGE_PARSE) {
if (!m_pParser) {
- m_pParser.reset(new CPDF_StreamContentParser(
+ m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>(
m_pObjectHolder->m_pDocument, m_pObjectHolder->m_pPageResources,
nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources,
- &m_pObjectHolder->m_BBox, nullptr, 0));
+ &m_pObjectHolder->m_BBox, nullptr, 0);
m_pParser->GetCurStates()->m_ColorState.SetDefault();
}
if (m_CurrentOffset >= m_Size) {
diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp
index 3a5fa0a74a..b3f2b372e3 100644
--- a/core/fpdfapi/page/cpdf_form.cpp
+++ b/core/fpdfapi/page/cpdf_form.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/page/pageint.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
+#include "third_party/base/ptr_util.h"
CPDF_Form::CPDF_Form(CPDF_Document* pDoc,
CPDF_Dictionary* pPageResources,
@@ -39,7 +40,7 @@ void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates,
if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
return;
- m_pParser.reset(new CPDF_ContentParser);
+ m_pParser = pdfium::MakeUnique<CPDF_ContentParser>();
m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, level);
m_ParseState = CONTENT_PARSING;
}
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index b4e2e67939..f9c02837a7 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -17,6 +17,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/render/cpdf_pagerendercache.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
@@ -88,7 +89,7 @@ void CPDF_Page::StartParse() {
if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
return;
- m_pParser.reset(new CPDF_ContentParser);
+ m_pParser = pdfium::MakeUnique<CPDF_ContentParser>();
m_pParser->Start(this);
m_ParseState = CONTENT_PARSING;
}
diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp
index 1b7bee4366..a041f38074 100644
--- a/core/fpdfapi/page/cpdf_tilingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
+#include "third_party/base/ptr_util.h"
CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
@@ -47,7 +48,7 @@ bool CPDF_TilingPattern::Load() {
if (!pStream)
return false;
- m_pForm.reset(new CPDF_Form(m_pDocument, nullptr, pStream));
+ m_pForm = pdfium::MakeUnique<CPDF_Form>(m_pDocument, nullptr, pStream);
m_pForm->ParseContent(nullptr, &m_ParentMatrix, nullptr);
m_BBox = pDict->GetRectFor("BBox");
return true;
diff --git a/core/fpdfapi/page/fpdf_page_func.cpp b/core/fpdfapi/page/fpdf_page_func.cpp
index a6c73b0e5f..672bfc02be 100644
--- a/core/fpdfapi/page/fpdf_page_func.cpp
+++ b/core/fpdfapi/page/fpdf_page_func.cpp
@@ -20,6 +20,7 @@
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -495,7 +496,7 @@ bool CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
return false;
m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample);
- m_pSampleStream.reset(new CPDF_StreamAcc);
+ m_pSampleStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pSampleStream->LoadAllData(pStream, false);
FX_SAFE_UINT32 nTotalSampleBits = 1;
m_EncodeInfo.resize(m_nInputs);
@@ -742,13 +743,13 @@ std::unique_ptr<CPDF_Function> CPDF_Function::Load(CPDF_Object* pFuncObj) {
Type type = IntegerToFunctionType(iType);
if (type == Type::kType0Sampled)
- pFunc.reset(new CPDF_SampledFunc());
+ pFunc = pdfium::MakeUnique<CPDF_SampledFunc>();
else if (type == Type::kType2ExpotentialInterpolation)
- pFunc.reset(new CPDF_ExpIntFunc());
+ pFunc = pdfium::MakeUnique<CPDF_ExpIntFunc>();
else if (type == Type::kType3Stitching)
- pFunc.reset(new CPDF_StitchFunc());
+ pFunc = pdfium::MakeUnique<CPDF_StitchFunc>();
else if (type == Type::kType4PostScript)
- pFunc.reset(new CPDF_PSFunc());
+ pFunc = pdfium::MakeUnique<CPDF_PSFunc>();
if (!pFunc || !pFunc->Init(pFuncObj))
return nullptr;
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp
index e4fe033c8a..91beba3a6b 100644
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp
@@ -108,7 +108,7 @@ class CPDF_TestDocumentWithPageWithoutPageNum : public CPDF_Document {
allPages->Add(CreateNumberedPage(2));
CPDF_Dictionary* pagesDict =
CreatePageTreeNode(std::move(allPages), this, 3);
- m_pOwnedRootDict.reset(new CPDF_Dictionary());
+ m_pOwnedRootDict = pdfium::MakeUnique<CPDF_Dictionary>();
m_pOwnedRootDict->SetNewFor<CPDF_Reference>("Pages", this,
pagesDict->GetObjNum());
m_pRootDict = m_pOwnedRootDict.get();
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 47c5c4eab4..62364c0a75 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -24,6 +24,7 @@
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
#include "core/fxcrt/fx_ext.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -57,7 +58,7 @@ CPDF_Parser::CPDF_Parser()
m_FileVersion(0),
m_pEncryptDict(nullptr),
m_dwXrefStartObjNum(0) {
- m_pSyntax.reset(new CPDF_SyntaxParser);
+ m_pSyntax = pdfium::MakeUnique<CPDF_SyntaxParser>();
}
CPDF_Parser::~CPDF_Parser() {
@@ -242,7 +243,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() {
std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler;
Error err = HANDLER_ERROR;
if (filter == "Standard") {
- pSecurityHandler.reset(new CPDF_SecurityHandler);
+ pSecurityHandler = pdfium::MakeUnique<CPDF_SecurityHandler>();
err = PASSWORD_ERROR;
}
if (!pSecurityHandler)
diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp
index 4f76ec1c63..3159791e82 100644
--- a/core/fpdfapi/parser/cpdf_stream.cpp
+++ b/core/fpdfapi/parser/cpdf_stream.cpp
@@ -13,6 +13,7 @@
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "third_party/base/numerics/safe_conversions.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
CPDF_Stream::CPDF_Stream() {}
@@ -103,7 +104,7 @@ void CPDF_Stream::SetData(const uint8_t* pData, uint32_t size) {
FXSYS_memcpy(m_pDataBuf.get(), pData, size);
m_dwSize = size;
if (!m_pDict)
- m_pDict.reset(new CPDF_Dictionary());
+ m_pDict = pdfium::MakeUnique<CPDF_Dictionary>();
m_pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(size));
m_pDict->RemoveFor("Filter");
m_pDict->RemoveFor("DecodeParms");
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp
index 06b4d13c7a..edc91802fb 100644
--- a/core/fpdfapi/render/cpdf_devicebuffer.cpp
+++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp
@@ -12,6 +12,7 @@
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/fx_dib.h"
+#include "third_party/base/ptr_util.h"
CPDF_DeviceBuffer::CPDF_DeviceBuffer()
: m_pDevice(nullptr), m_pContext(nullptr), m_pObject(nullptr) {}
@@ -49,7 +50,7 @@ bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext,
CFX_FloatRect rect(*pRect);
m_Matrix.TransformRect(rect);
FX_RECT bitmap_rect = rect.GetOuterRect();
- m_pBitmap.reset(new CFX_DIBitmap);
+ m_pBitmap = pdfium::MakeUnique<CFX_DIBitmap>();
m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb);
return true;
}
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index eae32443d8..5ca7ea842f 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -28,6 +28,7 @@
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_pathdata.h"
+#include "third_party/base/ptr_util.h"
#ifdef _SKIA_SUPPORT_
#include "core/fxge/skia/fx_skia_device.h"
@@ -437,8 +438,8 @@ bool CPDF_ImageRenderer::StartDIBSource() {
FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox();
clip_box.Intersect(image_rect);
m_Status = 2;
- m_pTransformer.reset(new CFX_ImageTransformer(m_pDIBSource, &m_ImageMatrix,
- m_Flags, &clip_box));
+ m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
+ m_pDIBSource, &m_ImageMatrix, m_Flags, &clip_box);
m_pTransformer->Start();
return true;
}
diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.cpp b/core/fpdfapi/render/cpdf_progressiverenderer.cpp
index 46d78b6c4e..6aa3b8a309 100644
--- a/core/fpdfapi/render/cpdf_progressiverenderer.cpp
+++ b/core/fpdfapi/render/cpdf_progressiverenderer.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/render/cpdf_renderoptions.h"
#include "core/fpdfapi/render/cpdf_renderstatus.h"
#include "core/fxge/cfx_renderdevice.h"
+#include "third_party/base/ptr_util.h"
CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer(
CPDF_RenderContext* pContext,
@@ -48,7 +49,7 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex);
m_LastObjectRendered =
m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end();
- m_pRenderStatus.reset(new CPDF_RenderStatus());
+ m_pRenderStatus = pdfium::MakeUnique<CPDF_RenderStatus>();
m_pRenderStatus->Initialize(
m_pContext, m_pDevice, nullptr, nullptr, nullptr, nullptr, m_pOptions,
m_pCurrentLayer->m_pObjectHolder->m_Transparency, false, nullptr);
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index b23b98cdb1..3897963de8 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -54,6 +54,7 @@
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/ifx_renderdevicedriver.h"
#include "third_party/base/numerics/safe_math.h"
+#include "third_party/base/ptr_util.h"
#ifdef _SKIA_SUPPORT_
#include "core/fxge/skia/fx_skia_device.h"
@@ -1079,7 +1080,7 @@ bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj,
return false;
if (pObj->IsImage()) {
- m_pImageRenderer.reset(new CPDF_ImageRenderer);
+ m_pImageRenderer = pdfium::MakeUnique<CPDF_ImageRenderer>();
if (!m_pImageRenderer->Start(this, pObj, pObj2Device, false,
FXDIB_BLEND_NORMAL)) {
if (!m_pImageRenderer->GetResult())
@@ -1382,7 +1383,7 @@ void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath,
CPDF_TextObject* pText = ClipPath.GetText(i);
if (pText) {
if (!pTextClippingPath)
- pTextClippingPath.reset(new CFX_PathData);
+ pTextClippingPath = pdfium::MakeUnique<CFX_PathData>();
ProcessText(pText, pObj2Device, pTextClippingPath.get());
continue;
}
@@ -1513,7 +1514,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
CFX_FxgeDevice bitmap_device;
std::unique_ptr<CFX_DIBitmap> oriDevice;
if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) {
- oriDevice.reset(new CFX_DIBitmap);
+ oriDevice = pdfium::MakeUnique<CFX_DIBitmap>();
if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height))
return true;
m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top);
@@ -1527,7 +1528,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
new_matrix.Scale(scaleX, scaleY);
std::unique_ptr<CFX_DIBitmap> pTextMask;
if (bTextClip) {
- pTextMask.reset(new CFX_DIBitmap);
+ pTextMask = pdfium::MakeUnique<CFX_DIBitmap>();
if (!pTextMask->Create(width, height, FXDIB_8bppMask))
return true;
diff --git a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
index a14bb9ea43..bcc03ba2dd 100644
--- a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
+++ b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/render/cpdf_renderoptions.h"
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_renderdevice.h"
+#include "third_party/base/ptr_util.h"
#define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024)
@@ -43,7 +44,7 @@ bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext,
if (dpiv > max_dpi)
m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv);
}
- m_pBitmapDevice.reset(new CFX_FxgeDevice);
+ m_pBitmapDevice = pdfium::MakeUnique<CFX_FxgeDevice>();
FXDIB_Format dibFormat = FXDIB_Rgb;
int32_t bpp = 24;
if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) {
diff --git a/core/fpdfapi/render/fpdf_render_loadimage.cpp b/core/fpdfapi/render/fpdf_render_loadimage.cpp
index 085077f2e9..4a018a849d 100644
--- a/core/fpdfapi/render/fpdf_render_loadimage.cpp
+++ b/core/fpdfapi/render/fpdf_render_loadimage.cpp
@@ -22,6 +22,7 @@
#include "core/fpdfapi/render/cpdf_renderstatus.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -171,7 +172,7 @@ bool CPDF_DIBSource::Load(CPDF_Document* pDoc,
if (!src_size.IsValid()) {
return false;
}
- m_pStreamAcc.reset(new CPDF_StreamAcc);
+ m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true);
if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
return false;
@@ -293,7 +294,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc,
if (!src_size.IsValid()) {
return 0;
}
- m_pStreamAcc.reset(new CPDF_StreamAcc);
+ m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true);
if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
return 0;
@@ -335,12 +336,12 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) {
}
CCodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module();
if (!m_pJbig2Context) {
- m_pJbig2Context.reset(new CCodec_Jbig2Context());
+ m_pJbig2Context = pdfium::MakeUnique<CCodec_Jbig2Context>();
if (m_pStreamAcc->GetImageParam()) {
CPDF_Stream* pGlobals =
m_pStreamAcc->GetImageParam()->GetStreamFor("JBIG2Globals");
if (pGlobals) {
- m_pGlobalStream.reset(new CPDF_StreamAcc);
+ m_pGlobalStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pGlobalStream->LoadAllData(pGlobals, false);
}
}
@@ -676,7 +677,7 @@ void CPDF_DIBSource::LoadJpxBitmap() {
format = FXDIB_Rgb;
}
- m_pCachedBitmap.reset(new CFX_DIBitmap);
+ m_pCachedBitmap = pdfium::MakeUnique<CFX_DIBitmap>();
if (!m_pCachedBitmap->Create(width, height, format)) {
m_pCachedBitmap.reset();
return;
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 5cc7e9bf11..1313516f22 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -15,6 +15,7 @@
#include "core/fpdfdoc/cpvt_wordinfo.h"
#include "core/fpdfdoc/csection.h"
#include "core/fpdfdoc/ipvt_fontmap.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -1096,7 +1097,7 @@ bool CPDF_VariableText::IsLatinWord(uint16_t word) {
CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() {
if (!m_pVTIterator)
- m_pVTIterator.reset(new CPDF_VariableText::Iterator(this));
+ m_pVTIterator = pdfium::MakeUnique<CPDF_VariableText::Iterator>(this);
return m_pVTIterator.get();
}
diff --git a/core/fpdfdoc/cpvt_sectioninfo.cpp b/core/fpdfdoc/cpvt_sectioninfo.cpp
index eb5c1bb809..ec0262c1a0 100644
--- a/core/fpdfdoc/cpvt_sectioninfo.cpp
+++ b/core/fpdfdoc/cpvt_sectioninfo.cpp
@@ -5,6 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fpdfdoc/cpvt_sectioninfo.h"
+#include "third_party/base/ptr_util.h"
CPVT_SectionInfo::CPVT_SectionInfo() : rcSection(), nTotalLine(0) {}
@@ -21,11 +22,12 @@ void CPVT_SectionInfo::operator=(const CPVT_SectionInfo& other) {
rcSection = other.rcSection;
nTotalLine = other.nTotalLine;
if (other.pSecProps)
- pSecProps.reset(new CPVT_SecProps(*other.pSecProps));
+ pSecProps = pdfium::MakeUnique<CPVT_SecProps>(*other.pSecProps);
else
pSecProps.reset();
+
if (other.pWordProps)
- pWordProps.reset(new CPVT_WordProps(*other.pWordProps));
+ pWordProps = pdfium::MakeUnique<CPVT_WordProps>(*other.pWordProps);
else
pWordProps.reset();
}
diff --git a/core/fpdfdoc/cpvt_wordinfo.cpp b/core/fpdfdoc/cpvt_wordinfo.cpp
index 2303f30032..f1ea11915c 100644
--- a/core/fpdfdoc/cpvt_wordinfo.cpp
+++ b/core/fpdfdoc/cpvt_wordinfo.cpp
@@ -5,6 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fpdfdoc/cpvt_wordinfo.h"
+#include "third_party/base/ptr_util.h"
CPVT_WordInfo::CPVT_WordInfo()
: Word(0),
@@ -48,7 +49,7 @@ void CPVT_WordInfo::operator=(const CPVT_WordInfo& word) {
fWordY = word.fWordY;
fWordTail = word.fWordTail;
if (word.pWordProps)
- pWordProps.reset(new CPVT_WordProps(*word.pWordProps));
+ pWordProps = pdfium::MakeUnique<CPVT_WordProps>(*word.pWordProps);
else
pWordProps.reset();
}
diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp
index 8d20894231..926541f07d 100644
--- a/core/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/fxcodec/codec/fx_codec_jbig.cpp
@@ -14,6 +14,7 @@
#include "core/fxcodec/jbig2/JBig2_Context.h"
#include "core/fxcodec/jbig2/JBig2_Image.h"
#include "core/fxcrt/fx_memory.h"
+#include "third_party/base/ptr_util.h"
JBig2_DocumentContext::JBig2_DocumentContext() {}
@@ -22,7 +23,7 @@ JBig2_DocumentContext::~JBig2_DocumentContext() {}
JBig2_DocumentContext* GetJBig2DocumentContext(
std::unique_ptr<JBig2_DocumentContext>* pContextHolder) {
if (!pContextHolder->get())
- pContextHolder->reset(new JBig2_DocumentContext());
+ *pContextHolder = pdfium::MakeUnique<JBig2_DocumentContext>();
return pContextHolder->get();
}
@@ -62,9 +63,9 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(
pJbig2Context->m_dest_pitch = dest_pitch;
pJbig2Context->m_pPause = pPause;
FXSYS_memset(dest_buf, 0, height * dest_pitch);
- pJbig2Context->m_pContext.reset(new CJBig2_Context(
+ pJbig2Context->m_pContext = pdfium::MakeUnique<CJBig2_Context>(
global_stream, src_stream, pJBig2DocumentContext->GetSymbolDictCache(),
- pPause, false));
+ pPause, false);
if (!pJbig2Context->m_pContext)
return FXCODEC_STATUS_ERROR;
diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
index febd00b463..757840598a 100644
--- a/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -22,6 +22,7 @@
#include "core/fxcodec/jbig2/JBig2_PddProc.h"
#include "core/fxcodec/jbig2/JBig2_SddProc.h"
#include "core/fxcodec/jbig2/JBig2_TrdProc.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -60,10 +61,10 @@ CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream,
m_pSymbolDictCache(pSymbolDictCache),
m_bIsGlobal(bIsGlobal) {
if (pGlobalStream && (pGlobalStream->GetSize() > 0)) {
- m_pGlobalContext.reset(new CJBig2_Context(nullptr, pGlobalStream,
- pSymbolDictCache, pPause, true));
+ m_pGlobalContext = pdfium::MakeUnique<CJBig2_Context>(
+ nullptr, pGlobalStream, pSymbolDictCache, pPause, true);
}
- m_pStream.reset(new CJBig2_BitStream(pSrcStream));
+ m_pStream = pdfium::MakeUnique<CJBig2_BitStream>(pSrcStream);
}
CJBig2_Context::~CJBig2_Context() {}
@@ -75,7 +76,7 @@ int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) {
while (m_pStream->getByteLeft() >= JBIG2_MIN_SEGMENT_SIZE) {
if (!m_pSegment) {
- m_pSegment.reset(new CJBig2_Segment);
+ m_pSegment = pdfium::MakeUnique<CJBig2_Segment>();
nRet = parseSegmentHeader(m_pSegment.get());
if (nRet != JBIG2_SUCCESS) {
m_pSegment.reset();
@@ -172,7 +173,7 @@ int32_t CJBig2_Context::getFirstPage(uint8_t* pBuf,
}
}
m_PauseStep = 0;
- m_pPage.reset(new CJBig2_Image(width, height, stride, pBuf));
+ m_pPage = pdfium::MakeUnique<CJBig2_Image>(width, height, stride, pBuf);
m_bBufSpecified = true;
if (pPause && pPause->NeedToPauseNow()) {
m_PauseStep = 1;
@@ -383,7 +384,8 @@ int32_t CJBig2_Context::ProcessingParseSegmentData(CJBig2_Segment* pSegment,
if (!m_bBufSpecified) {
uint32_t height =
bMaxHeight ? pPageInfo->m_wMaxStripeSize : pPageInfo->m_dwHeight;
- m_pPage.reset(new CJBig2_Image(pPageInfo->m_dwWidth, height));
+ m_pPage =
+ pdfium::MakeUnique<CJBig2_Image>(pPageInfo->m_dwWidth, height);
}
if (!m_pPage->m_pData) {
@@ -497,12 +499,12 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
int32_t nIndex = 0;
if (cSDHUFFDH == 0) {
- Table_B4.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B4, HuffmanTable_B4_Size, HuffmanTable_HTOOB_B4));
+ Table_B4 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B4, HuffmanTable_B4_Size, HuffmanTable_HTOOB_B4);
pSymbolDictDecoder->SDHUFFDH = Table_B4.get();
} else if (cSDHUFFDH == 1) {
- Table_B5.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B5, HuffmanTable_B5_Size, HuffmanTable_HTOOB_B5));
+ Table_B5 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B5, HuffmanTable_B5_Size, HuffmanTable_HTOOB_B5);
pSymbolDictDecoder->SDHUFFDH = Table_B5.get();
} else {
CJBig2_Segment* pSeg =
@@ -512,12 +514,12 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
pSymbolDictDecoder->SDHUFFDH = pSeg->m_Result.ht;
}
if (cSDHUFFDW == 0) {
- Table_B2.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B2, HuffmanTable_B2_Size, HuffmanTable_HTOOB_B2));
+ Table_B2 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B2, HuffmanTable_B2_Size, HuffmanTable_HTOOB_B2);
pSymbolDictDecoder->SDHUFFDW = Table_B2.get();
} else if (cSDHUFFDW == 1) {
- Table_B3.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B3, HuffmanTable_B3_Size, HuffmanTable_HTOOB_B3));
+ Table_B3 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B3, HuffmanTable_B3_Size, HuffmanTable_HTOOB_B3);
pSymbolDictDecoder->SDHUFFDW = Table_B3.get();
} else {
CJBig2_Segment* pSeg =
@@ -527,8 +529,8 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
pSymbolDictDecoder->SDHUFFDW = pSeg->m_Result.ht;
}
if (cSDHUFFBMSIZE == 0) {
- Table_B1.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1));
+ Table_B1 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
pSymbolDictDecoder->SDHUFFBMSIZE = Table_B1.get();
} else {
CJBig2_Segment* pSeg =
@@ -540,8 +542,8 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
if (pSymbolDictDecoder->SDREFAGG == 1) {
if (cSDHUFFAGGINST == 0) {
if (!Table_B1) {
- Table_B1.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1));
+ Table_B1 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
}
pSymbolDictDecoder->SDHUFFAGGINST = Table_B1.get();
} else {
@@ -759,12 +761,12 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
int32_t nIndex = 0;
if (cSBHUFFFS == 0) {
- Table_B6.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6));
+ Table_B6 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6);
pTRD->SBHUFFFS = Table_B6.get();
} else if (cSBHUFFFS == 1) {
- Table_B7.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B7, HuffmanTable_B7_Size, HuffmanTable_HTOOB_B7));
+ Table_B7 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B7, HuffmanTable_B7_Size, HuffmanTable_HTOOB_B7);
pTRD->SBHUFFFS = Table_B7.get();
} else {
CJBig2_Segment* pSeg =
@@ -774,16 +776,16 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFFS = pSeg->m_Result.ht;
}
if (cSBHUFFDS == 0) {
- Table_B8.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8));
+ Table_B8 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8);
pTRD->SBHUFFDS = Table_B8.get();
} else if (cSBHUFFDS == 1) {
- Table_B9.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B9, HuffmanTable_B9_Size, HuffmanTable_HTOOB_B9));
+ Table_B9 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B9, HuffmanTable_B9_Size, HuffmanTable_HTOOB_B9);
pTRD->SBHUFFDS = Table_B9.get();
} else if (cSBHUFFDS == 2) {
- Table_B10.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B10, HuffmanTable_B10_Size, HuffmanTable_HTOOB_B10));
+ Table_B10 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B10, HuffmanTable_B10_Size, HuffmanTable_HTOOB_B10);
pTRD->SBHUFFDS = Table_B10.get();
} else {
CJBig2_Segment* pSeg =
@@ -793,16 +795,16 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFDS = pSeg->m_Result.ht;
}
if (cSBHUFFDT == 0) {
- Table_B11.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11));
+ Table_B11 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11);
pTRD->SBHUFFDT = Table_B11.get();
} else if (cSBHUFFDT == 1) {
- Table_B12.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B12, HuffmanTable_B12_Size, HuffmanTable_HTOOB_B12));
+ Table_B12 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B12, HuffmanTable_B12_Size, HuffmanTable_HTOOB_B12);
pTRD->SBHUFFDT = Table_B12.get();
} else if (cSBHUFFDT == 2) {
- Table_B13.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B13, HuffmanTable_B13_Size, HuffmanTable_HTOOB_B13));
+ Table_B13 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B13, HuffmanTable_B13_Size, HuffmanTable_HTOOB_B13);
pTRD->SBHUFFDT = Table_B13.get();
} else {
CJBig2_Segment* pSeg =
@@ -812,12 +814,12 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFDT = pSeg->m_Result.ht;
}
if (cSBHUFFRDW == 0) {
- Table_B14.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
+ Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
pTRD->SBHUFFRDW = Table_B14.get();
} else if (cSBHUFFRDW == 1) {
- Table_B15.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
+ Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
pTRD->SBHUFFRDW = Table_B15.get();
} else {
CJBig2_Segment* pSeg =
@@ -828,14 +830,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
if (cSBHUFFRDH == 0) {
if (!Table_B14) {
- Table_B14.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
+ Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
}
pTRD->SBHUFFRDH = Table_B14.get();
} else if (cSBHUFFRDH == 1) {
if (!Table_B15) {
- Table_B15.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
+ Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
}
pTRD->SBHUFFRDH = Table_B15.get();
} else {
@@ -847,14 +849,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
if (cSBHUFFRDX == 0) {
if (!Table_B14) {
- Table_B14.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
+ Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
}
pTRD->SBHUFFRDX = Table_B14.get();
} else if (cSBHUFFRDX == 1) {
if (!Table_B15) {
- Table_B15.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
+ Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
}
pTRD->SBHUFFRDX = Table_B15.get();
} else {
@@ -866,14 +868,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
if (cSBHUFFRDY == 0) {
if (!Table_B14) {
- Table_B14.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
+ Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
}
pTRD->SBHUFFRDY = Table_B14.get();
} else if (cSBHUFFRDY == 1) {
if (!Table_B15) {
- Table_B15.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
+ Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
}
pTRD->SBHUFFRDY = Table_B15.get();
} else {
@@ -884,8 +886,8 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFRDY = pSeg->m_Result.ht;
}
if (cSBHUFFRSIZE == 0) {
- Table_B1.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1));
+ Table_B1 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
pTRD->SBHUFFRSIZE = Table_B1.get();
} else {
CJBig2_Segment* pSeg =
@@ -1095,7 +1097,8 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
m_gbContext.resize(size);
}
if (!m_pArithDecoder) {
- m_pArithDecoder.reset(new CJBig2_ArithDecoder(m_pStream.get()));
+ m_pArithDecoder =
+ pdfium::MakeUnique<CJBig2_ArithDecoder>(m_pStream.get());
m_ProcessingStatus = m_pGRD->Start_decode_Arith(&pSegment->m_Result.im,
m_pArithDecoder.get(),
&m_gbContext[0], pPause);
diff --git a/core/fxcodec/jbig2/JBig2_HtrdProc.cpp b/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
index f3391b32ff..121bf1d6df 100644
--- a/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
@@ -10,6 +10,7 @@
#include "core/fxcodec/jbig2/JBig2_GsidProc.h"
#include "core/fxcrt/fx_basic.h"
+#include "third_party/base/ptr_util.h"
CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
@@ -22,7 +23,7 @@ CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
std::unique_ptr<CJBig2_Image> HTREG(new CJBig2_Image(HBW, HBH));
HTREG->fill(HDEFPIXEL);
if (HENABLESKIP == 1) {
- HSKIP.reset(new CJBig2_Image(HGW, HGH));
+ HSKIP = pdfium::MakeUnique<CJBig2_Image>(HGW, HGH);
for (mg = 0; mg < HGH; mg++) {
for (ng = 0; ng < HGW; ng++) {
x = (HGX + mg * HRY + ng * HRX) >> 8;
diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp
index 7e9ace2046..d27ff680d5 100644
--- a/core/fxcodec/jbig2/JBig2_SddProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp
@@ -18,6 +18,7 @@
#include "core/fxcodec/jbig2/JBig2_SymbolDict.h"
#include "core/fxcodec/jbig2/JBig2_TrdProc.h"
#include "core/fxcrt/fx_basic.h"
+#include "third_party/base/ptr_util.h"
CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
CJBig2_ArithDecoder* pArithDecoder,
@@ -59,7 +60,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
while ((uint32_t)(1 << nTmp) < (SDNUMINSYMS + SDNUMNEWSYMS)) {
nTmp++;
}
- IAID.reset(new CJBig2_ArithIaidDecoder((uint8_t)nTmp));
+ IAID = pdfium::MakeUnique<CJBig2_ArithIaidDecoder>((uint8_t)nTmp);
SDNEWSYMS = FX_Alloc(CJBig2_Image*, SDNUMNEWSYMS);
FXSYS_memset(SDNEWSYMS, 0, SDNUMNEWSYMS * sizeof(CJBig2_Image*));
@@ -258,7 +259,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
goto failed;
}
- pDict.reset(new CJBig2_SymbolDict);
+ pDict = pdfium::MakeUnique<CJBig2_SymbolDict>();
I = J = 0;
for (I = 0; I < SDNUMINSYMS + SDNUMNEWSYMS; I++) {
if (EXFLAGS[I] && J < SDNUMEXSYMS) {
@@ -562,8 +563,8 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman(
}
EXINDEX = 0;
CUREXFLAG = 0;
- pTable.reset(new CJBig2_HuffmanTable(HuffmanTable_B1, HuffmanTable_B1_Size,
- HuffmanTable_HTOOB_B1));
+ pTable = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
EXFLAGS = FX_Alloc(bool, SDNUMINSYMS + SDNUMNEWSYMS);
num_ex_syms = 0;
while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) {
diff --git a/core/fxcodec/jbig2/JBig2_TrdProc.cpp b/core/fxcodec/jbig2/JBig2_TrdProc.cpp
index 1fa4373d79..84042dbd8c 100644
--- a/core/fxcodec/jbig2/JBig2_TrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_TrdProc.cpp
@@ -12,6 +12,7 @@
#include "core/fxcodec/jbig2/JBig2_ArithIntDecoder.h"
#include "core/fxcodec/jbig2/JBig2_GrrdProc.h"
#include "core/fxcodec/jbig2/JBig2_HuffmanDecoder.h"
+#include "third_party/base/ptr_util.h"
CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream,
JBig2ArithCtx* grContext) {
@@ -242,16 +243,16 @@ CJBig2_Image* CJBig2_TRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
pIARDY = pIDS->IARDY;
pIAID = pIDS->IAID;
} else {
- IADT.reset(new CJBig2_ArithIntDecoder());
- IAFS.reset(new CJBig2_ArithIntDecoder());
- IADS.reset(new CJBig2_ArithIntDecoder());
- IAIT.reset(new CJBig2_ArithIntDecoder());
- IARI.reset(new CJBig2_ArithIntDecoder());
- IARDW.reset(new CJBig2_ArithIntDecoder());
- IARDH.reset(new CJBig2_ArithIntDecoder());
- IARDX.reset(new CJBig2_ArithIntDecoder());
- IARDY.reset(new CJBig2_ArithIntDecoder());
- IAID.reset(new CJBig2_ArithIaidDecoder(SBSYMCODELEN));
+ IADT = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IAFS = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IADS = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IAIT = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IARI = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IARDW = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IARDH = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IARDX = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IARDY = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IAID = pdfium::MakeUnique<CJBig2_ArithIaidDecoder>(SBSYMCODELEN);
pIADT = IADT.get();
pIAFS = IAFS.get();
pIADS = IADS.get();