-
|
In the response handler is it necessary to call otMessageFree(message) after receiving the message or not? Would it have any impact on the buffer space for receiving coap messages? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
In the OpenThread CoAP response handler, you do not need to call The OpenThread stack manages the lifecycle of the message buffer and will automatically free it once your response handler returns. Manually calling 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 |
Beta Was this translation helpful? Give feedback.
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…