← Back to team overview

dolfin team mailing list archive

Re: Ownership

 

If we can use references somewhere we use pointers, we should change
that. All factory functions will of course return pointers, and they
clearly give away ownership to the caller. Where else do we need to
use pointers? A common reason to use pointers other than when passing
ownership is to allow a null pointer. Any other reasons?

Using a host of different smart pointers will probably just be
confusing to most users. I think we should stick with the
std::tr1::shared_ptr if we need one, unless there are very good
reasons otherwise. (Also, the newest version of swig is supposed to
support shared_ptr in the python interface, but I don't know how
exactly).

-- 
Martin


2008/6/26 Garth N. Wells <gnw20@xxxxxxxxx>:
> In trying to follow some pieces code recently and tracking down some
> memory leaks, I see that as some classes have become more sophisticated,
> ownership is not always clear. Where we used to use references to data,
> we often now need to use pointers. This lead to a number of leaks and
> makes code harder to read.
>
> I don't know of any simple solutions for this, but it is worth
> discussing what to do. It might just be a case of naming conventions.
> Perhaps an idea is to start by trying returning smart pointers in the
> linear algebra factories? Boost provides a number of smart pointers that
> are straightforward to use. If this works, we can try using them more
> extensively.
>
> Garth
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
>


Follow ups

References