12 #ifndef EASTL_FIXED_ALLOCATOR_H
13 #define EASTL_FIXED_ALLOCATOR_H
16 #include <EASTL/internal/config.h>
17 #include <EASTL/internal/fixed_pool.h>
18 #include <EASTL/functional.h>
19 #include <EASTL/memory.h>
20 #include <EASTL/allocator.h>
21 #include <EASTL/type_traits.h>
23 EA_DISABLE_ALL_VC_WARNINGS();
27 EA_RESTORE_ALL_VC_WARNINGS();
29 EA_DISABLE_VC_WARNING(4275);
31 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
139 Link* pLink = mpHead;
143 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
144 if(++mnCurrentSize > mnPeakSize)
145 mnPeakSize = mnCurrentSize;
148 mpHead = pLink->mpNext;
156 if(mpNext != mpCapacity)
160 mpNext =
reinterpret_cast<Link*
>(
reinterpret_cast<char*
>(mpNext) + n);
162 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
163 if(++mnCurrentSize > mnPeakSize)
164 mnPeakSize = mnCurrentSize;
178 void*
allocate(
size_t n,
size_t ,
size_t ,
int flags = 0)
180 return allocate(n, flags);
192 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
196 ((
Link*)p)->mpNext = mpHead;
204 const char* get_name()
const
206 return EASTL_FIXED_POOL_DEFAULT_NAME;
210 void set_name(
const char*)
217 bool operator==(
const fixed_allocator& a,
const fixed_allocator& b);
218 bool operator!=(
const fixed_allocator& a,
const fixed_allocator& b);
271 , mOverflowAllocator(pName)
272 , mpPoolBegin(nullptr)
288 , mpPoolBegin(nullptr)
303 #if EASTL_ALLOCATOR_COPY_ENABLED
304 mOverflowAllocator = x.mOverflowAllocator;
315 void init(
void* pMemory,
size_t memorySize,
size_t nodeSize,
316 size_t alignment,
size_t alignmentOffset = 0)
320 mpPoolBegin = pMemory;
321 mpPoolEnd = (
void*)((uintptr_t)pMemory + memorySize);
322 mnNodeSize = (eastl_size_t)nodeSize;
340 mpHead = mpHead->mpNext;
347 if (mpNext != mpCapacity)
350 mpNext =
reinterpret_cast<Link*
>(
reinterpret_cast<char*
>(mpNext) + mnNodeSize);
353 p = mOverflowAllocator.allocate(mnNodeSize);
356 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
357 if(p && (++mnCurrentSize > mnPeakSize))
358 mnPeakSize = mnCurrentSize;
367 void*
allocate(
size_t n,
size_t ,
size_t ,
int flags = 0)
369 return allocate(n, flags);
381 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
385 if((p >= mpPoolBegin) && (p < mpPoolEnd))
387 ((
Link*)p)->mpNext = mpHead;
391 mOverflowAllocator.deallocate(p, (
size_t)mnNodeSize);
398 const char* get_name()
const
400 return mOverflowAllocator.get_name();
404 void set_name(
const char* pName)
406 mOverflowAllocator.set_name(pName);
410 EASTLAllocatorType mOverflowAllocator;
413 eastl_size_t mnNodeSize;
417 bool operator==(
const fixed_allocator_with_overflow& a,
const fixed_allocator_with_overflow& b);
418 bool operator!=(
const fixed_allocator_with_overflow& a,
const fixed_allocator_with_overflow& b);
429 inline bool operator==(
const fixed_allocator&,
const fixed_allocator&)
434 inline bool operator!=(
const fixed_allocator&,
const fixed_allocator&)
439 inline bool operator==(
const fixed_allocator_with_overflow&,
const fixed_allocator_with_overflow&)
444 inline bool operator!=(
const fixed_allocator_with_overflow&,
const fixed_allocator_with_overflow&)
453 EA_RESTORE_VC_WARNING();
Definition: fixed_allocator.h:262
void deallocate(void *p, size_t)
Definition: fixed_allocator.h:379
fixed_allocator_with_overflow(const fixed_allocator_with_overflow &)
Definition: fixed_allocator.h:286
void * allocate(size_t, int=0)
Definition: fixed_allocator.h:331
fixed_allocator_with_overflow & operator=(const fixed_allocator_with_overflow &x)
Definition: fixed_allocator.h:301
void * allocate(size_t n, size_t, size_t, int flags=0)
Definition: fixed_allocator.h:367
void init(void *pMemory, size_t memorySize, size_t nodeSize, size_t alignment, size_t alignmentOffset=0)
Definition: fixed_allocator.h:315
fixed_allocator_with_overflow(const char *pName=EASTL_FIXED_POOL_DEFAULT_NAME)
Definition: fixed_allocator.h:269
Definition: fixed_allocator.h:84
fixed_allocator & operator=(const fixed_allocator &)
Definition: fixed_allocator.h:116
void * allocate(size_t n, size_t, size_t, int flags=0)
Definition: fixed_allocator.h:178
void deallocate(void *p, size_t)
Definition: fixed_allocator.h:190
fixed_allocator(const char *=EASTL_FIXED_POOL_DEFAULT_NAME)
Definition: fixed_allocator.h:91
fixed_allocator(const fixed_allocator &)
Definition: fixed_allocator.h:104
void * allocate(size_t n, int=0)
Definition: fixed_allocator.h:135
EA Standard Template Library.
Definition: algorithm.h:288
Definition: fixed_pool.h:209
Definition: fixed_pool.h:134
bool can_allocate() const
Definition: fixed_pool.h:200
EASTL_API void init(void *pMemory, size_t memorySize, size_t nodeSize, size_t alignment, size_t alignmentOffset=0)
Definition: fixed_pool.cpp:15