CustomAllocatorInterface Class Reference

#include <customallocator.h>

详细描述

Custom allocator/memory pool interface.

公共成员函数

  MAXON_ADD_TO_REFERENCE_CLASS ( Int ComputeArraySize( Int currentSize, Int increment, Int minChunkSize) { return DefaultAllocator::ComputeArraySize (currentSize, increment, minChunkSize);})
MAXON_METHOD void *  Alloc ( Int s, MAXON_SOURCE_LOCATION_DECLARATION )
MAXON_METHOD void *  AllocClear ( Int s, MAXON_SOURCE_LOCATION_DECLARATION )
MAXON_METHOD void *  Realloc (void *data, Int size, MAXON_SOURCE_LOCATION_DECLARATION )
  MAXON_ADD_TO_REFERENCE_CLASS (template< typename T > void Free(T *&p) { if(this->GetPointer()) this->GetPointer() -> PrivateFree ((void *) p);p=nullptr;})
  MAXON_ADD_TO_REFERENCE_CLASS ( Bool IsCompatibleWithDefaultAllocator(void *) const { return false;})
MAXON_METHOD void *  PrivateAlloc ( Int size, Bool clear, MAXON_SOURCE_LOCATION_DECLARATION )
MAXON_METHOD void  PrivateFree (void *data)
MAXON_METHOD Int   PrivateGetDataSize (void *data)

静态公共成员函数

static MAXON_METHOD CustomAllocatorInterface Alloc ( MAXON_SOURCE_LOCATION_DECLARATION )

私有成员函数

  MAXON_INTERFACE_NONVIRTUAL ( CustomAllocatorInterface , MAXON_REFERENCE_NORMAL , "net.maxon.interface.customallocator")

成员函数文档编制

◆  MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( CustomAllocatorInterface   ,
MAXON_REFERENCE_NORMAL   ,
"net.maxon.interface.customallocator"   
)
private

◆  Alloc() [1/2]

static MAXON_METHOD CustomAllocatorInterface * Alloc ( MAXON_SOURCE_LOCATION_DECLARATION   )
static
参数
[in] allocLocation Source location.

◆  MAXON_ADD_TO_REFERENCE_CLASS() [1/3]

MAXON_ADD_TO_REFERENCE_CLASS ( Int ComputeArraySize( Int currentSize, Int increment, Int minChunkSize) { return DefaultAllocator::ComputeArraySize (currentSize, increment, minChunkSize);}  )

Computes the new capacity for a growing array. THREADSAFE.

参数
[in] currentSize Current number of elements.
[in] increment Number of elements to be added (>= 1)
[in] minChunkSize The minimum number of elements upon array creation.
返回
New capacity (maximum number of elements).

◆  Alloc() [2/2]

MAXON_METHOD void* Alloc ( Int   s ,
MAXON_SOURCE_LOCATION_DECLARATION    
)

Allocates a memory block. THREADSAFE. The memory is not cleared, it may contain a certain byte pattern in debug mode.

参数
[in] s Block size in bytes (values < 0 will return nullptr)
[in] allocLocation Pass MAXON_SOURCE_LOCATION(_NAME) to add the current source line and file.
返回
Memory block address or nullptr.

◆  AllocClear()

MAXON_METHOD void* AllocClear ( Int   s ,
MAXON_SOURCE_LOCATION_DECLARATION    
)

Allocates a memory block and clears it. THREADSAFE.

参数
[in] s Block size in bytes (values < 0 will return nullptr)
[in] allocLocation Pass MAXON_SOURCE_LOCATION(_NAME) to add the current source line and file.
返回
Memory block address or nullptr.

◆  Realloc()

MAXON_METHOD void* Realloc ( void *  data ,
Int   size ,
MAXON_SOURCE_LOCATION_DECLARATION    
)

Resizes an allocated memory block. If allocation of a new block fails the old one won't be freed.

参数
[in] data 数据 location, can be nullptr.
[in] size Minimum new data size (values < 0 will return nullptr).
[in] allocLocation Structure with caller data like source file and source line.
返回
数据 pointer or nullptr.

◆  MAXON_ADD_TO_REFERENCE_CLASS() [2/3]

MAXON_ADD_TO_REFERENCE_CLASS ( template< typename T > void Free(T *&p) { if(this->GetPointer()) this->GetPointer() -> PrivateFree ((void *) p);p=nullptr;}  )

◆  MAXON_ADD_TO_REFERENCE_CLASS() [3/3]

MAXON_ADD_TO_REFERENCE_CLASS ( Bool IsCompatibleWithDefaultAllocator(void *) const { return false;}  )

Returns if a memory block allocated via this allocator can be reallocated or freed by the DefaultAllocator .

返回
True if the memory block can be reallocated or freed by the DefaultAllocator .

◆  PrivateAlloc()

MAXON_METHOD void* PrivateAlloc ( Int   size ,
Bool   clear ,
MAXON_SOURCE_LOCATION_DECLARATION    
)

Allocates a block of memory.

参数
[in] size Minimum data size (values < 0 will return nullptr).
[in] clear If the data should be cleared this must be true.
[in] allocLocation Structure with caller data like source file and source line.
返回
数据 pointer or nullptr.

◆  PrivateFree()

MAXON_METHOD void PrivateFree ( void *  data )

Frees a memory block (might have been allocated by a different local Allocator of the same type).

参数
[in] data Pointer as returned by Alloc, guaranteed to be valid and not nullptr.

◆  PrivateGetDataSize()

MAXON_METHOD Int PrivateGetDataSize ( void *  data )

Returns the maximum size of an allocated block (might be bigger than what was acutally allocated).

参数
[in] data Pointer as returned by Alloc, guaranteed to be valid and != nullptr.
返回
Block size in bytes (>=allocated size) or 0.