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::
Constructors, destructors, conversion operators
-
CoreAllocatorAdapter(const char* pName = EASTL_
NAME_ VAL(EASTL_ ALLOCATOR_ DEFAULT_ NAME), AllocatorType* pAllocator = EASTL_ CORE_ ALLOCATOR_ ADAPTER_ GET_ DEFAULT_ CORE_ ALLOCATOR()) - 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* -
auto deallocate(void* p,
size_
t n) -> void - auto get_allocator() const -> AllocatorType*
- auto set_allocator(AllocatorType* pAllocator) -> void
- auto get_flags() const -> int
- auto set_flags(int flags) -> void
- auto get_name() const -> const char*
- auto set_name(const char* pName) -> void