On 27/06/2011, at 3:37 PM, Campbell Barton wrote:
Would a std::vector<T> be an appropriate replacement in the areas you're seeing things?
Have to say I don't know C++ well enough to say, heres a simple example of one of the cases with 3 lines of function body:
./src/libcola/shortest_paths.cpp
dijkstra(...) { Node vs[n]; dijkstra_init(vs,es,eweights); dijkstra(s,n,vs,d); }
So not freeing in this case is really not a worry, though maybe some day the function becomes more complicated, which is still an argument against replacing with allocations. Even so there are tools to detect memory leaks, I use valgrind frequently however it does rely on someone running that function to find the leak so errors can still go un-noticed.
Would std::vector<T> be acceptable here?
Since this is code I'm now maintaining (libvpsc, libcola, libavoid), I can answer this. Yes, and in fact this code in the Adaptagrams SVN repository was updated some time ago to use std::vector since someone using it had run into this compiler error.
Updating the libavoid version in Inkscape is on my todo list, and when I do this I'll update libcola and libvpsc as well. I know there were a couple of instances of these dynamically allocated arrays in the Adaptagrams libraries.
Cambpell, are all the instances of this problem in the libcola, libavoid and libvpsc directories? For the ones that are, could you please send me the patch and I'll make sure they are corrected.
Cheers, Michael
------ Dr. Michael Wybrow, Research Fellow Clayton School of Information Technology Monash University Wellington Rd, Clayton, Vic 3800, Australia Phone: +613 9905 2479