PCL
|
Provides memory allocation for PCL containers. More...
#include <Allocator.h>
Inherits A.
Public Member Functions | |
Allocator ()=default | |
Allocator (const A &a) | |
Allocator (const Allocator< T, A > &)=default | |
T * | Allocate (size_type n, size_type extra=0) |
void | Deallocate (T *p) |
size_type | MaxLength () const |
size_type | PagedLength (size_type n) const |
size_type | ReallocatedLength (size_type currentLength, size_type newLength) const |
Allocator inherits directly from its template argument A, which corresponds to a block allocator class. A block allocator is responsible for allocation and deallocation of untyped blocks of contiguous memory. Allocator inherits block allocation capabilities and specializes them for allocation of a particular type T.
The type T must have default and copy construction semantics.
Besides the default and copy constructors, the block allocator class A must define the following member functions:
Returns the maximum size in bytes that the block allocator is able to allocate as a contiguous memory block.
Returns the size in bytes of an allocation block suitable to store at least n contiguous bytes. Allocator uses this block size to reserve memory in chunks of optimized length. This greatly improves efficiency of containers because it minimizes the frequency of allocation/deallocation operations.
Returns the size in bytes of a reallocated block. currentSize is the current size in bytes of the block being reallocated, and newSize is the requested block size. This function is similar to A::BlockSize(), but it is called for reallocation of already existing data blocks, for example before deleting a subset of container elements.
Custom allocation routine. Allocates a contiguous memory block of length sz in bytes, and returns the address of the first byte in the newly allocated block.
Custom deallocation routine. Deallocates a contiguous block of memory that has been previously allocated by any allocator of class A.
StandardAllocator is an example of a block allocator that uses the standard new
and delete
operators.
Definition at line 131 of file Allocator.h.
|
default |
Default constructor.
Referenced by pcl::IndirectArray< T, A >::Allocator().
|
default |
Copy constructor.
|
inline |
Constructs an Allocator instance as a copy of other block allocator.
Definition at line 148 of file Allocator.h.
|
inline |
Allocates a contiguous block of memory, sufficient to store at least n instance of class T. Optionally, allocates the necessary space for n objects plus extra additional bytes.
Returns the starting address of the allocated block.
Definition at line 163 of file Allocator.h.
|
inline |
Deallocates a block of memory.
Definition at line 177 of file Allocator.h.
|
inline |
Returns the maximum number of instances of class T that this allocator can allocate.
Definition at line 188 of file Allocator.h.
|
inline |
Returns the length of a newly allocated data block.
Given a number n of T instances, returns the corresponding paged length for this allocator. The paged length is the actual number of T instances that would be allocated instead of n, which depends on the block allocation policy implemented by the block allocator class.
The value returned by this member function is always greater than or equal to n.
Definition at line 206 of file Allocator.h.
|
inline |
Returns the length of a reallocated data block.
currentLength | The current length of an allocated data block. |
newLength | The new length of the reallocated data block. |
The returned length is the actual number of T instances that would be allocated instead of newLength, which depends on the block allocation policy implemented by the block allocator class.
The value returned by this member function is always greater than or equal to n.
Definition at line 227 of file Allocator.h.