Loading...
 
Skip to main content

System Workbench for STM32


Use pvPortMalloc() or malloc()?

I am using FREERTOS. For the code I add to an STM32CubeMX created project is it preferable to use pvPortMalloc() or malloc()? Would there be any advantage to abandoning the use of malloc() in favor of exclusively using pvPortMalloc()?
France

Yes, you should use pvPortMalloc instead of malloc, as malloc is not protected against mulltitask parallel use...

Fo pvPortMalloc, you can choose from various implementations in the FreeRTOS source code (heap1.c to heap4.c); look at the comments in front of the files to choose the one that fits best your needs.

Bernard (Ac6)