How does memory get allocated on the heap when using an static array?

How does memory get allocated on the heap when using a static array in heap_1.c for example?

I afraid I don’t fully understand your question.
Do you have questions regarding the implementation details of heap_1.c after reading the source ?

Yes exactly, heap_1.c for example uses a static array.
Don’t fully understand how it manages the heap?

When you google for “freertos heap_1”, you will find all information about the different heap algorithms, from heap_1 to heap_5.
( Google brought me here ).

Ok, yes I’ve googled and read the FreeRTOS documentation, I found this:

So, heap_1.c doesn’t really allocate memory on the heap

Exactly

It somewhat depends on what you want to call ‘the heap’. There is ‘the heap’ that C provides, which is only used in heap_3.c, which provide wrappers for malloc and free so they can be used in a thread safe manner.

The other heap files CREATE there own equivalent of that heap for use by FreeRTOS and other parts of the program that use those same routines. Each version provide different capabilities, and all (except heap_3.c) work out of static arrays for the allocations.

I mean the ‘heap’ defined within a specific memory region in RAM in my STM32 MCU.

@richard-damon:
The other heap files CREATE there own equivalent of that heap for use by FreeRTOS and other parts of the program that use those same routines. Each version provide different capabilities, and all (except heap_3.c) work out of static arrays for the allocations.

Ok I understand the conecpt. Thanks

Yes, the key is THAT heap, as defined by the link map, is only used by malloc and company. To use that, you need to use heap_3.c (and watch out that malloc by itself may. not be thread-safe)

Cortex-M: I use heap_5.c, and configure the whole of RAM from the end of BSS to <some amount for interrupts, default 1024> below the initial stack top. Since I’m writing in Ada, I don’t need to worry about malloc/free.

Hmm. I can see that will be an issue if I call some Newlib function that does use malloc/free.