Comment 47 for bug 333127

Revision history for this message
In , Pavlov (pavlov) wrote :

(In reply to comment #20)
> (From update of attachment 386469 [details])
> (In reply to comment #17)
> > I don't understand the "elif !defined(malloc) bit here... can you explain the
> > purpose of that clause?
>
> I saw this code
>
> /* Mangle standard interfaces on Darwin and Windows CE,
> in order to avoid linking problems. */
> #if defined(MOZ_MEMORY_DARWIN)
> #define malloc(a) moz_malloc(a)
> #define valloc(a) moz_valloc(a)
> #define calloc(a, b) moz_calloc(a, b)
> #define realloc(a, b) moz_realloc(a, b)
> #define free(a) moz_free(a)
> #endif
>
> http://hg.mozilla.org/mozilla-central/annotate/55955ee71c10/memory/jemalloc/jemalloc.c#l6126
>
> and assumed that in some cases jemalloc does not replace the system malloc but
> is used as an alternative allocator in parallel to the system malloc (used
> only in cases where mixing of allocate/free implementations can be avoided).

on mac they use this zone allocator nonsense, and so malloc calls in to zone[0] basically and does an allocation. free() loops through each zone asking if it owns the allocation and then calls free on that zone. on mac with jemalloc (which we don't actually use at the moment), we setup a zone and replace the default zone with our own, so we need to define our functions as something other than malloc, etc. We still replace the system allocations.