mi::base::IAllocator Class Reference
[Memory Management]
Description
The IAllocator interface class supports allocating and releasing memory dynamically. Different APIs allow to be configured with your own implementation of an allocator to override their internal implementation.
Include File:
#include <mi/base/iallocator.h>
Public Member Functions
- virtual void free( void* memory) =0
- Releases the given memory block. More...
- virtual void* malloc( Size size) =0
- Allocates a memory block of the given size. More...
Member Functions
- 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.
- 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.