Boost logo

Boost :

From: Lorenzo Bettini (bettini_at_[hidden])
Date: 2005-06-07 01:43:08


David Abrahams wrote:
> Can you deal with deallocation of the whole network at once? It often
> works to maintain the nodes (C objects) in a container like a deque
> and let them link to one another with raw pointers.
>
> Otherwise you may be in need of a real GC.
>

I solved the problem in a (probably) not too elegant way: when I know
that I'm creating objects with mutual dependences say A and B I store
weak pointers, and I store a shared pointer to A and B into a list. As
long as the list survives the weak pointers are still valid. When I
want to deallocate everything, all I have to do is to deallocate the
list. This worked, and also valgrind says there are no leaks...

Lorenzo

--
+-----------------------------------------------------+
|  Lorenzo Bettini          ICQ# lbetto, 16080134     |
|  PhD in Computer Science                            |
|  Dip. Sistemi e Informatica, Univ. di Firenze       |
|  Florence - Italy        (GNU/Linux User # 158233)  |
|  Home Page        : http://www.lorenzobettini.it    |
|  http://music.dsi.unifi.it         XKlaim language  |
|  http://www.lorenzobettini.it/purple    Cover Band  |
|  http://www.gnu.org/software/src-highlite           |
|  http://www.gnu.org/software/gengetopt              |
|  http://www.lorenzobettini.it/software/gengen       |
|  http://www.lorenzobettini.it/software/doublecpp    |
+-----------------------------------------------------+

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk