Closed
Bug 767240
Opened 11 years ago
Closed 11 years ago
Make it easier to create type-specific scoped pointers (TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE)
Categories
(Core :: MFBT, defect)
Core
MFBT
Tracking
()
RESOLVED
FIXED
mozilla18
People
(Reporter: briansmith, Assigned: briansmith)
References
Details
Attachments
(1 file)
1.75 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
Some types (usually C types) need to be deleted with something other than free or delete. For example, PRFileDesc* needs to be deleted with PR_Close(), and NSS types usually need to be deleted using XXXX_DestroyYYYYYYY() functions. This macro and template make it easy to define types like "ScopedPRFileDesc" that work like ScopedDeletePtr.
Attachment #635572 -
Flags: review?(jwalden+bmo)
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → bsmith
Comment 1•11 years ago
|
||
Comment on attachment 635572 [details] [diff] [review] Add TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE to mftb/Scoped.h Review of attachment 635572 [details] [diff] [review]: ----------------------------------------------------------------- ::: mfbt/Scoped.h @@ +240,5 @@ > + * ScopedPRFileDesc file(PR_OpenFile(...)); > + * ... > + * } // file is closed with PR_Close here > + */ > +#define TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(name, Type, Deleter) \ This file doesn't do it right now, something got missed during reviews, but this macro (and all other macros in exported mfbt headers, except for the whole-file include guards) should be MOZ_-prefixed. Please do that for these new macros, so that the mistake doesn't propagate, at least? @@ +248,5 @@ > +template <typename T> > +struct TypeSpecificScopedPointerTraits > +{ > + typedef T* type; > + const static type empty() { return nsnull; } mfbt uses NULL. @@ +253,5 @@ > + const static void release(type value) > + { > + if (value) { > + TypeSpecificDelete(value); > + } No braces around single-line statements in mfbt code, see mfbt/STYLE.
Attachment #635572 -
Flags: review?(jwalden+bmo) → review+
Assignee | ||
Comment 2•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/7faf6b82017f Thanks for the review. I addressed all of the review comments.
Target Milestone: --- → mozilla18
Comment 3•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/7faf6b82017f
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•