The memory management provides an interface for allocators including a default implementation.
More...
The memory management provides an interface for allocators including a default implementation.
You can request dynamic memory from an allocator implementation through an mi::base::IAllocator interface. A default implementation based on global new and delete operators is mi::base::Default_allocator.
You can adapt an allocator to become a standard STL allocator using mi::base::Std_allocator.
◆ const_pointer
◆ const_reference
◆ difference_type
◆ other
template<class T>
template<class T1>
Rebind type, defines a new class instance of this allocator template instantiated for the new value type T1
.
◆ pointer
◆ reference
◆ size_type
◆ value_type
Value type allocated by this allocator.
◆ address() [1/2]
Returns const address of object x
allocated through this allocator.
◆ address() [2/2]
Returns address of object x
allocated through this allocator.
◆ allocate()
Allocate uninitialized dynamic memory for n
elements of type T
.
- Returns
- The pointer to the allocated memory. Can be
NULL
if the underlying IAllocator implementation fails to allocate the memory.
◆ construct()
Calls the copy constructor of T
on the location p
with the argument value
.
◆ deallocate()
Frees uninitialized dynamic memory at location p
that has previously been allocated with allocate
().
- Parameters
-
p | the memory to be freed. If p is equal to NULL , no operation is performed. However, note that according to |
◆ destroy()
Calls the destructor of T
on the location p
.
◆ free() [1/2]
virtual void mi::base::Default_allocator::free |
( |
void * |
memory | ) |
|
|
inlinevirtual |
◆ free() [2/2]
virtual void mi::base::IAllocator::free |
( |
void * |
memory | ) |
|
|
pure virtual |
Releases the given memory block.
This function can be called at any time from any thread, including concurrent calls from several threads at the same time.
- Parameters
-
memory | A memory block previously allocated by a call to malloc(). If memory is NULL , no operation is performed. |
Implemented in mi::base::Default_allocator.
◆ get_allocator()
Returns the interface of the underlying allocator.
◆ get_instance()
static IAllocator * mi::base::Default_allocator::get_instance |
( |
| ) |
|
|
inlinestatic |
Returns the single instance of the default allocator.
◆ malloc() [1/2]
virtual void * mi::base::Default_allocator::malloc |
( |
Size |
size | ) |
|
|
inlinevirtual |
Allocates a memory block of the given size.
Implements mi::base::IAllocator::malloc through a global non-throwing operator
new
call.
- Parameters
-
size | The requested size of memory in bytes. It may be zero. |
- Returns
- The allocated memory block.
Implements mi::base::IAllocator.
◆ malloc() [2/2]
virtual void * mi::base::IAllocator::malloc |
( |
Size |
size | ) |
|
|
pure virtual |
Allocates a memory block of the given size.
The memory must be aligned to an address which can accommodate any type of object on the current platform.
An allocation of zero bytes returns a valid non-null pointer which must be freed in the end. However, dereferencing this pointer gives undefined behavior.
This function can be called at any time from any thread, including concurrent calls from several threads at the same time.
If the requested memory is not available this function returns NULL
. Some products give the stronger guarantee that allocation can never fail. (They can do this, for example, by flushing parts or in its extreme, stop executing.) See the API documentation of the specific products for specific allocator interfaces or allocator documentation.
- Parameters
-
size | The requested size of memory in bytes. It may be zero. |
- Returns
- The allocated memory block.
Implemented in mi::base::Default_allocator.
◆ max_size()
Returns the maximum number of elements of type T
that can be allocated using this allocator.
◆ operator!=()
template<class T>
template<class T2>
Inequality comparison.
Returns false
if the underlying IAllocator interface implementations are the same.
◆ operator==()
template<class T>
template<class T2>
Equality comparison.
Returns true
if the underlying IAllocator interface implementations are the same, because then these allocators can be used interchangeably for allocation and deallocation.
◆ Std_allocator() [1/3]
◆ Std_allocator() [2/3]
◆ Std_allocator() [3/3]
template<class T>
template<class T1>
Copying constructor template for alike allocators of different value type.