Replacing malloc and free
Many C-runtimes will ship with an implementation of malloc. However, the C-runtime versions for embedded-systems are not necessarily thread-safe by default. Because each C-runtime is different, the steps needed to make malloc thread safe will vary. The included STM toolchain used in this book includes newlib-nano as the C-runtime library. The following are a few notes regarding newlib-nano:
newlib-nanois a derivative of newlib, targeted for embedded systems. It uses similar APIs as newlib and some of the information about newlib applies tonewlib-nano.newlib-nanousesmallocandreallocforstdio.hfunctionality (for example,printf). (reallocis a library-function for resizing a memory-block that was previously obtained by a library-function such asmalloc.)reallocis not directly supported by FreeRTOS heap implementations.FreeRTOSConfig.hincludes theconfigUSE_NEWLIB_REENTRANTsetting to makenewlibthread safe, but it...