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 _FX_MEMORY_H_ | 7 #ifndef _FX_MEMORY_H_ |
8 #define _FX_MEMORY_H_ | 8 #define _FX_MEMORY_H_ |
9 | 9 |
10 #include "fx_system.h" | 10 #include "fx_system.h" |
11 | 11 |
12 #ifdef __cplusplus | 12 #ifdef __cplusplus |
13 #include <new> | 13 #include <new> |
14 extern "C" { | 14 extern "C" { |
15 #endif | 15 #endif |
16 #define FX_Alloc(type, size) (type*)c
alloc(size, sizeof(type)) | 16 #define FX_Alloc(type, size) (type*)c
alloc(size, sizeof(type)) |
17 #define FX_Realloc(type, ptr, size) (type*)r
ealloc(ptr, sizeof(type) * (size)) | 17 #define FX_Realloc(type, ptr, size) (type*)r
ealloc(ptr, sizeof(type) * (size)) |
18 #define FX_AllocNL(type, size) FX_Alloc
(type, size) | 18 #define FX_AllocNL(type, size) FX_Alloc
(type, size) |
19 #define FX_ReallocNL(type, ptr, size) FX_Realloc(type,
ptr, size) | 19 #define FX_ReallocNL(type, ptr, size) FX_Realloc(type,
ptr, size) |
20 #define FX_Free(ptr)
free(ptr) | 20 #define FX_Free(ptr)
free(ptr) |
21 void* FXMEM_DefaultAlloc(size_t byte_size, int flags); | 21 void* FXMEM_DefaultAlloc(size_t byte_size, int flags); |
22 void* FXMEM_DefaultRealloc(void* pointer, size_t new_size, int flags); | 22 void* FXMEM_DefaultRealloc(void* pointer, size_t new_size, int flags); |
23 void FXMEM_DefaultFree(void* pointer, int flags); | 23 void FXMEM_DefaultFree(void* pointer, int flags); |
24 #ifdef __cplusplus | 24 #ifdef __cplusplus |
25 } | 25 } |
26 | 26 |
27 #define FX_NEW new(std::nothrow) | 27 #define FX_NEW new |
28 #define FX_NEW_VECTOR(Pointer, Class, Count) (Pointer = FX_NEW Class[Count]) | 28 #define FX_NEW_VECTOR(Pointer, Class, Count) (Pointer = FX_NEW Class[Count]) |
29 #define FX_DELETE_VECTOR(Pointer, Class, Count) delete[] Pointer | 29 #define FX_DELETE_VECTOR(Pointer, Class, Count) delete[] Pointer |
30 | 30 |
31 class CFX_DestructObject | 31 class CFX_DestructObject |
32 { | 32 { |
33 public: | 33 public: |
34 | 34 |
35 virtual ~CFX_DestructObject() {} | 35 virtual ~CFX_DestructObject() {} |
36 }; | 36 }; |
37 class CFX_GrowOnlyPool | 37 class CFX_GrowOnlyPool |
(...skipping 30 matching lines...) Expand all Loading... |
68 | 68 |
69 void FreeAll(); | 69 void FreeAll(); |
70 private: | 70 private: |
71 | 71 |
72 size_t m_TrunkSize; | 72 size_t m_TrunkSize; |
73 | 73 |
74 void* m_pFirstTrunk; | 74 void* m_pFirstTrunk; |
75 }; | 75 }; |
76 #endif | 76 #endif |
77 #endif | 77 #endif |
OLD | NEW |