Closed
Bug 396369
Opened 18 years ago
Closed 18 years ago
Overload forget method on nsCOMPtr/nsRefPtr to work with out parameters
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
People
(Reporter: bent.mozilla, Assigned: bent.mozilla)
Details
Attachments
(1 file, 1 obsolete file)
3.31 KB,
patch
|
bent.mozilla
:
review+
bent.mozilla
:
superreview+
damons
:
approval1.9+
|
Details | Diff | Splinter Review |
This patch overloads the forget method on nsCOMPtr/nsRefPtr to work better with out parameters.
This will save a pair of addref/release calls for all methods that use the following (ubiquitous) construct:
void FooMethod(/*out*/nsIFoo** _retval)
{
nsCOMPtr<nsIFoo> foo = ...
NS_ADDREF(*_retval = foo);
}
New code can simply use:
foo.forget(_retval);
Not that 'swap(_retval)' could be used but it isn't safe unless you first ensure that '*_retval' is null.
Attachment #281105 -
Flags: review?(dbaron)
Comment on attachment 281105 [details] [diff] [review]
Patch
There's no need for rhs to be T**&; it can just be T**. r=dbaron with that change
Attachment #281105 -
Flags: review?(dbaron) → review+
Assignee | ||
Comment 2•18 years ago
|
||
Comment on attachment 281105 [details] [diff] [review]
Patch
Ok, will make that small change on checkin. Thanks!
Attachment #281105 -
Flags: approval1.9?
Updated•18 years ago
|
Assignee: nobody → bent.mozilla
Updated•18 years ago
|
Attachment #281105 -
Flags: superreview?(benjamin)
Comment 3•18 years ago
|
||
Comment on attachment 281105 [details] [diff] [review]
Patch
Also, you need to add this signature to the specialization of nsCOMPtr<nsISupports> below in nsCOMPtr.h
Please submit a new patch to ask for approval
Attachment #281105 -
Flags: superreview?(benjamin)
Attachment #281105 -
Flags: superreview+
Attachment #281105 -
Flags: approval1.9?
Assignee | ||
Comment 4•18 years ago
|
||
Here's the updated patch with the extra nsISupports specialization. Carrying forward r+/sr+.
Attachment #281105 -
Attachment is obsolete: true
Attachment #285249 -
Flags: superreview?
Attachment #285249 -
Flags: review?
Attachment #285249 -
Flags: approval1.9?
Assignee | ||
Updated•18 years ago
|
Attachment #285249 -
Flags: superreview?
Attachment #285249 -
Flags: superreview+
Attachment #285249 -
Flags: review?
Attachment #285249 -
Flags: review+
Comment 5•18 years ago
|
||
Comment on attachment 285249 [details] [diff] [review]
Updated fix
a=release drivers.
Attachment #285249 -
Flags: approval1.9? → approval1.9+
Assignee | ||
Comment 6•18 years ago
|
||
Fixed on trunk.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•