I had a problem somewhere in my code in a function that I wanted to declare an array but it failed. after some debugging I found out that it uses malloc in disassembly window so I increased the heap size and it works fine!
So my question is why keil uses Heap for local variable?
Here is the variable declaration code:
uint8_t result[data->capacityBytes];
memset(result, 0, sizeof(result));
I've added flag C99
Your array has a dynamic size, i.e. the compiler does not know how big it will be until runtime. This is a feature introduced in C99 called variable length arrays (VLA).
According to Keil's documentation (see the Note), such arrays are allocated on the heap by this compiler. (Others might allocate on the stack. Others might not implement this feature at all - it became optional in C11.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With