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 #ifndef _FX_SYSTEM_H_ | 9 #ifndef _FX_SYSTEM_H_ |
10 #include "fx_system.h" | 10 #include "fx_system.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 { | 110 { |
111 public: | 111 public: |
112 | 112 |
113 virtual ~CFX_DestructObject() {} | 113 virtual ~CFX_DestructObject() {} |
114 }; | 114 }; |
115 #ifdef __cplusplus | 115 #ifdef __cplusplus |
116 extern "C" { | 116 extern "C" { |
117 #endif | 117 #endif |
118 typedef struct _IFX_Allocator { | 118 typedef struct _IFX_Allocator { |
119 | 119 |
120 void*» (*m_AllocDebug)(struct _IFX_Allocator* pAllocator, size_t size,
FX_LPCSTR file, int line); | 120 void*» (*m_AllocDebug)(struct _IFX_Allocator* pAllocator, size_t num, s
ize_t size, FX_LPCSTR file, int line); |
121 | 121 |
122 void*» (*m_Alloc)(struct _IFX_Allocator* pAllocator, size_t size); | 122 void*» (*m_Alloc)(struct _IFX_Allocator* pAllocator, size_t num, size_t
size); |
123 | 123 |
124 void*» (*m_ReallocDebug)(struct _IFX_Allocator* pAllocator, void* p, si
ze_t size, FX_LPCSTR file, int line); | 124 void*» (*m_ReallocDebug)(struct _IFX_Allocator* pAllocator, void* p, si
ze_t num, size_t size, FX_LPCSTR file, int line); |
125 | 125 |
126 void*» (*m_Realloc)(struct _IFX_Allocator* pAllocator, void* p, size_t
size); | 126 void*» (*m_Realloc)(struct _IFX_Allocator* pAllocator, void* p, size_t
num, size_t size); |
127 | 127 |
128 void (*m_Free)(struct _IFX_Allocator* pAllocator, void* p); | 128 void (*m_Free)(struct _IFX_Allocator* pAllocator, void* p); |
129 } IFX_Allocator; | 129 } IFX_Allocator; |
130 IFX_Allocator* FXMEM_GetDefAllocator(); | 130 IFX_Allocator* FXMEM_GetDefAllocator(); |
131 #ifdef __cplusplus | 131 #ifdef __cplusplus |
132 } | 132 } |
133 #endif | 133 #endif |
134 #ifdef _DEBUG | 134 #ifdef _DEBUG |
135 | 135 |
136 #define FX_Allocator_Alloc(fxAllocator, type, size) \ | 136 #define FX_Allocator_Alloc(fxAllocator, type, size) \ |
137 ((fxAllocator) ? (type*)(fxAllocator)->m_AllocDebug((fxAllocator), (size) *
sizeof(type), __FILE__, __LINE__) : (FX_Alloc(type, size))) | 137 ((fxAllocator) ? (type*)(fxAllocator)->m_AllocDebug((fxAllocator), (size), s
izeof(type), __FILE__, __LINE__) : (FX_Alloc(type, size))) |
138 | 138 |
139 #define FX_Allocator_Realloc(fxAllocator, type, ptr, new_size) \ | 139 #define FX_Allocator_Realloc(fxAllocator, type, ptr, new_size) \ |
140 ((fxAllocator) ? (type*)(fxAllocator)->m_ReallocDebug((fxAllocator), (ptr),
(new_size) * sizeof(type), __FILE__, __LINE__) : (FX_Realloc(type, ptr, new_size
))) | 140 ((fxAllocator) ? (type*)(fxAllocator)->m_ReallocDebug((fxAllocator), (ptr),
(new_size) , sizeof(type), __FILE__, __LINE__) : (FX_Realloc(type, ptr, new_size
))) |
141 #else | 141 #else |
142 | 142 |
143 #define FX_Allocator_Alloc(fxAllocator, type, size) \ | 143 #define FX_Allocator_Alloc(fxAllocator, type, size) \ |
144 ((fxAllocator) ? (type*)(fxAllocator)->m_Alloc((fxAllocator), (size) * sizeo
f(type)) : (FX_Alloc(type, size))) | 144 ((fxAllocator) ? (type*)(fxAllocator)->m_Alloc((fxAllocator), (size), sizeof
(type)) : (FX_Alloc(type, size))) |
145 | 145 |
146 #define FX_Allocator_Realloc(fxAllocator, type, ptr, new_size) \ | 146 #define FX_Allocator_Realloc(fxAllocator, type, ptr, new_size) \ |
147 ((fxAllocator) ? (type*)(fxAllocator)->m_Realloc((fxAllocator), (ptr), (new_
size) * sizeof(type)) : (FX_Realloc(type, ptr, new_size))) | 147 ((fxAllocator) ? (type*)(fxAllocator)->m_Realloc((fxAllocator), (ptr), (new_
size), sizeof(type)) : (FX_Realloc(type, ptr, new_size))) |
148 #endif | 148 #endif |
149 #define FX_Allocator_Free(fxAllocator, ptr) \ | 149 #define FX_Allocator_Free(fxAllocator, ptr) \ |
150 ((fxAllocator) ? (fxAllocator)->m_Free((fxAllocator), (ptr)) : (FX_Free(ptr)
)) | 150 ((fxAllocator) ? (fxAllocator)->m_Free((fxAllocator), (ptr)) : (FX_Free(ptr)
)) |
151 inline void* operator new(size_t size, IFX_Allocator* fxAllocator) | 151 inline void* operator new(size_t size, IFX_Allocator* fxAllocator) |
152 { | 152 { |
153 return (void*)FX_Allocator_Alloc(fxAllocator, FX_BYTE, size); | 153 return (void*)FX_Allocator_Alloc(fxAllocator, FX_BYTE, size); |
154 } | 154 } |
155 inline void operator delete(void* ptr, IFX_Allocator* fxAllocator) | 155 inline void operator delete(void* ptr, IFX_Allocator* fxAllocator) |
156 { | 156 { |
157 } | 157 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 size_t nPageSize_Large; | 292 size_t nPageSize_Large; |
293 | 293 |
294 size_t nPageSize_Alone; | 294 size_t nPageSize_Alone; |
295 } FX_MEMCONFIG; | 295 } FX_MEMCONFIG; |
296 void FXMEM_SetConfig(const FX_MEMCONFIG* memConfig); | 296 void FXMEM_SetConfig(const FX_MEMCONFIG* memConfig); |
297 #ifdef __cplusplus | 297 #ifdef __cplusplus |
298 } | 298 } |
299 #endif | 299 #endif |
300 #endif | 300 #endif |
OLD | NEW |