manodeep / Corrfunc

⚡️⚡️⚡️Blazing fast correlation functions on the CPU.
https://corrfunc.readthedocs.io
MIT License
167 stars 51 forks source link

Avoid possible memory-leak with returned result #57

Closed manodeep closed 8 years ago

manodeep commented 8 years ago

All of the APIs return a heap-allocated struct result. This has potential for a memory-leak, in case the user does not free the memory afterwards. I am probably doing that from the python interfaces. An easy fix would be to replace those with stack-allocated structs, this would require replacing all results-> with results.

manodeep commented 8 years ago

To completely avoid memory leaks would require the entire struct results to be on the stack => a compile-time max limit on nbins would have to be imposed. I could probably enforce something like MAX_NBINS = 2048; I can't imagine requiring more than 2048 bins. Closing for now - might revisit before v2.0.