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 CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 7 #ifndef CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
8 #define CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 8 #define CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
9 | 9 |
10 #include "fx_memory.h" | 10 #include "fx_memory.h" |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 public: | 558 public: |
559 CFX_FixedBufGrow() : m_pData(NULL) {} | 559 CFX_FixedBufGrow() : m_pData(NULL) {} |
560 CFX_FixedBufGrow(int data_size) : m_pData(NULL) { | 560 CFX_FixedBufGrow(int data_size) : m_pData(NULL) { |
561 if (data_size > FixedSize) { | 561 if (data_size > FixedSize) { |
562 m_pData = FX_Alloc(DataType, data_size); | 562 m_pData = FX_Alloc(DataType, data_size); |
563 } else { | 563 } else { |
564 FXSYS_memset(m_Data, 0, sizeof(DataType) * FixedSize); | 564 FXSYS_memset(m_Data, 0, sizeof(DataType) * FixedSize); |
565 } | 565 } |
566 } | 566 } |
567 void SetDataSize(int data_size) { | 567 void SetDataSize(int data_size) { |
568 if (m_pData) { | 568 FX_Free(m_pData); |
569 FX_Free(m_pData); | |
570 } | |
571 m_pData = NULL; | 569 m_pData = NULL; |
572 if (data_size > FixedSize) { | 570 if (data_size > FixedSize) { |
573 m_pData = FX_Alloc(DataType, data_size); | 571 m_pData = FX_Alloc(DataType, data_size); |
574 } else { | 572 } else { |
575 FXSYS_memset(m_Data, 0, sizeof(DataType) * FixedSize); | 573 FXSYS_memset(m_Data, 0, sizeof(DataType) * FixedSize); |
576 } | 574 } |
577 } | 575 } |
578 ~CFX_FixedBufGrow() { | 576 ~CFX_FixedBufGrow() { FX_Free(m_pData); } |
579 if (m_pData) { | |
580 FX_Free(m_pData); | |
581 } | |
582 } | |
583 operator DataType*() { return m_pData ? m_pData : m_Data; } | 577 operator DataType*() { return m_pData ? m_pData : m_Data; } |
584 | 578 |
585 private: | 579 private: |
586 DataType m_Data[FixedSize]; | 580 DataType m_Data[FixedSize]; |
587 DataType* m_pData; | 581 DataType* m_pData; |
588 }; | 582 }; |
589 class CFX_MapPtrToPtr { | 583 class CFX_MapPtrToPtr { |
590 protected: | 584 protected: |
591 struct CAssoc { | 585 struct CAssoc { |
592 CAssoc* pNext; | 586 CAssoc* pNext; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 }; | 1065 }; |
1072 | 1066 |
1073 public: | 1067 public: |
1074 CFX_SortListArray() : m_CurList(0) {} | 1068 CFX_SortListArray() : m_CurList(0) {} |
1075 | 1069 |
1076 ~CFX_SortListArray() { Clear(); } | 1070 ~CFX_SortListArray() { Clear(); } |
1077 | 1071 |
1078 void Clear() { | 1072 void Clear() { |
1079 for (int32_t i = m_DataLists.GetUpperBound(); i >= 0; i--) { | 1073 for (int32_t i = m_DataLists.GetUpperBound(); i >= 0; i--) { |
1080 DataList list = m_DataLists.ElementAt(i); | 1074 DataList list = m_DataLists.ElementAt(i); |
1081 if (list.data) { | 1075 FX_Free(list.data); |
1082 FX_Free(list.data); | |
1083 } | |
1084 } | 1076 } |
1085 m_DataLists.RemoveAll(); | 1077 m_DataLists.RemoveAll(); |
1086 m_CurList = 0; | 1078 m_CurList = 0; |
1087 } | 1079 } |
1088 | 1080 |
1089 void Append(int32_t nStart, int32_t nCount) { | 1081 void Append(int32_t nStart, int32_t nCount) { |
1090 if (nStart < 0) { | 1082 if (nStart < 0) { |
1091 return; | 1083 return; |
1092 } | 1084 } |
1093 while (nCount > 0) { | 1085 while (nCount > 0) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 FX_FLOAT c; | 1233 FX_FLOAT c; |
1242 FX_FLOAT d; | 1234 FX_FLOAT d; |
1243 FX_FLOAT e; | 1235 FX_FLOAT e; |
1244 FX_FLOAT f; | 1236 FX_FLOAT f; |
1245 FX_FLOAT g; | 1237 FX_FLOAT g; |
1246 FX_FLOAT h; | 1238 FX_FLOAT h; |
1247 FX_FLOAT i; | 1239 FX_FLOAT i; |
1248 }; | 1240 }; |
1249 | 1241 |
1250 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 1242 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
OLD | NEW |