Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: core/src/fxcodec/jbig2/JBig2_List.h

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 public:
14 public: 14 CJBig2_List(int32_t nSize = 8) {
15 m_nSize = nSize;
16 m_pArray = (TYPE**)m_pModule->JBig2_Malloc2(sizeof(TYPE*), nSize);
17 m_nLength = 0;
18 }
15 19
16 CJBig2_List(int32_t nSize = 8) 20 ~CJBig2_List() {
17 { 21 clear();
18 m_nSize = nSize; 22 m_pModule->JBig2_Free(m_pArray);
19 m_pArray = (TYPE**)m_pModule->JBig2_Malloc2(sizeof(TYPE*), nSize); 23 }
20 m_nLength = 0; 24
25 void clear() {
26 int32_t i;
27 for (i = 0; i < m_nLength; i++) {
28 delete m_pArray[i];
21 } 29 }
30 m_nLength = 0;
31 }
22 32
23 ~CJBig2_List() 33 void addItem(TYPE* pItem) {
24 { 34 if (m_nLength >= m_nSize) {
25 clear(); 35 m_nSize += 8;
26 m_pModule->JBig2_Free(m_pArray); 36 m_pArray =
37 (TYPE**)m_pModule->JBig2_Realloc(m_pArray, sizeof(TYPE*) * m_nSize);
27 } 38 }
39 m_pArray[m_nLength++] = pItem;
40 }
28 41
29 void clear() 42 int32_t getLength() { return m_nLength; }
30 {
31 int32_t i;
32 for(i = 0; i < m_nLength; i++) {
33 delete m_pArray[i];
34 }
35 m_nLength = 0;
36 }
37 43
38 void addItem(TYPE *pItem) 44 TYPE* getAt(int32_t nIndex) { return m_pArray[nIndex]; }
39 {
40 if(m_nLength >= m_nSize) {
41 m_nSize += 8;
42 m_pArray = (TYPE**)m_pModule->JBig2_Realloc(m_pArray, sizeof(TYPE*)* m_nSize);
43 }
44 m_pArray[m_nLength++] = pItem;
45 }
46 45
46 TYPE* getLast() { return m_pArray[m_nLength - 1]; }
47 47
48 int32_t getLength() 48 private:
49 { 49 int32_t m_nSize;
50 return m_nLength; 50 TYPE** m_pArray;
51 } 51 int32_t m_nLength;
52
53 TYPE *getAt(int32_t nIndex)
54 {
55 return m_pArray[nIndex];
56 }
57
58 TYPE *getLast()
59 {
60 return m_pArray[m_nLength - 1];
61 }
62 private:
63 int32_t m_nSize;
64 TYPE **m_pArray;
65 int32_t m_nLength;
66 }; 52 };
67 #endif 53 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698