template<class AllocatorType>
CoreAllocatorAdapter class


Implements the EASTL allocator interface. Allocates memory from an instance of ICoreAllocator or another class with an equivalent interface. ICoreAllocator is a pure-virtual memory allocation interface used by a number of EA games and shared libraries. It's completely unrelated to EASTL, but it's prevalent enough that it's useful for EASTL to have a built-in adapter for this interface. ICoreAllocator is declared in the ICoreAllocator.h header, but CoreAllocatorAdapter can work with any equivalent interface, as defined below.

Expected interface: enum AllocFlags { kFlagTempMemory = 0, kFlagPermMemory = 1 };

struct CoreAllocator { void* Alloc(size_t size, const char* name, unsigned int allocFlags); void* Alloc(size_t size, const char* name, unsigned int allocFlags, // Not required unless you are working with types that require custom alignment. unsigned int align, unsigned int alignOffset = 0); void Free(void* block, size_t size = 0); static CoreAllocator* GetDefaultAllocator(); };

Example usage: #include <coreallocator/icoreallocator_interface.h> typedef EA::Allocator::CoreAllocatorAdapter<EASTLTestCoreAllocator> Adapter; eastl::list<Widget, Adapter> widgetList(Adapter("UI/WidgetList", pSomeCoreAllocator)); widgetList.push_back(Widget());

Example usage: #include <MyEquivalentCoreAllocatorInterface.h> eastl::list<Widget, CoreAllocatorAdapter<MyCoreAllocatorInterface> > widgetList; widgetList.push_back(Widget());

Example usage: #include <coreallocator/icoreallocator_interface.h> typedef EA::Allocator::CoreAllocatorAdapter<EASTLTestCoreAllocator> Adapter; typedef eastl::list<Widget, Adapter> WidgetList; CoreAllocatorFixed<WidgetList::node_type> widgetCoreAllocator(pFixedAllocatorForWidgetListValueType); // CoreAllocatorFixed is a hypothetical implementation of the ICoreAllocator interface. WidgetList widgetList(Adapter("UI/WidgetList", &widgetCoreAllocator)); // Note that the widgetCoreAllocator is declared before and thus destroyed after the widget list.

Public types

using this_type = CoreAllocatorAdapter<AllocatorType>

Constructors, destructors, conversion operators

CoreAllocatorAdapter(const char* pName, AllocatorType* pAllocator, int flags)
CoreAllocatorAdapter(const CoreAllocatorAdapter& x)
CoreAllocatorAdapter(const CoreAllocatorAdapter& x, const char* pName)

Public functions

auto operator=(const CoreAllocatorAdapter& x) -> CoreAllocatorAdapter&
auto allocate(size_t n, int flags = 0) -> void*
auto allocate(size_t n, size_t alignment, size_t offset, int flags = 0) -> void*
void deallocate(void* p, size_t n)
auto get_allocator() const -> AllocatorType*
void set_allocator(AllocatorType* pAllocator)
auto get_flags() const -> int
void set_flags(int flags)
auto get_name() const -> const char*
void set_name(const char* pName)

Public variables

AllocatorType* mpCoreAllocator
int mnFlags