docs: Clarifications on buffer ownership

This commit is contained in:
2026-06-29 16:00:02 +01:00
parent 24554e9d23
commit 854d6eab36
2 changed files with 12 additions and 2 deletions

View File

@@ -17,3 +17,13 @@ Set as a macro in compile flags if wishing to override the defaults
## Setup ## Setup
- incphub_task_preinit MUST be run before any calls to the client, likely even before the scheduler is started - incphub_task_preinit MUST be run before any calls to the client, likely even before the scheduler is started
## Buffer ownership
Buffers are allocated with incphub_get_msg_buffer, at which point they belong to the requesting task.
When passed to incphub_send_XXX functions, they become owned by incphub
When dispatched internally, the receiving task becomes the owner and must invoke incphub_release_msg_buffer when done
When routed externally, after calling the transmitter function, incphub releases the buffer

View File

@@ -28,7 +28,7 @@ int incphub_init_client(incphub_cli_t **cli, ntl_port_t port);
/// @return INCPHUB_OK on success, an error otherwise /// @return INCPHUB_OK on success, an error otherwise
int incphub_get_msg_buffer(incphub_cli_t *cli, uint8_t **buffer_ptr, size_t length); int incphub_get_msg_buffer(incphub_cli_t *cli, uint8_t **buffer_ptr, size_t length);
/// @brief Releases a buffer previously acquired with incphub_get_msg_buffer /// @brief Releases a buffer received from incphub_await_msg
/// @param cli Current client handle /// @param cli Current client handle
/// @param buffer The buffer to release /// @param buffer The buffer to release
/// @return INCPHUB_OK on success, an error otherwise /// @return INCPHUB_OK on success, an error otherwise
@@ -36,7 +36,7 @@ int incphub_release_msg_buffer(incphub_cli_t *cli, uint8_t *buffer);
/// @brief Attempts to send a message to the local interface /// @brief Attempts to send a message to the local interface
/// @param cli Current client handle /// @param cli Current client handle
/// @param buffer The message buffer /// @param buffer The message buffer (gets consumed)
/// @param length The message length /// @param length The message length
/// @param dst_port The destination NTL port /// @param dst_port The destination NTL port
/// @return INCPHUB_OK on success, an error otherwise /// @return INCPHUB_OK on success, an error otherwise