Closed Bug 504727 Opened 16 years ago Closed 16 years ago

Create an already_Transferred helper for nsAutoPtr

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(1 file, 1 obsolete file)

Attached patch Like so (obsolete) — Splinter Review
Just a way to annotate return values that the callee should own and delete.
Attachment #389076 - Flags: review?(dbaron)
Blocks: 504221
Attachment #389076 - Attachment is obsolete: true
Attachment #389417 - Flags: review?(dbaron)
Attachment #389076 - Flags: review?(dbaron)
Attachment #389417 - Flags: review?(benjamin)
I really don't like the name. I think "already" isn't really appropriate in this case. It's not a matter of when a reference count is being incremented, it's a matter of ownership being transferred. (I think a good name for this class could probably be applied back to renaming already_AddRefed if we really wanted to, although I doubt it would be worth it.) I've been trying to think if I can get a good name out of things like "caller owns" or "must free", but I'm not too happy with them either.
OS: Mac OS X → All
Hardware: x86 → All
Comment on attachment 389417 [details] [diff] [review] Without the bogus assert Is the goal to make the code more readable, or prevent some bad construct from happening at compile-time? I really don't think this makes it any more readable.
The goal is to keep: nsFoo* foo = GetFoo(); from compiling and to make it clear to anyone reading the header that GetFoo() needs to be assigned into an nsAutoPtr. Could call it caller_MustFree
boost::scoped_ptr doesn't have a similar helper... I'm skeptical that the reward/confusion factor makes this worthwhile.
I can live with wontfixing this; just would like us to make a call so I can land (or modify and land) the patches in bug 504221.
OK, per ircdiscussion with Benjamin, wontfix.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → WONTFIX
Attachment #389417 - Flags: review?(dbaron)
Attachment #389417 - Flags: review?(benjamin)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: