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 XFA_FGAS_CRT_FGAS_MEMORY_H_ | 7 #ifndef XFA_FGAS_CRT_FGAS_MEMORY_H_ |
8 #define XFA_FGAS_CRT_FGAS_MEMORY_H_ | 8 #define XFA_FGAS_CRT_FGAS_MEMORY_H_ |
9 | 9 |
10 #include "core/fxcrt/include/fx_memory.h" | 10 #include "core/fxcrt/include/fx_memory.h" |
11 #include "core/fxcrt/include/fx_system.h" | 11 #include "core/fxcrt/include/fx_system.h" |
12 | 12 |
13 enum FX_ALLOCTYPE { | 13 enum FX_ALLOCTYPE { |
14 FX_ALLOCTYPE_Static, | 14 FX_ALLOCTYPE_Static, |
15 FX_ALLOCTYPE_Fixed, | 15 FX_ALLOCTYPE_Fixed, |
16 }; | 16 }; |
17 | 17 |
18 class IFX_MemoryAllocator { | 18 class IFX_MemoryAllocator { |
19 public: | 19 public: |
20 virtual ~IFX_MemoryAllocator() {} | 20 virtual ~IFX_MemoryAllocator() {} |
21 virtual void Release() = 0; | |
22 | |
23 virtual void* Alloc(size_t size) = 0; | 21 virtual void* Alloc(size_t size) = 0; |
24 virtual void Free(void* pBlock) = 0; | 22 virtual void Free(void* pBlock) = 0; |
25 | 23 |
26 static IFX_MemoryAllocator* Create(FX_ALLOCTYPE eType, | 24 static IFX_MemoryAllocator* Create(FX_ALLOCTYPE eType, |
27 size_t chunkSize, | 25 size_t chunkSize, |
28 size_t blockSize); | 26 size_t blockSize); |
29 }; | 27 }; |
30 | 28 |
31 class CFX_Target { | 29 class CFX_Target { |
32 public: | 30 public: |
(...skipping 11 matching lines...) Expand all Loading... |
44 }; | 42 }; |
45 | 43 |
46 #define FXTARGET_NewWith(__allocator__) new (__allocator__) | 44 #define FXTARGET_NewWith(__allocator__) new (__allocator__) |
47 #define FXTARGET_DeleteWith(__class__, __allocator__, pointer) \ | 45 #define FXTARGET_DeleteWith(__class__, __allocator__, pointer) \ |
48 { \ | 46 { \ |
49 (pointer)->~__class__(); \ | 47 (pointer)->~__class__(); \ |
50 (pointer)->operator delete((pointer), (__allocator__)); \ | 48 (pointer)->operator delete((pointer), (__allocator__)); \ |
51 } | 49 } |
52 | 50 |
53 #endif // XFA_FGAS_CRT_FGAS_MEMORY_H_ | 51 #endif // XFA_FGAS_CRT_FGAS_MEMORY_H_ |
OLD | NEW |