You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The very, very strange thing is that we are malloc this variable, then immediately freeing it after passing it into esp_now_add_peer.
This raises the question: Why bother with mallocing it at all...?
Is this, perhaps, to get around memory access restrictions across task boundary? That seems sketchy.
If it is safe to immediately free the variable, it should be safe to just leave it defined on the stack.
OFC, in practice, freed data does not necessarily get returned to the system. So even though the memory is freed, it might still operate as intended.
This just seems really sketchy.
Unfortunately, ESPNOW documentation makes no mention of whether memory needs to be retained by the caller. Good design principles would lead me to assume "no" but we cannot know for sure without documentation.
I am going to move forward under the assumption that keeping the data on the stack is fine. I'll report back here on if that creates problems.
The text was updated successfully, but these errors were encountered:
So both our current firmware, and the official ESP-IDF examples follow the following pattern:
The very, very strange thing is that we are malloc this variable, then immediately freeing it after passing it into esp_now_add_peer.
This raises the question: Why bother with mallocing it at all...?
Is this, perhaps, to get around memory access restrictions across task boundary? That seems sketchy.
If it is safe to immediately free the variable, it should be safe to just leave it defined on the stack.
OFC, in practice, freed data does not necessarily get returned to the system. So even though the memory is freed, it might still operate as intended.
This just seems really sketchy.
Unfortunately, ESPNOW documentation makes no mention of whether memory needs to be retained by the caller. Good design principles would lead me to assume "no" but we cannot know for sure without documentation.
I am going to move forward under the assumption that keeping the data on the stack is fine. I'll report back here on if that creates problems.
The text was updated successfully, but these errors were encountered: