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

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

Issue 2208423002: Use smart pointers for class owned pointers under xfa/fde (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: one more change Created 4 years, 4 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/fde/tto/fde_textout.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 <memory>
11
10 #include "core/fxcrt/include/fx_memory.h" 12 #include "core/fxcrt/include/fx_memory.h"
11 #include "core/fxcrt/include/fx_system.h" 13 #include "core/fxcrt/include/fx_system.h"
12 14
13 enum FX_ALLOCTYPE { 15 enum FX_ALLOCTYPE {
14 FX_ALLOCTYPE_Static, 16 FX_ALLOCTYPE_Static,
15 FX_ALLOCTYPE_Fixed, 17 FX_ALLOCTYPE_Fixed,
16 }; 18 };
17 19
18 class IFX_MemoryAllocator { 20 class IFX_MemoryAllocator {
19 public: 21 public:
20 virtual ~IFX_MemoryAllocator() {} 22 virtual ~IFX_MemoryAllocator() {}
21 virtual void* Alloc(size_t size) = 0; 23 virtual void* Alloc(size_t size) = 0;
22 virtual void Free(void* pBlock) = 0; 24 virtual void Free(void* pBlock) = 0;
23 25
24 static IFX_MemoryAllocator* Create(FX_ALLOCTYPE eType, 26 static std::unique_ptr<IFX_MemoryAllocator> Create(FX_ALLOCTYPE eType,
25 size_t chunkSize, 27 size_t chunkSize,
26 size_t blockSize); 28 size_t blockSize);
27 }; 29 };
28 30
29 class CFX_Target { 31 class CFX_Target {
30 public: 32 public:
31 virtual ~CFX_Target() {} 33 virtual ~CFX_Target() {}
32 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); }
33 void operator delete(void* p) { FX_Free(p); } 35 void operator delete(void* p) { FX_Free(p); }
34 void* operator new(size_t size, IFX_MemoryAllocator* pAllocator) { 36 void* operator new(size_t size, IFX_MemoryAllocator* pAllocator) {
35 return pAllocator->Alloc(size); 37 return pAllocator->Alloc(size);
36 } 38 }
37 void operator delete(void* p, IFX_MemoryAllocator* pAllocator) { 39 void operator delete(void* p, IFX_MemoryAllocator* pAllocator) {
38 pAllocator->Free(p); 40 pAllocator->Free(p);
39 } 41 }
40 void* operator new(size_t size, void* place) { return place; } 42 void* operator new(size_t size, void* place) { return place; }
41 void operator delete(void* p, void* place) {} 43 void operator delete(void* p, void* place) {}
42 }; 44 };
43 45
44 #define FXTARGET_NewWith(__allocator__) new (__allocator__) 46 #define FXTARGET_NewWith(__allocator__) new (__allocator__)
45 #define FXTARGET_DeleteWith(__class__, __allocator__, pointer) \ 47 #define FXTARGET_DeleteWith(__class__, __allocator__, pointer) \
46 { \ 48 { \
47 (pointer)->~__class__(); \ 49 (pointer)->~__class__(); \
48 (pointer)->operator delete((pointer), (__allocator__)); \ 50 (pointer)->operator delete((pointer), (__allocator__)); \
49 } 51 }
50 52
51 #endif // XFA_FGAS_CRT_FGAS_MEMORY_H_ 53 #endif // XFA_FGAS_CRT_FGAS_MEMORY_H_
OLDNEW
« no previous file with comments | « xfa/fde/tto/fde_textout.cpp ('k') | xfa/fgas/crt/fgas_memory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698