OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "JBig2_SymbolDict.h" | 7 #include "JBig2_SymbolDict.h" |
| 8 |
| 9 #include "../../../include/fxcrt/fx_memory.h" |
| 10 |
8 CJBig2_SymbolDict::CJBig2_SymbolDict() { | 11 CJBig2_SymbolDict::CJBig2_SymbolDict() { |
9 SDNUMEXSYMS = 0; | 12 SDNUMEXSYMS = 0; |
10 SDEXSYMS = NULL; | 13 SDEXSYMS = NULL; |
11 m_bContextRetained = FALSE; | 14 m_bContextRetained = FALSE; |
12 m_gbContext = m_grContext = NULL; | 15 m_gbContext = m_grContext = NULL; |
13 } | 16 } |
14 | 17 |
15 CJBig2_SymbolDict* CJBig2_SymbolDict::DeepCopy() { | 18 CJBig2_SymbolDict* CJBig2_SymbolDict::DeepCopy() { |
16 CJBig2_SymbolDict* dst = NULL; | |
17 CJBig2_SymbolDict* src = this; | 19 CJBig2_SymbolDict* src = this; |
18 if (src->m_bContextRetained || src->m_gbContext || src->m_grContext) { | 20 if (src->m_bContextRetained || src->m_gbContext || src->m_grContext) { |
19 return NULL; | 21 return NULL; |
20 } | 22 } |
21 JBIG2_ALLOC(dst, CJBig2_SymbolDict()); | 23 CJBig2_SymbolDict* dst = new CJBig2_SymbolDict; |
22 dst->SDNUMEXSYMS = src->SDNUMEXSYMS; | 24 dst->SDNUMEXSYMS = src->SDNUMEXSYMS; |
23 dst->SDEXSYMS = (CJBig2_Image**)m_pModule->JBig2_Malloc2( | 25 dst->SDEXSYMS = (CJBig2_Image**)FX_Alloc2D(uint8_t, sizeof(CJBig2_Image*), |
24 sizeof(CJBig2_Image*), src->SDNUMEXSYMS); | 26 src->SDNUMEXSYMS); |
25 for (FX_DWORD i = 0; i < src->SDNUMEXSYMS; i++) { | 27 for (FX_DWORD i = 0; i < src->SDNUMEXSYMS; i++) { |
26 if (src->SDEXSYMS[i]) { | 28 if (src->SDEXSYMS[i]) { |
27 JBIG2_ALLOC(dst->SDEXSYMS[i], CJBig2_Image(*(src->SDEXSYMS[i]))); | 29 dst->SDEXSYMS[i] = new CJBig2_Image(*(src->SDEXSYMS[i])); |
28 } else { | 30 } else { |
29 dst->SDEXSYMS[i] = NULL; | 31 dst->SDEXSYMS[i] = NULL; |
30 } | 32 } |
31 } | 33 } |
32 return dst; | 34 return dst; |
33 } | 35 } |
34 | 36 |
35 CJBig2_SymbolDict::~CJBig2_SymbolDict() { | 37 CJBig2_SymbolDict::~CJBig2_SymbolDict() { |
36 if (SDEXSYMS) { | 38 if (SDEXSYMS) { |
37 for (FX_DWORD i = 0; i < SDNUMEXSYMS; i++) { | 39 for (FX_DWORD i = 0; i < SDNUMEXSYMS; i++) { |
38 delete SDEXSYMS[i]; | 40 delete SDEXSYMS[i]; |
39 } | 41 } |
40 m_pModule->JBig2_Free(SDEXSYMS); | 42 FX_Free(SDEXSYMS); |
41 } | 43 } |
42 if (m_bContextRetained) { | 44 if (m_bContextRetained) { |
43 if (m_gbContext) { | 45 FX_Free(m_gbContext); |
44 m_pModule->JBig2_Free(m_gbContext); | 46 FX_Free(m_grContext); |
45 } | |
46 if (m_grContext) { | |
47 m_pModule->JBig2_Free(m_grContext); | |
48 } | |
49 } | 47 } |
50 } | 48 } |
OLD | NEW |