Functions that allocate memory with new() and then return the resulting pointer should be modified to instead keep a global array in memory, populate that array with the function results, and then set it as the return value. This will decrease the potential for segmentation faults, memory leaks, and (hopefully) false positive errors in valgrind.
Functions that allocate memory with
new()
and then return the resulting pointer should be modified to instead keep a global array in memory, populate that array with the function results, and then set it as the return value. This will decrease the potential for segmentation faults, memory leaks, and (hopefully) false positive errors in valgrind.