37 #ifndef EASTL_ALLOCATOR_H 38 #define EASTL_ALLOCATOR_H 41 #include <stk_util/util/config_eastl.h> 47 #pragma warning(disable: 4189) // local variable is initialized but not referenced 58 #ifndef EASTL_ALLOCATOR_DEFAULT_NAME 59 #define EASTL_ALLOCATOR_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX // Unless the user overrides something, this is "EASTL". 84 EASTL_ALLOCATOR_EXPLICIT
allocator(
const char* pName = EASTL_NAME_VAL(EASTL_ALLOCATOR_DEFAULT_NAME));
90 void* allocate(
size_t n,
int flags = 0);
91 void* allocate(
size_t n,
size_t alignment,
size_t offset,
int flags = 0);
92 void deallocate(
void* p,
size_t n);
94 const char* get_name()
const;
95 void set_name(
const char* pName);
98 #if EASTL_NAME_ENABLED 106 EASTL_API
allocator* GetDefaultAllocator();
128 template <
typename Allocator>
136 return EASTLAllocatorDefault();
147 EASTLAllocatorType*
const pAllocator = EASTLAllocatorDefault();
151 EASTLFree(*pAllocator, pBuffer, n);
155 return EASTLAlloc(*pAllocator, n);
166 template <
typename Allocator>
167 void*
allocate_memory(Allocator& a,
size_t n,
size_t alignment,
size_t alignmentOffset)
170 return EASTLAlloc(a, n);
171 return EASTLAllocAligned(a, n, alignment, alignmentOffset);
180 #ifndef EASTL_USER_DEFINED_ALLOCATOR // If the user hasn't declared that he has defined a different allocator implementation elsewhere... 183 #pragma warning(push, 0) 190 #if !EASTL_DLL // If building a regular library and not building EASTL as a DLL... 194 void*
operator new[](
size_t size,
const char* pName,
int flags,
unsigned debugFlags,
const char* file,
int line);
195 void*
operator new[](
size_t size,
size_t alignment,
size_t alignmentOffset,
const char* pName,
int flags,
unsigned debugFlags,
const char* file,
int line);
200 inline allocator::allocator(
const char* EASTL_NAME(pName))
202 #if EASTL_NAME_ENABLED 203 mpName = pName ? pName : EASTL_ALLOCATOR_DEFAULT_NAME;
208 inline allocator::allocator(
const allocator& EASTL_NAME(alloc))
210 #if EASTL_NAME_ENABLED 211 mpName = alloc.mpName;
216 inline allocator::allocator(
const allocator&,
const char* EASTL_NAME(pName))
218 #if EASTL_NAME_ENABLED 219 mpName = pName ? pName : EASTL_ALLOCATOR_DEFAULT_NAME;
224 inline allocator& allocator::operator=(
const allocator& EASTL_NAME(alloc))
226 #if EASTL_NAME_ENABLED 227 mpName = alloc.mpName;
233 inline const char* allocator::get_name()
const 235 #if EASTL_NAME_ENABLED 238 return EASTL_ALLOCATOR_DEFAULT_NAME;
243 inline void allocator::set_name(
const char* EASTL_NAME(pName))
245 #if EASTL_NAME_ENABLED 251 inline void* allocator::allocate(
size_t n,
int flags)
253 #if EASTL_NAME_ENABLED 256 #define pName EASTL_ALLOCATOR_DEFAULT_NAME 264 return ::new
char[n];
265 #elif (EASTL_DEBUGPARAMS_LEVEL <= 0) 266 return ::new((
char*)0, flags, 0, (
char*)0, 0) char[n];
267 #elif (EASTL_DEBUGPARAMS_LEVEL == 1) 268 return ::new( pName, flags, 0, (
char*)0, 0) char[n];
270 return ::new( pName, flags, 0, __FILE__, __LINE__)
char[n];
275 inline void* allocator::allocate(
size_t n,
size_t alignment,
size_t offset,
int flags)
282 EASTL_ASSERT(alignment <= 8);
283 (void)alignment; (void)offset; (void)flags;
285 #elif (EASTL_DEBUGPARAMS_LEVEL <= 0) 286 return ::new(alignment, offset, (
char*)0, flags, 0, (
char*)0, 0) char[n];
287 #elif (EASTL_DEBUGPARAMS_LEVEL == 1) 288 return ::new(alignment, offset, pName, flags, 0, (
char*)0, 0) char[n];
290 return ::new(alignment, offset, pName, flags, 0, __FILE__, __LINE__)
char[n];
293 #undef pName // See above for the definition of this. 297 inline void allocator::deallocate(
void* p,
size_t)
303 inline bool operator==(
const allocator&,
const allocator&)
309 inline bool operator!=(
const allocator&,
const allocator&)
318 #endif // EASTL_USER_DEFINED_ALLOCATOR 326 #endif // Header include guard
void * default_allocfreemethod(size_t n, void *pBuffer, void *)
Allocator * get_default_allocator(const Allocator *)
void * allocate_memory(Allocator &a, size_t n, size_t alignment, size_t alignmentOffset)
EA Standard Template Library.