[geos-devel] Reviewing std::auto_ptr spaghetti

Sandro Santilli strk at kbt.io
Wed Sep 6 08:17:11 PDT 2017


On Wed, Sep 06, 2017 at 04:24:45PM +0200, Mateusz Loskot wrote:

> In the code, there are uses of std::auto_ptr that are hard to reason about
> what makes me suspicious:
> 
> class T
> {
>   auto_ptr items;
> public
>     auto_ptr<A> getItems()
>     {
>         return items;
>     }
> };
> 
> Is the intention to give up the object's internal resource, really?

Yes. I agree it's a weird pattern, but it's what got us to the current
leak-free state. Very dangerous for C++ interface, but safe for C-API.

Best we can do is document when needed.

--strk;


More information about the geos-devel mailing list