Data Allocator

group data_allocator

A quick-and-dirty provisional interface

Typedefs

typedef struct dds_data_allocator dds_data_allocator_t

Data Allocator structure Contains internal details about the data allocator for a given entity.

Functions

dds_return_t dds_data_allocator_init(dds_entity_t entity, dds_data_allocator_t *data_allocator)

Initialize an object for performing allocations/frees in the context of a reader/writer.

The operation will fall back to standard heap allocation if nothing better is available.

Parameters
  • entity[in] the handle of the entity

  • data_allocator[out] opaque allocator object to initialize

Return values
  • DDS_RETCODE_OK – the allocator object was successfully initialized

  • DDS_RETCODE_BAD_PARAMETER – entity is invalid, data_allocator is a null pointer

  • DDS_RETCODE_PRECONDITION_NOT_MET – Cyclone DDS is not initialized

  • DDS_RETCODE_ILLEGAL_OPERATION – operation not supported on this entity

Returns

success or a generic error indication

dds_return_t dds_data_allocator_init_heap(dds_data_allocator_t *data_allocator)

Initialize an object for performing standard allocations/frees on the heap.

Parameters
  • data_allocator[out] opaque allocator object to initialize

Return values
  • DDS_RETCODE_OK – the allocator object was successfully initialized

  • DDS_RETCODE_BAD_PARAMETER – entity is invalid, data_allocator is a null pointer

  • DDS_RETCODE_PRECONDITION_NOT_MET – Cyclone DDS is not initialized

  • DDS_RETCODE_ILLEGAL_OPERATION – operation not supported on this entity

Returns

success or a generic error indication

dds_return_t dds_data_allocator_fini(dds_data_allocator_t *data_allocator)

Finalize a previously initialized allocator object.

Parameters
  • data_allocator[inout] object to finalize

Return values
  • DDS_RETCODE_OK – the data was successfully finalized

  • DDS_RETCODE_BAD_PARAMETER – data_allocator does not reference a valid entity

  • DDS_RETCODE_PRECONDITION_NOT_MET – Cyclone DDS is not initialized

Returns

success or an error indication

void *dds_data_allocator_alloc(dds_data_allocator_t *data_allocator, size_t size)

Allocate memory using the given allocator.

Parameters
  • data_allocator[inout] initialized allocator object

  • size[in] minimum number of bytes to allocate with suitable alignment

Returns

a pointer to unaliased, uninitialized memory of at least the requested size, or NULL

dds_return_t dds_data_allocator_free(dds_data_allocator_t *data_allocator, void *ptr)

Release memory using the given allocator.

Parameters
  • data_allocator[inout] initialized allocator object

  • ptr[in] memory to free

Return values
  • DDS_RETCODE_OK – the memory was successfully released

  • DDS_RETCODE_BAD_PARAMETER – data_allocator does not reference a valid entity

  • DDS_RETCODE_PRECONDITION_NOT_METdds_data_allocator already finalized

Returns

success or an error indication

struct dds_data_allocator
#include <dds_data_allocator.h>

Data Allocator structure Contains internal details about the data allocator for a given entity.

Public Members

dds_entity_t entity

to which entity this allocator is attached

unsigned char bytes[(12 * sizeof(void*))]

internal details

void *align_ptr

internal details

uint64_t align_u64

internal details

union dds_data_allocator.[anonymous] opaque

internal details