-
Notifications
You must be signed in to change notification settings - Fork 283
Static allocation of statistics buffer #1246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
12ffe31
to
032a3c9
Compare
} | ||
statisticsDataEnd = newData; // set DataEnd to new data | ||
|
||
StatisticsNextNodePtr next = statisticsDataEnd->next; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be a linked list now, it can just be an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we instead use a virtual index (0-720) for data retrieval and convert it to the current index (e.g. 359-719-0-358)?
Or should we return all the copied and reordered data at once with newly allocated memory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I understand the question. I would keep stack of the size and the start of the data in the array (head), then you can convert any position to the array position by modulo 720.
if (NULL != statisticsDataStart) { | ||
removeStatisticsBuffer(); | ||
|
||
StatisticsNodePtr buffer = (StatisticsNodePtr)malloc(sizeof(struct StatisticsData) * maxDataCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use heap_caps_malloc
with MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM
to force it into PSRAM?
There is a current potential for a memory leak with duplicate staticbuffer creating. my suggested change would be
Also please make sure to simplify it and I agree with @mutatrum that there is no need for a linked list |
For issue #1242