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

Side by Side Diff: xfa/fgas/crt/fgas_memory.h

Issue 1944093002: Cleanup XFA-Specific memory allocators. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Dan's comments, remove more unused methods. Created 4 years, 7 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
« no previous file with comments | « xfa/fee/fde_txtedtbuf.cpp ('k') | xfa/fgas/crt/fgas_memory.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 class IFX_MEMAllocator;
14 class CFX_Target;
15 enum FX_ALLOCTYPE { 13 enum FX_ALLOCTYPE {
16 FX_ALLOCTYPE_Default = 0,
17 FX_ALLOCTYPE_Static, 14 FX_ALLOCTYPE_Static,
18 FX_ALLOCTYPE_Fixed, 15 FX_ALLOCTYPE_Fixed,
19 FX_ALLOCTYPE_Dynamic,
20 }; 16 };
21 17
22 class IFX_MEMAllocator { 18 class IFX_MemoryAllocator {
23 public: 19 public:
24 virtual ~IFX_MEMAllocator() {} 20 virtual ~IFX_MemoryAllocator() {}
25 virtual void Release() = 0; 21 virtual void Release() = 0;
22
26 virtual void* Alloc(size_t size) = 0; 23 virtual void* Alloc(size_t size) = 0;
27 virtual void Free(void* pBlock) = 0; 24 virtual void Free(void* pBlock) = 0;
28 virtual size_t GetBlockSize() const = 0; 25
29 virtual size_t GetDefChunkSize() const = 0; 26 static IFX_MemoryAllocator* Create(FX_ALLOCTYPE eType,
30 virtual size_t SetDefChunkSize(size_t size) = 0; 27 size_t chunkSize,
31 virtual size_t GetCurrentDataSize() const = 0; 28 size_t blockSize);
32 }; 29 };
33 30
34 IFX_MEMAllocator* FX_CreateAllocator(FX_ALLOCTYPE eType,
35 size_t chunkSize,
36 size_t blockSize);
37 class CFX_Target { 31 class CFX_Target {
38 public: 32 public:
39 virtual ~CFX_Target() {} 33 virtual ~CFX_Target() {}
40 void* operator new(size_t size) { return FX_Alloc(uint8_t, size); } 34 void* operator new(size_t size) { return FX_Alloc(uint8_t, size); }
41 void operator delete(void* p) { FX_Free(p); } 35 void operator delete(void* p) { FX_Free(p); }
42 void* operator new(size_t size, IFX_MEMAllocator* pAllocator) { 36 void* operator new(size_t size, IFX_MemoryAllocator* pAllocator) {
43 return pAllocator->Alloc(size); 37 return pAllocator->Alloc(size);
44 } 38 }
45 void operator delete(void* p, IFX_MEMAllocator* pAllocator) { 39 void operator delete(void* p, IFX_MemoryAllocator* pAllocator) {
46 pAllocator->Free(p); 40 pAllocator->Free(p);
47 } 41 }
48 void* operator new(size_t size, void* place) { return place; } 42 void* operator new(size_t size, void* place) { return place; }
49 void operator delete(void* p, void* place) {} 43 void operator delete(void* p, void* place) {}
50 }; 44 };
51 45
52 #define FXTARGET_NewWith(__allocator__) new (__allocator__) 46 #define FXTARGET_NewWith(__allocator__) new (__allocator__)
53 #define FXTARGET_DeleteWith(__class__, __allocator__, pointer) \ 47 #define FXTARGET_DeleteWith(__class__, __allocator__, pointer) \
54 { \ 48 { \
55 (pointer)->~__class__(); \ 49 (pointer)->~__class__(); \
56 (pointer)->operator delete((pointer), (__allocator__)); \ 50 (pointer)->operator delete((pointer), (__allocator__)); \
57 } 51 }
58 52
59 #endif // XFA_FGAS_CRT_FGAS_MEMORY_H_ 53 #endif // XFA_FGAS_CRT_FGAS_MEMORY_H_
OLDNEW
« no previous file with comments | « xfa/fee/fde_txtedtbuf.cpp ('k') | xfa/fgas/crt/fgas_memory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698