rmw
master
C API providing a middleware abstraction layer which is used to implement the rest of ROS.
|
#include "rcutils/allocator.h"
#include "rmw/macros.h"
#include "rmw/types.h"
#include "rmw/visibility_control.h"
Go to the source code of this file.
Functions | |
rmw_serialized_message_t | rmw_get_zero_initialized_serialized_message (void) |
Return a zero initialized serialized message struct. More... | |
rmw_ret_t | rmw_serialized_message_init (rmw_serialized_message_t *msg, size_t buffer_capacity, const rcutils_allocator_t *allocator) |
Initialize a zero initialized serialized message struct. More... | |
rmw_ret_t | rmw_serialized_message_fini (rmw_serialized_message_t *msg) |
Finalize a serialized message struct. More... | |
rmw_ret_t | rmw_serialized_message_resize (rmw_serialized_message_t *msg, size_t new_size) |
Resize the internal buffer for the message byte stream. More... | |
rmw_serialized_message_t rmw_get_zero_initialized_serialized_message | ( | void | ) |
Return a zero initialized serialized message struct.
rmw_ret_t rmw_serialized_message_init | ( | rmw_serialized_message_t * | msg, |
size_t | buffer_capacity, | ||
const rcutils_allocator_t * | allocator | ||
) |
Initialize a zero initialized serialized message struct.
This function may leak if the serialized message struct is already pre-initialized. If the capacity is set to 0, no memory is allocated and the internal buffer is still NULL.
msg | a pointer to the to be initialized serialized message struct |
buffer_capacity | the size of the memory to allocate for the byte stream |
allocator | the allocator to use for the memory allocation |
RMW_RET_OK
if successful, or RMW_RET_ERROR
if an unexpected error occurs rmw_ret_t rmw_serialized_message_fini | ( | rmw_serialized_message_t * | msg | ) |
Finalize a serialized message struct.
Cleans up and deallocates any resources used in a rmw_message_serialized_t. Passing a rmw_serialized_message_t which has not been zero initialized using rmw_get_zero_initialized_serialized_message() to this function is undefined behavior.
msg | pointer to the serialized message to be cleaned up |
RMW_RET_OK
if successful, or RMW_RET_BAD_ALLOC
if memory allocation failed, or RMW_RET_ERROR
if an unexpected error occurs rmw_ret_t rmw_serialized_message_resize | ( | rmw_serialized_message_t * | msg, |
size_t | new_size | ||
) |
Resize the internal buffer for the message byte stream.
The internal buffer of the serialized message can be resized dynamically if needed. If the new size is smaller than the current capacity, then the memory is truncated. Be aware, that this will deallocate the memory and therefore invalidates any pointers to this storage. If the new size is larger, new memory is getting allocated and the existing content is copied over.
msg | pointer to the instance of rmw_serialized_message_t which is being resized |
new_size | the new size of the internal buffer |
RMW_RET_OK
if successful, or RMW_RET_BAD_ALLOC
if memory allocation failed, or RMW_RET_ERROR
if an unexpected error occurs