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

Improve ChibiOS memory functions #2634

Closed
wants to merge 9 commits into from
23 changes: 6 additions & 17 deletions targets/ChibiOS/_common/platform_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,17 @@
//

#include <ch.h>
#include <nanoHAL_v2.h>
// #include <nanoHAL_v2.h> // Not required as we are fully using the platform specific implementation.

void *platform_malloc(size_t size)
{

// need to undef in order to call the real function
#undef malloc

return malloc(size);

// define back
#define malloc YOU_SHALL_NOT_USE_malloc
return chHeapAlloc(NULL, size);
}

void platform_free(void *ptr)
{

// need to undef in order to call the real function
#undef free

free(ptr);

// define back
#define free YOU_SHALL_NOT_USE_free
if (ptr)
{
chHeapFree(ptr);
}
}