Skip to content
Discussion options

You must be logged in to vote

In the OpenThread CoAP response handler, you do not need to call otMessageFree(message).

The OpenThread stack manages the lifecycle of the message buffer and will automatically free it once your response handler returns. Manually calling otMessageFree(message) within the handler could actually lead to a double-free error because the stack will still attempt to free the message after the callback completes.

Regarding your question about buffer space: since the message is freed by the stack immediately after the handler returns, it will not permanently occupy buffer space.

If your application needs to keep the message data for use outside of the callback, you should clone the message using o…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jtaySWE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants