| 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 #ifndef _JBIG2_LIST_H_ | 7 #ifndef _JBIG2_LIST_H_ |
| 8 #define _JBIG2_LIST_H_ | 8 #define _JBIG2_LIST_H_ |
| 9 #include "JBig2_Define.h" | 9 #include "JBig2_Define.h" |
| 10 #include "JBig2_Object.h" | 10 #include "JBig2_Object.h" |
| 11 template <class TYPE> | 11 template <class TYPE> |
| 12 class CJBig2_List : public CJBig2_Object | 12 class CJBig2_List : public CJBig2_Object |
| 13 { | 13 { |
| 14 public: | 14 public: |
| 15 | 15 |
| 16 CJBig2_List(FX_INT32 nSize = 8) | 16 CJBig2_List(int32_t nSize = 8) |
| 17 { | 17 { |
| 18 m_nSize = nSize; | 18 m_nSize = nSize; |
| 19 m_pArray = (TYPE**)m_pModule->JBig2_Malloc2(sizeof(TYPE*), nSize); | 19 m_pArray = (TYPE**)m_pModule->JBig2_Malloc2(sizeof(TYPE*), nSize); |
| 20 m_nLength = 0; | 20 m_nLength = 0; |
| 21 } | 21 } |
| 22 | 22 |
| 23 ~CJBig2_List() | 23 ~CJBig2_List() |
| 24 { | 24 { |
| 25 clear(); | 25 clear(); |
| 26 m_pModule->JBig2_Free(m_pArray); | 26 m_pModule->JBig2_Free(m_pArray); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void clear() | 29 void clear() |
| 30 { | 30 { |
| 31 FX_INT32 i; | 31 int32_t i; |
| 32 for(i = 0; i < m_nLength; i++) { | 32 for(i = 0; i < m_nLength; i++) { |
| 33 delete m_pArray[i]; | 33 delete m_pArray[i]; |
| 34 } | 34 } |
| 35 m_nLength = 0; | 35 m_nLength = 0; |
| 36 } | 36 } |
| 37 | 37 |
| 38 void addItem(TYPE *pItem) | 38 void addItem(TYPE *pItem) |
| 39 { | 39 { |
| 40 if(m_nLength >= m_nSize) { | 40 if(m_nLength >= m_nSize) { |
| 41 m_nSize += 8; | 41 m_nSize += 8; |
| 42 m_pArray = (TYPE**)m_pModule->JBig2_Realloc(m_pArray, sizeof(TYPE*)*
m_nSize); | 42 m_pArray = (TYPE**)m_pModule->JBig2_Realloc(m_pArray, sizeof(TYPE*)*
m_nSize); |
| 43 } | 43 } |
| 44 m_pArray[m_nLength++] = pItem; | 44 m_pArray[m_nLength++] = pItem; |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 |
| 48 FX_INT32 getLength() | 48 int32_t getLength() |
| 49 { | 49 { |
| 50 return m_nLength; | 50 return m_nLength; |
| 51 } | 51 } |
| 52 | 52 |
| 53 TYPE *getAt(FX_INT32 nIndex) | 53 TYPE *getAt(int32_t nIndex) |
| 54 { | 54 { |
| 55 return m_pArray[nIndex]; | 55 return m_pArray[nIndex]; |
| 56 } | 56 } |
| 57 | 57 |
| 58 TYPE *getLast() | 58 TYPE *getLast() |
| 59 { | 59 { |
| 60 return m_pArray[m_nLength - 1]; | 60 return m_pArray[m_nLength - 1]; |
| 61 } | 61 } |
| 62 private: | 62 private: |
| 63 FX_INT32 m_nSize; | 63 int32_t m_nSize; |
| 64 TYPE **m_pArray; | 64 TYPE **m_pArray; |
| 65 FX_INT32 m_nLength; | 65 int32_t m_nLength; |
| 66 }; | 66 }; |
| 67 #endif | 67 #endif |
| OLD | NEW |