How do I copy from a sequence to an array?

Note: Applies to RTI Connext 4.x and above, C and C++ APIs

Statically allocated arrays

  • For C, use FooSeq_to_array.
  • For C++, use FooSeq::to_array.

Dinamically allocated arrays 

There is an easy way to copy from sequence into an array. RTI Connext will always create a contiguous internal buffer for a sequence, if you don't loan it anything. So, you can do the following to copy the sequence to an application buffer: 

  1. Ensure that the application buffer is at least as big as the current size of the sequence. 
  2. Get the address of the first element, e.g. using FooSeq_get_reference(&foo_seq,0) 
  3. Use that address in a call to memcpy. 

Note: See Example attached.

Programming Language:
Attachments: