Apologies for the time taken to reply - I wanted to write some tests for this.
I concur the heap_1 and heap_2 alignment calculation can unnecessarily waste a word, so will create a pull request to amend as per your suggestion (unless you want to create the pull request here first of course https://github.com/FreeRTOS/FreeRTOS-Kernel
However I don’t see anything wrong in the case of heap_4 or heap_5 where the code is:
if( ( xAddress & portBYTE_ALIGNMENT_MASK ) != 0 )
{
xAddress += ( portBYTE_ALIGNMENT - 1 );
xAddress &= ~portBYTE_ALIGNMENT_MASK;
/* Adjust the size for the bytes lost to alignment. */
xTotalRegionSize -= xAddress - ( size_t ) pxHeapRegion->pucStartAddress;
}
Looking at this further, unfortunately the modification does not work when portBYTE_ALIGNMENT is 1. We could use the same technique as heap_4 and heap_5, but really heap_1 and heap_2 are basically obsolete (heap_1 by the ability to use static allocation and heap_2 by heap_4) and as this is only wasting one word of memory I’m inclined to leave the code as is.