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 Bettini          ICQ# lbetto, 16080134     |
|  PhD in Computer Science                            |
|  Dip. Sistemi e Informatica, Univ. di Firenze       |
|  Florence - Italy        (GNU/Linux User # 158233)  |
|  Home Page        :    |
|         XKlaim language  |
|    Cover Band  |
|           |
|              |
|       |
|    |

Boost list run by bdawes at, gregod at, cpdaniel at, john at