Skip to content
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

added guard to prevent dealloc and realloc on null ptr #8

Merged
merged 1 commit into from
Jun 30, 2020

Conversation

alsaibie
Copy link
Contributor

A small fix to memory management. Based on this issue.

}

void * __freertos_reallocate(void * pointer, size_t size, void * state){
(void) state;
// printf("-- Realloc %d -> %d (prev: %d B)\n",getBlockSize(pointer),size, xPortGetFreeHeapSize());
absoluteUsedMemory += size;
usedMemory += size;
usedMemory -= getBlockSize(pointer);
return pvPortRealloc(pointer,size);
if (NULL != pointer){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability, I propose to swap the two cases, in order to avoid an else-branch for a unequal comparison.

@ralph-lange
Copy link
Contributor

Thank you very much for the contribution, @alsaibie.

@ralph-lange ralph-lange merged commit 60b5950 into micro-ROS:dashing Jun 30, 2020
fofolevrai pushed a commit to fofolevrai/freertos_apps that referenced this pull request Jun 14, 2021
Source for before building to fix agent build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants