Closed Bug 1192230 Opened 9 years ago Closed 9 years ago

clean up reference-counting in xpcom/

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla43
Tracking Status
firefox43 --- fixed

People

(Reporter: froydnj, Assigned: froydnj)

Details

Attachments

(1 file)

      No description provided.
Mostly, what we're doing here is eliminating:

  NS_ADDREF(*aOutParam = ptr);

in favor of:

  ptr.forget(aOutParam);

which is smaller and more efficient.  Various null-checks might have been
eliminated in passing as well.
Attachment #8644939 - Flags: review?(erahm)
Comment on attachment 8644939 [details] [diff] [review]
clean up reference-counting in xpcom/

Review of attachment 8644939 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, nice cleanup. r=me

::: xpcom/glue/nsArrayEnumerator.cpp
@@ -92,5 @@
>  NS_NewArrayEnumerator(nsISimpleEnumerator** aResult, nsIArray* aArray)
>  {
> -  nsSimpleArrayEnumerator* enumer = new nsSimpleArrayEnumerator(aArray);
> -  if (!enumer) {
> -    return NS_ERROR_OUT_OF_MEMORY;

Presumably it's OK to get rid of this b/c the allocator our new operator uses is infallible?
Attachment #8644939 - Flags: review?(erahm) → review+
> Presumably it's OK to get rid of this b/c the allocator our new operator
> uses is infallible?

Yes. |operator new| is infallible by default, though you can make it fallible by passing a |fallible_t| argument. See memory/mozalloc/mozalloc.h for details.
We also have some documentation on infallible allocation here:
https://developer.mozilla.org/en-US/docs/Infallible_memory_allocation
https://hg.mozilla.org/mozilla-central/rev/69980d43dea7
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: