Closed Bug 1145051 Opened 5 years ago Closed 5 years ago

mozalloc.h should not depend on xpcom-config.h

Categories

(Core :: Memory Allocator, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: jimb, Assigned: jimb)

Details

Attachments

(3 files)

I'd like to use mozalloc.h in JS_STANDALONE (JS shell) builds, but it depends on xpcom-config.h for some attributes that really belong in mfbt/Attributes.h anyway.

mfbt/Attributes.h should be extended to provide the same functionality, and the whole tree should switch to using those. That accomplished, mozalloc.h will no longer need xpcom-config.h, and we can remove the dependency.
Assignee: nobody → jimb
Status: NEW → ASSIGNED
Attachment #8579893 - Flags: review?(mh+mozilla)
The punch line.
Attachment #8579895 - Flags: review?(mh+mozilla)
Comment on attachment 8579893 [details] [diff] [review]
Replace uses of NS_ATTR_MALLOC with new MOZ_ALLOCATOR from mfbt/Attributes.h.

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

::: memory/mozalloc/mozalloc.h
@@ +65,5 @@
>  MFBT_API
>  void moz_free(void* ptr);
>  
>  MFBT_API void* moz_xmalloc(size_t size)
> +    MOZ_ALLOCATOR NS_WARN_UNUSED_RESULT;

Maybe NS_WARN_UNUSED_RESULT should be implied by MOZ_ALLOCATOR.

::: mfbt/Attributes.h
@@ +301,5 @@
> + *
> + * Place this attribute at the very beginning of a function definition. For
> + * example, write
> + *
> + *   MOZ_ALLOCATOR void *my_allocator(size_t);

... which doesn't match how it's used :) (it's placed *after* the definition at the moment)
Attachment #8579893 - Flags: review?(mh+mozilla) → review+
Comment on attachment 8579894 [details] [diff] [review]
Use MOZ_WARN_UNUSED_RESULT instead of NS_WARN_UNUSED_RESULT.

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

You're missing dom/base/nsHTMLContentSerializer.h, dom/base/nsXHTMLContentSerializer.h and dom/base/nsXMLContentSerializer.h (landed recently in bug 1131348).

::: mfbt/Attributes.h
@@ +320,5 @@
> + *
> + * Place this attribute at the very beginning of a function definition. For
> + * example, write
> + *
> + *   MOZ_WARN_UNUSED_RESULT int foo();

Same kind of remark as MOZ_ALLOCATOR, we're using it both before and after.
Attachment #8579894 - Flags: review?(mh+mozilla) → review+
Attachment #8579895 - Flags: review?(mh+mozilla) → review+
Flags: in-testsuite-
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.