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)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bent.mozilla, Assigned: bent.mozilla)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch Patch (obsolete) — 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+
Comment on attachment 281105 [details] [diff] [review] Patch Ok, will make that small change on checkin. Thanks!
Attachment #281105 - Flags: approval1.9?
Assignee: nobody → bent.mozilla
Attachment #281105 - Flags: superreview?(benjamin)
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?
Attached patch Updated fixSplinter Review
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?
Attachment #285249 - Flags: superreview?
Attachment #285249 - Flags: superreview+
Attachment #285249 - Flags: review?
Attachment #285249 - Flags: review+
Comment on attachment 285249 [details] [diff] [review] Updated fix a=release drivers.
Attachment #285249 - Flags: approval1.9? → approval1.9+
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.

Attachment

General

Created:
Updated:
Size: