9 #include <config/MemoryAllocation.hpp> 10 #include <type_traits> 19 return this->
allocate(identifier, size, unused, alignment);
27 void* memory = this->
allocate(identifier, size, recoverable, alignment);
28 FW_ASSERT(memory !=
nullptr && size >= requestedSize, static_cast<FwAssertArgType>(identifier),
29 static_cast<FwAssertArgType>(requestedSize), static_cast<FwAssertArgType>(size));
38 MemAllocatorRegistry::MemAllocatorRegistry() : m_defaultAllocator(
MemAllocatorRegistry::getDefaultAllocator()) {
44 this->m_allocators[type] = &allocator;
53 FW_ASSERT(this->m_allocators[type] !=
nullptr, static_cast<FwAssertArgType>(type));
54 return *this->m_allocators[type];
59 if (this->m_allocators[type] ==
nullptr) {
62 return *this->m_allocators[type];
65 MemAllocator& MemAllocatorRegistry::getDefaultAllocator() {
66 static_assert(std::is_constructible<MemoryAllocation::DefaultMemoryAllocatorType>::value,
67 "DefaultMemoryAllocatorType must be constructible without arguments");
69 return defaultAllocator;
virtual void * allocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable, FwSizeType alignment=alignof(std::max_align_t))=0
PlatformSizeType FwSizeType
REQUIRED: required for allocation for memory using a standard system allocator (i.e. the default)
static MemAllocatorRegistry & getInstance()
get the singleton registry
MemAllocator & getAnAllocator(const MemoryAllocation::MemoryAllocatorType type)
void * checkedAllocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable, FwSizeType alignment=alignof(std::max_align_t))
malloc based memory allocator
Memory Allocation base class.
MemAllocator & getAllocator(const MemoryAllocation::MemoryAllocatorType type)
Defines a base class for a memory allocator for classes.
Implementation of malloc based allocator.
void registerAllocator(const MemoryAllocation::MemoryAllocatorType type, MemAllocator &allocator)
register an allocator for the given type