I was going through heap_2.c in the MemMang folder in FreeRTOS V7.4.2 source to understand it. I have compared heap_2.c with the latest vesrion too, this file remains more of less the same, so I did not move over to the newest version of FreeRTOS to get a newer version of heap_2.c. After going through the code, I have a few doubts.
Why is configTOTAL_HEAP_SIZE defined with a** size_t** type e.g. “#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 19 * 1024 ) )” and size_t is used in a few other places as well in heap_2.c? What is the benefit of it ?
Why does size of** xBlockLink**, blocks and** xWantedSize** need to be aligned or adjusted to the nearest word (4 bytes in case of Cortex M4), is it because some controllers are not capable of unaligned access ?
To save stack depth prvInsertBlockIntoFreeList macro is defined in heap_2.c, whereas** prvHeapInit** is an independent function in the same file even though prvHeapInit is a static function as well. What are the considerations for using macros or functions here?