Closed vassik closed 9 years ago
@Lyadis
In my opinion this behaviour is not problematic. The range of your variable declared locally in a function should not extend the lifetime of the function. Therefore you should not allocate memory to it and not free it inside the same function.
If you want to modify the content of an array inside a function, the array should be passed as a parameter. In the same way if you want to allocate memory to your array and conserved it after the lifetime of the function, the variable should be declare outside of the function and passed as a parameter.
Consider the following code in ThingML
and C generated code
Pointer to a local array is returned. Should never happen....
I would rather prefer dynamic allocation, but still not quite clear where to free this memory block...see below