Re: [webkit-dev] Tightening up smart pointer usage rules

2010-06-29 Thread David Levin
I like leakPtr. Personally, releasePtr() is so close to release() (which is safe) that I could easily overlook it in a code review and not realize that it hands off a raw pointer with a ref count on it. dave On Tue, Jun 29, 2010 at 10:40 AM, Darin Adler da...@apple.com wrote: On Jun 28,

Re: [webkit-dev] Tightening up smart pointer usage rules

2010-06-29 Thread Geoffrey Garen
I like leakPtr. Personally, releasePtr() is so close to release() (which is safe) that I could easily overlook it in a code review and not realize that it hands off a raw pointer with a ref count on it. dave +1 Anders once argued against the name leakPtr, Well, then you might as well

[webkit-dev] Tightening up smart pointer usage rules

2010-06-28 Thread Darin Adler
Hi folks. I’d like to use our smart pointers more consistently to decrease the chances of memory leaks or other similar problems. My proposal is that we have a rule that all calls to new are immediately followed by putting the object into a smart pointer. The main types of smart pointer that

Re: [webkit-dev] Tightening up smart pointer usage rules

2010-06-28 Thread Kenneth Christiansen
   6) Add validator rules that make invocation of the new operator legal only inside adoptRef and adoptPtr function calls. That is probably going to be a problem for Qt code on the WebKit API side. If we disable this rule for WebKitTools and WebKit I think we should be OK Kenneth

Re: [webkit-dev] Tightening up smart pointer usage rules

2010-06-28 Thread Adam Barth
On Mon, Jun 28, 2010 at 1:43 PM, Kenneth Christiansen kenneth.christian...@openbossa.org wrote:    6) Add validator rules that make invocation of the new operator legal only inside adoptRef and adoptPtr function calls. That is probably  going to be a problem for Qt code on the WebKit API

Re: [webkit-dev] Tightening up smart pointer usage rules

2010-06-28 Thread Adam Barth
Sounds great. Let me know how I can help. Do we need an exception for statics that we intend to leak at shutdown? Maybe leakPtr(new Foo)? Adam On Mon, Jun 28, 2010 at 1:39 PM, Darin Adler da...@apple.com wrote: Hi folks. I’d like to use our smart pointers more consistently to decrease the

Re: [webkit-dev] Tightening up smart pointer usage rules

2010-06-28 Thread Antti Koivisto
Is the plan also to banish the std::auto_ptr? It seems pointless and confusing to allow both the OwnPtr and the auto_ptr. antti (who wants PwnPtr too) On Mon, Jun 28, 2010 at 11:39 PM, Darin Adler da...@apple.com wrote: Hi folks. I’d like to use our smart pointers more consistently to

Re: [webkit-dev] Tightening up smart pointer usage rules

2010-06-28 Thread Darin Adler
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

Re: [webkit-dev] Tightening up smart pointer usage rules

2010-06-28 Thread Darin Adler
On Jun 28, 2010, at 2:55 PM, Antti Koivisto wrote: Is the plan also to banish the std::auto_ptr? It seems pointless and confusing to allow both the OwnPtr and the auto_ptr. Yes, that would be my preference. PassOwnPtr is intended as a replacement for std::auto_ptr. Before PassOwnPtr

Re: [webkit-dev] Tightening up smart pointer usage rules

2010-06-28 Thread Maciej Stachowiak
I like this idea. Addressing some of the side comments: - Yes, we should get rid of auto_ptr. - I can imagine a leakPtr function being more self-documenting than adoptPtr(...).releasePtr() when it appears in code, but on the other hand the greater convenience may lead to using it carelessly.