43 #ifndef EASTL_FIXED_ALLOCATOR_H 44 #define EASTL_FIXED_ALLOCATOR_H 47 #include <stk_util/util/config_eastl.h> 48 #include <stk_util/util/fixed_pool_eastl.h> 49 #include <stk_util/util/functional_eastl.h> 50 #include <stk_util/util/memory_eastl.h> 51 #include <stk_util/util/allocator_eastl.h> 52 #include <stk_util/util/type_traits_eastl.h> 55 #pragma warning(push, 0) 165 Link* pLink = mpHead;
169 #if EASTL_FIXED_SIZE_TRACKING_ENABLED 170 if(++mnCurrentSize > mnPeakSize)
171 mnPeakSize = mnCurrentSize;
174 mpHead = pLink->mpNext;
182 if(mpNext != mpCapacity)
186 mpNext =
reinterpret_cast<Link*
>(
reinterpret_cast<char8_t*
>(mpNext) + mnNodeSize);
188 #if EASTL_FIXED_SIZE_TRACKING_ENABLED 189 if(++mnCurrentSize > mnPeakSize)
190 mnPeakSize = mnCurrentSize;
204 void*
allocate(
size_t n,
size_t ,
size_t ,
int flags = 0)
206 return allocate(n, flags);
218 #if EASTL_FIXED_SIZE_TRACKING_ENABLED 222 ((
Link*)p)->mpNext = mpHead;
230 const char* get_name()
const 232 return EASTL_FIXED_POOL_DEFAULT_NAME;
236 void set_name(
const char*)
243 bool operator==(
const fixed_allocator& a,
const fixed_allocator& b);
244 bool operator!=(
const fixed_allocator& a,
const fixed_allocator& b);
297 mOverflowAllocator(pName)
323 #if EASTL_ALLOCATOR_COPY_ENABLED 324 mOverflowAllocator = x.mOverflowAllocator;
335 void init(
void* pMemory,
size_t memorySize,
size_t nodeSize,
336 size_t alignment,
size_t alignmentOffset = 0)
340 mpPoolBegin = pMemory;
341 mpPoolEnd = (
void*)((uintptr_t)pMemory + memorySize);
342 mnNodeSize = (eastl_size_t)nodeSize;
360 mpHead = mpHead->mpNext;
363 p = mOverflowAllocator.allocate(mnNodeSize);
365 #if EASTL_FIXED_SIZE_TRACKING_ENABLED 366 if(p && (++mnCurrentSize > mnPeakSize))
367 mnPeakSize = mnCurrentSize;
376 void*
allocate(
size_t n,
size_t ,
size_t ,
int flags = 0)
378 return allocate(n, flags);
390 #if EASTL_FIXED_SIZE_TRACKING_ENABLED 394 if((p >= mpPoolBegin) && (p < mpPoolEnd))
396 ((
Link*)p)->mpNext = mpHead;
400 mOverflowAllocator.deallocate(p, (
size_t)mnNodeSize);
407 const char* get_name()
const 409 return mOverflowAllocator.get_name();
413 void set_name(
const char* pName)
415 mOverflowAllocator.set_name(pName);
419 EASTLAllocatorType mOverflowAllocator;
422 eastl_size_t mnNodeSize;
426 bool operator==(
const fixed_allocator_with_overflow& a,
const fixed_allocator_with_overflow& b);
427 bool operator!=(
const fixed_allocator_with_overflow& a,
const fixed_allocator_with_overflow& b);
438 inline bool operator==(
const fixed_allocator&,
const fixed_allocator&)
443 inline bool operator!=(
const fixed_allocator&,
const fixed_allocator&)
448 inline bool operator==(
const fixed_allocator_with_overflow&,
const fixed_allocator_with_overflow&)
453 inline bool operator!=(
const fixed_allocator_with_overflow&,
const fixed_allocator_with_overflow&)
464 #endif // Header include guard void deallocate(void *p, size_t)
void deallocate(void *p, size_t)
fixed_allocator_with_overflow(const char *pName=EASTL_FIXED_POOL_DEFAULT_NAME)
bool can_allocate() const
fixed_allocator(const char *=EASTL_FIXED_POOL_DEFAULT_NAME)
void * allocate(size_t n, size_t, size_t, int flags=0)
void * allocate(size_t, int=0)
fixed_allocator_with_overflow & operator=(const fixed_allocator_with_overflow &x)
fixed_allocator(const fixed_allocator &)
fixed_allocator & operator=(const fixed_allocator &)
void * allocate(size_t n, size_t, size_t, int flags=0)
fixed_allocator_with_overflow(const fixed_allocator_with_overflow &)
void init(void *pMemory, size_t memorySize, size_t nodeSize, size_t alignment, size_t alignmentOffset=0)
EA Standard Template Library.
void init(void *pMemory, size_t memorySize, size_t nodeSize, size_t alignment, size_t alignmentOffset=0)
void * allocate(size_t, int=0)