Boost logo

Boost Users :

Subject: [Boost-users] Help in using smart (double) pointers
From: Sundaram (legends2k_at_[hidden])
Date: 2009-08-17 07:42:19


Howdy
I'm very new to Boost libraries, and this is my first try in using it, so pardon my naive questions. Now for the question:

I'm trying to port a Java module to C++, as in a J2ME game to Windows Mobile. I've re-written all the classes that the game code depends on the J2ME packages using Windows Mobile's native methods. Now for the last difference between the two: memory. The game code has lots of new and obviously no deletes, since Java has automatic garbage collection. So for the C++ equivalent , I thought of going for smart pointers, so that I needn't bother about memory leaks and to call delete for all news.

I've no problem in using smart pointers for normal dumb pointers. While it is the double pointers that I'm confused of. Say if I have:

int **palette = new int* [5];
palette[0] = new int[10];
palette[1] = new int[7];
...
...

what is the boost equivalent that I can use, so that when all references to palette's are released, all memory allocated in the name of palette should be freed i.e. both the single (palette[0], etc.) and double pointer (**palette) should be freed. If yes, can you please show me how?

Thanks!
Sundaram

      



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net