[webkit-dev] Tightening up smart pointer usage rules

Darin Adler darin at apple.com
Mon Jun 28 14:57:00 PDT 2010


On Jun 28, 2010, at 2:14 PM, Adam Barth wrote:

> Do we need an exception for statics that we intend to leak at shutdown? Maybe leakPtr(new Foo)?

Maybe.

My first thought for such things is that I’d prefer to write them as:

    adoptPtr(new Foo).releasePtr()

At first that may look strange, but it has a huge benefit. It can be refactored to:

    Foo::create().releasePtr()

That’s the main reason I don’t suggest having a leakPtr or dontAdoptPtr function.

I have thought that leakPtr might be a good alternate name for releasePtr. In fact I have proposed renaming releaseRef to leakRef more than once.

    -- Darin



More information about the webkit-dev mailing list