| Index: core/fxcodec/jbig2/JBig2_Context.cpp
|
| diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
|
| index 8dde290be6df11c362579eb35424f198156fa573..669393e64ec4951010877827f20d8ef42fa749c1 100644
|
| --- a/core/fxcodec/jbig2/JBig2_Context.cpp
|
| +++ b/core/fxcodec/jbig2/JBig2_Context.cpp
|
| @@ -45,19 +45,6 @@ size_t GetRefAggContextSize(FX_BOOL val) {
|
| // difference for typical JBIG2 documents.
|
| static const int kSymbolDictCacheMaxSize = 2;
|
|
|
| -CJBig2_Context* CJBig2_Context::CreateContext(
|
| - CPDF_StreamAcc* pGlobalStream,
|
| - CPDF_StreamAcc* pSrcStream,
|
| - std::list<CJBig2_CachePair>* pSymbolDictCache,
|
| - IFX_Pause* pPause) {
|
| - return new CJBig2_Context(pGlobalStream, pSrcStream, pSymbolDictCache, pPause,
|
| - false);
|
| -}
|
| -
|
| -void CJBig2_Context::DestroyContext(CJBig2_Context* pContext) {
|
| - delete pContext;
|
| -}
|
| -
|
| CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream,
|
| CPDF_StreamAcc* pSrcStream,
|
| std::list<CJBig2_CachePair>* pSymbolDictCache,
|
| @@ -69,26 +56,17 @@ CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream,
|
| m_PauseStep(10),
|
| m_pPause(pPause),
|
| m_ProcessingStatus(FXCODEC_STATUS_FRAME_READY),
|
| - m_gbContext(nullptr),
|
| m_dwOffset(0),
|
| m_pSymbolDictCache(pSymbolDictCache),
|
| m_bIsGlobal(bIsGlobal) {
|
| if (pGlobalStream && (pGlobalStream->GetSize() > 0)) {
|
| - m_pGlobalContext = new CJBig2_Context(nullptr, pGlobalStream,
|
| - pSymbolDictCache, pPause, true);
|
| - } else {
|
| - m_pGlobalContext = nullptr;
|
| + m_pGlobalContext.reset(new CJBig2_Context(nullptr, pGlobalStream,
|
| + pSymbolDictCache, pPause, true));
|
| }
|
| -
|
| m_pStream.reset(new CJBig2_BitStream(pSrcStream));
|
| }
|
|
|
| -CJBig2_Context::~CJBig2_Context() {
|
| - FX_Free(m_gbContext);
|
| - m_gbContext = nullptr;
|
| - delete m_pGlobalContext;
|
| - m_pGlobalContext = nullptr;
|
| -}
|
| +CJBig2_Context::~CJBig2_Context() {}
|
|
|
| int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) {
|
| int32_t nRet;
|
| @@ -1108,13 +1086,14 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
|
| if (m_pGRD->MMR == 0) {
|
| if (!m_gbContext) {
|
| const size_t size = GetHuffContextSize(m_pGRD->GBTEMPLATE);
|
| - m_gbContext = FX_Alloc(JBig2ArithCtx, size);
|
| - JBIG2_memset(m_gbContext, 0, sizeof(JBig2ArithCtx) * size);
|
| + m_gbContext.reset(FX_Alloc(JBig2ArithCtx, size));
|
| + JBIG2_memset(m_gbContext.get(), 0, sizeof(JBig2ArithCtx) * size);
|
| }
|
| if (!m_pArithDecoder) {
|
| m_pArithDecoder.reset(new CJBig2_ArithDecoder(m_pStream.get()));
|
| m_ProcessingStatus = m_pGRD->Start_decode_Arith(
|
| - &pSegment->m_Result.im, m_pArithDecoder.get(), m_gbContext, pPause);
|
| + &pSegment->m_Result.im, m_pArithDecoder.get(), m_gbContext.get(),
|
| + pPause);
|
| } else {
|
| m_ProcessingStatus = m_pGRD->Continue_decode(pPause);
|
| }
|
| @@ -1136,8 +1115,7 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
|
| return JBIG2_SUCCESS;
|
| } else {
|
| m_pArithDecoder.reset();
|
| - FX_Free(m_gbContext);
|
| - m_gbContext = nullptr;
|
| + m_gbContext.reset();
|
| if (!pSegment->m_Result.im) {
|
| m_ProcessingStatus = FXCODEC_STATUS_ERROR;
|
| m_pGRD.reset();
|
|
|