openDAQ
Open data acquisition platform
Allocator
+ Collaboration diagram for Allocator:

Detailed Description

Classes

struct  IAllocator
 An allocator used to allocate memory. More...
 
class  AllocatorPtr
 An allocator used to allocate memory. More...
 

Functions

void * allocate (const daq::DataDescriptorPtr &descriptor, daq::SizeT bytes, daq::SizeT align) const
 Allocates a chunk of memory for a packet. More...
 
void free (void *address) const
 Releases a chunk of memory allocated by allocate(). More...
 

Function Documentation

◆ allocate()

void* allocate ( const daq::DataDescriptorPtr &  descriptor,
daq::SizeT  bytes,
daq::SizeT  align 
) const
inline

Allocates a chunk of memory for a packet.

Parameters
descriptorThe 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.
bytesThe number of bytes to allocate.
alignThe 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.
Returns
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.

◆ free()

void free ( void *  address) const
inline

Releases a chunk of memory allocated by allocate().

Parameters
addressThe address of the allocated memory to release.

The implementation MUST ignore calls where address is null.