An allocator used to allocate memory. More...
An allocator used to allocate memory.
The default BB allocator simply uses malloc
, but the user can implement a custom allocator to override this behavior (perhaps using a memory pool or different allocation strategy). An example/reference implementation is provided which uses Microsoft mimalloc
.
Public Member Functions | |
virtual ErrCode INTERFACE_FUNC | allocate (const IDataDescriptor *descriptor, daq::SizeT bytes, daq::SizeT align, void **address)=0 |
Allocates a chunk of memory for a packet. More... | |
virtual ErrCode INTERFACE_FUNC | free (void *address)=0 |
Releases a chunk of memory allocated by allocate(). More... | |
![]() | |
virtual ErrCode INTERFACE_FUNC | borrowInterface (const IntfID &intfID, void **obj) const =0 |
Returns another interface which is supported by the object without incrementing the reference count. More... | |
virtual ErrCode INTERFACE_FUNC | dispose ()=0 |
Disposes all references held by the object. More... | |
virtual ErrCode INTERFACE_FUNC | getHashCode (SizeT *hashCode)=0 |
Returns hash code of the object. More... | |
virtual ErrCode INTERFACE_FUNC | equals (IBaseObject *other, Bool *equal) const =0 |
Compares object to another object for equality. More... | |
virtual ErrCode INTERFACE_FUNC | toString (CharPtr *str)=0 |
Returns a string representation of the object. More... | |
![]() | |
virtual ErrCode INTERFACE_FUNC | queryInterface (const IntfID &intfID, void **obj)=0 |
Returns another interface which is supported by the object and increments the reference count. More... | |
virtual int INTERFACE_FUNC | addRef ()=0 |
Increments the reference count for an interface on an object. More... | |
virtual int INTERFACE_FUNC | releaseRef ()=0 |
Decrements the reference count for an interface on an object. More... | |
|
pure virtual |
Allocates a chunk of memory for a packet.
descriptor | The OPTIONAL data descriptor of the signal for which memory is to be allocated. This can provide hints to the allocator. However, allocator implementations MUST accept null values. | |
bytes | The number of bytes to allocate. | |
align | The alignment requirement of the caller (typically the element size). This value may be zero if the caller does not need to specify an alignment requirement. | |
[out] | address | The address of the allocated memory. |
The implementation MAY set address value to nullptr
without returning an error code, if the allocator is out of memory. Alternatively, the implementation MAY return an error code in this case.
|
pure virtual |
Releases a chunk of memory allocated by allocate().
address | The address of the allocated memory to release. |
The implementation MUST ignore calls where address
is null.