Bug 5749 - WebCore should have wider adoption of SharedPtr
Summary: WebCore should have wider adoption of SharedPtr
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P4 Normal
Assignee: Nobody
URL:
Keywords: EasyFix
Depends on:
Blocks:
 
Reported: 2005-11-15 02:08 PST by Eric Seidel (no email)
Modified: 2007-01-13 10:02 PST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2005-11-15 02:08:44 PST
I'm filing this bug in case a WebKit open source contributer would like something easy to chew on that 
will take them throughout a large section of the code.

We have this template SharedPtr<T> which is used for automatically ref()ing and deref()ing "Shared" 
objects.  SharedPtr behaves pretty much just like a normal pointer and can be used either as an 
instance variable, or as a local variable for keeping track of a ref to an object.  SharedPtr automatically 
initializes itself to 0 in it's default constructor, as well as will automatically ref on assignment and deref 
on clearing or when going out of scope.

In order to find all the places in which SharePtr should be applied in the khtml code, simply search for 
"deref()".  SharePtr works with any object supporting ref()/deref() calls, not just those deriving from 
Shared, however, as you witll note, there are certain objects which take arguments on ref() or deref() 
which are not compatible with SharedPtr.

At time of writing there 342 manual deref() calls in khtml.  Most (if not all) of those could be replaced 
by proper SharePtr usage, for  not only cleaner, smaller code, but possibly also bug fixes.  We've found 
numerous ref counting issues in WebCore before, which have often been fixed by adoping SharedPtr.
Comment 1 Alexey Proskuryakov 2006-06-24 14:58:21 PDT
There are significantly fewer manual derefs now, and not all of these can be easily removed, but many are still waiting :-)
Comment 2 Anders Carlsson 2007-01-13 10:02:51 PST
I think we can declare this as fixed now, closing.