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_memory.h" | 7 #include "xfa/fgas/crt/fgas_memory.h" |
8 | 8 |
9 #ifndef MEMORY_TOOL_REPLACES_ALLOCATOR | 9 #ifndef MEMORY_TOOL_REPLACES_ALLOCATOR |
10 // Use CFX_DefStore to replace CFX_FixedStore to simplify memory | 10 // Use CFX_DefStore to replace CFX_FixedStore to simplify memory |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 new CFX_StaticStore(chunkSize)); | 93 new CFX_StaticStore(chunkSize)); |
94 case FX_ALLOCTYPE_Fixed: | 94 case FX_ALLOCTYPE_Fixed: |
95 #ifdef MEMORY_TOOL_REPLACES_ALLOCATOR | 95 #ifdef MEMORY_TOOL_REPLACES_ALLOCATOR |
96 return std::unique_ptr<IFX_MemoryAllocator>(new CFX_DefStore()); | 96 return std::unique_ptr<IFX_MemoryAllocator>(new CFX_DefStore()); |
97 #else | 97 #else |
98 return std::unique_ptr<IFX_MemoryAllocator>( | 98 return std::unique_ptr<IFX_MemoryAllocator>( |
99 new CFX_FixedStore(blockSize, chunkSize)); | 99 new CFX_FixedStore(blockSize, chunkSize)); |
100 #endif // MEMORY_TOOL_REPLACES_ALLOCATOR | 100 #endif // MEMORY_TOOL_REPLACES_ALLOCATOR |
101 default: | 101 default: |
102 ASSERT(0); | 102 ASSERT(0); |
103 return std::unique_ptr<IFX_MemoryAllocator>(); | 103 return nullptr; |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 CFX_StaticStore::CFX_StaticStore(size_t iDefChunkSize) | 107 CFX_StaticStore::CFX_StaticStore(size_t iDefChunkSize) |
108 : m_iAllocatedSize(0), | 108 : m_iAllocatedSize(0), |
109 m_iDefChunkSize(iDefChunkSize), | 109 m_iDefChunkSize(iDefChunkSize), |
110 m_pChunk(nullptr), | 110 m_pChunk(nullptr), |
111 m_pLastChunk(nullptr) { | 111 m_pLastChunk(nullptr) { |
112 ASSERT(m_iDefChunkSize != 0); | 112 ASSERT(m_iDefChunkSize != 0); |
113 } | 113 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 if (!pPrior) { | 245 if (!pPrior) { |
246 m_pChunk = pChunk->pNextChunk; | 246 m_pChunk = pChunk->pNextChunk; |
247 } else { | 247 } else { |
248 pPrior->pNextChunk = pChunk->pNextChunk; | 248 pPrior->pNextChunk = pChunk->pNextChunk; |
249 } | 249 } |
250 FX_Free(pChunk); | 250 FX_Free(pChunk); |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 #endif // MEMORY_TOOL_REPLACES_ALLOCATOR | 254 #endif // MEMORY_TOOL_REPLACES_ALLOCATOR |
OLD | NEW |