Clean up allocations and deallocations
Two improvements to the code:
- Replaced all calls to
alloca()
bymalloc()
andposix_memalign()
depending on use case. - Added cleaning up code to free up all the allocated memory.
The second change is there to make sure we don't have memory leaks by easing the read of the memory sanitizer output. There is only one allocation that cannot be easily freed at the end of a run. In space.c (line 1327) we allocate cells in batches and then use them as a linked list. No memory leak there, just a hard unnecessary work to clean up at the end of a run.
That allows to run the EAGLE_50 example for hundreds of steps.