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 "xfa/fgas/crt/fgas_utils.h" | 7 #include "xfa/fgas/crt/fgas_utils.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 FX_BASEARRAYDATA::~FX_BASEARRAYDATA() { | 32 FX_BASEARRAYDATA::~FX_BASEARRAYDATA() { |
33 FX_Free(pBuffer); | 33 FX_Free(pBuffer); |
34 } | 34 } |
35 | 35 |
36 CFX_BaseArray::CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize) { | 36 CFX_BaseArray::CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize) { |
37 ASSERT(iGrowSize > 0 && iBlockSize > 0); | 37 ASSERT(iGrowSize > 0 && iBlockSize > 0); |
38 m_pData = new FX_BASEARRAYDATA(iGrowSize, iBlockSize); | 38 m_pData = new FX_BASEARRAYDATA(iGrowSize, iBlockSize); |
39 } | 39 } |
40 CFX_BaseArray::~CFX_BaseArray() { | 40 CFX_BaseArray::~CFX_BaseArray() { |
41 RemoveAll(); | 41 RemoveAll(FALSE); |
42 delete m_pData; | 42 delete m_pData; |
43 } | 43 } |
44 int32_t CFX_BaseArray::GetSize() const { | 44 int32_t CFX_BaseArray::GetSize() const { |
45 return m_pData->iBlockCount; | 45 return m_pData->iBlockCount; |
46 } | 46 } |
47 int32_t CFX_BaseArray::GetBlockSize() const { | 47 int32_t CFX_BaseArray::GetBlockSize() const { |
48 return m_pData->iBlockSize; | 48 return m_pData->iBlockSize; |
49 } | 49 } |
50 uint8_t* CFX_BaseArray::AddSpaceTo(int32_t index) { | 50 uint8_t* CFX_BaseArray::AddSpaceTo(int32_t index) { |
51 ASSERT(index > -1); | 51 ASSERT(index > -1); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 int32_t iBlockSize) | 146 int32_t iBlockSize) |
147 : m_iChunkSize(iChunkSize), | 147 : m_iChunkSize(iChunkSize), |
148 m_iBlockSize(iBlockSize), | 148 m_iBlockSize(iBlockSize), |
149 m_iChunkCount(0), | 149 m_iChunkCount(0), |
150 m_iBlockCount(0), | 150 m_iBlockCount(0), |
151 m_pData(new CFX_ArrayTemplate<void*>()) { | 151 m_pData(new CFX_ArrayTemplate<void*>()) { |
152 ASSERT(m_iChunkSize > 0 && m_iBlockSize > 0); | 152 ASSERT(m_iChunkSize > 0 && m_iBlockSize > 0); |
153 m_pData->SetSize(16); | 153 m_pData->SetSize(16); |
154 } | 154 } |
155 CFX_BaseMassArrayImp::~CFX_BaseMassArrayImp() { | 155 CFX_BaseMassArrayImp::~CFX_BaseMassArrayImp() { |
156 RemoveAll(); | 156 RemoveAll(FALSE); |
157 delete m_pData; | 157 delete m_pData; |
158 } | 158 } |
159 uint8_t* CFX_BaseMassArrayImp::AddSpaceTo(int32_t index) { | 159 uint8_t* CFX_BaseMassArrayImp::AddSpaceTo(int32_t index) { |
160 ASSERT(index > -1); | 160 ASSERT(index > -1); |
161 uint8_t* pChunk; | 161 uint8_t* pChunk; |
162 if (index < m_iBlockCount) { | 162 if (index < m_iBlockCount) { |
163 pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize); | 163 pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize); |
164 } else { | 164 } else { |
165 int32_t iMemSize = m_iChunkSize * m_iBlockSize; | 165 int32_t iMemSize = m_iChunkSize * m_iBlockSize; |
166 while (TRUE) { | 166 while (TRUE) { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 } | 423 } |
424 int32_t CFX_BaseStack::GetSize() const { | 424 int32_t CFX_BaseStack::GetSize() const { |
425 return m_pData->m_iBlockCount; | 425 return m_pData->m_iBlockCount; |
426 } | 426 } |
427 uint8_t* CFX_BaseStack::GetAt(int32_t index) const { | 427 uint8_t* CFX_BaseStack::GetAt(int32_t index) const { |
428 return m_pData->GetAt(index); | 428 return m_pData->GetAt(index); |
429 } | 429 } |
430 void CFX_BaseStack::RemoveAll(FX_BOOL bLeaveMemory) { | 430 void CFX_BaseStack::RemoveAll(FX_BOOL bLeaveMemory) { |
431 m_pData->RemoveAll(bLeaveMemory); | 431 m_pData->RemoveAll(bLeaveMemory); |
432 } | 432 } |
OLD | NEW |