legends2k
August 17th, 2009, 12:19 PM
Hi,
I'm having a huge Java module with so many news and not a single delete call (obviously). I'm trying to port it to C++. I've ported other library dependences I.e. wrote new ones for them. Now for the new-delete problem, I tried using Boost's smart pointer classes. I've a doubt in them. Say if I want something like
int **palette = new int* [5];
palette[0] = new int [3];
palette[1] = new int [5];
...
...
Will I be able to use boost::shared_array smart pointer class for the same? I.e. will I be able to use smart pointers for double pointers too? If yes, I'm unable to get the syntax right. The main thing is that, once I discard the whole palette, all the pointers, both the double and the single pointers should free memory without leaks.
P.S.:
I tried something like this to no avail.
boost::scoped_array<boost::scoped_ptr<int>*> doubleptr_smartptr(new boost::scoped_ptr<int>* [10]);
I'm having a huge Java module with so many news and not a single delete call (obviously). I'm trying to port it to C++. I've ported other library dependences I.e. wrote new ones for them. Now for the new-delete problem, I tried using Boost's smart pointer classes. I've a doubt in them. Say if I want something like
int **palette = new int* [5];
palette[0] = new int [3];
palette[1] = new int [5];
...
...
Will I be able to use boost::shared_array smart pointer class for the same? I.e. will I be able to use smart pointers for double pointers too? If yes, I'm unable to get the syntax right. The main thing is that, once I discard the whole palette, all the pointers, both the double and the single pointers should free memory without leaks.
P.S.:
I tried something like this to no avail.
boost::scoped_array<boost::scoped_ptr<int>*> doubleptr_smartptr(new boost::scoped_ptr<int>* [10]);