Material Definition Language API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mi::base::IAllocator Class Referenceabstract

The IAllocator interface class supports allocating and releasing memory dynamically. More...

Inheritance diagram for mi::base::IAllocator:
mi::base::Interface_declare< 0xa1836db8, 0x6f63, 0x4079, 0x82, 0x82, 0xb3, 0x5d, 0x17, 0x36, 0x96, 0xef > mi::base::IInterface mi::base::Interface_declare< 0x952af060, 0xe2a6, 0x4bd7, 0xa2, 0x52, 0x9f, 0x6d, 0x39, 0xfb, 0x50, 0xa3, base::IAllocator > mi::base::Interface_implement_singleton< IAllocator > mi::neuraylib::IAllocator mi::base::Default_allocator

Public Member Functions

virtual void * malloc (Size size)=0
 Allocates a memory block of the given size. More...
 
virtual void free (void *memory)=0
 Releases the given memory block. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0xa1836db8, 0x6f63, 0x4079, 0x82, 0x82, 0xb3, 0x5d, 0x17, 0x36, 0x96, 0xef >
typedef Interface_declare< id1,
id2, id3, id4, id5, id6, id7,
id8, id9, id10, id11,
IInterface
Self
 Own type. More...
 
typedef Uuid_t< id1, id2, id3,
id4, id5, id6, id7, id8, id9,
id10, id11 > 
IID
 Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0xa1836db8, 0x6f63, 0x4079, 0x82, 0x82, 0xb3, 0x5d, 0x17, 0x36, 0x96, 0xef >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 

Detailed 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>

Member Function Documentation

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
memoryA memory block previously allocated by a call to malloc(). If memory is NULL, no operation is performed.

Implemented in mi::neuraylib::IAllocator, and mi::base::Default_allocator.

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
sizeThe requested size of memory in bytes. It may be zero.
Returns
The allocated memory block.

Implemented in mi::neuraylib::IAllocator, and mi::base::Default_allocator.