diff options
author | Mike Hommey <mh@glandium.org> | 2012-03-27 12:20:12 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2012-03-30 17:53:00 (GMT) |
commit | 71a93b8725fb52ae393ab88e2fccd5afa84c66a0 (patch) | |
tree | 183df5de00bb47ab3a9ee6eb03b8d60d96bd1649 /src | |
parent | 2cfe6d67ef6a622eeb47ba48b431bdafc0c45b35 (diff) | |
download | jemalloc-71a93b8725fb52ae393ab88e2fccd5afa84c66a0.zip jemalloc-71a93b8725fb52ae393ab88e2fccd5afa84c66a0.tar.gz jemalloc-71a93b8725fb52ae393ab88e2fccd5afa84c66a0.tar.bz2 |
Move zone registration to zone.c
Diffstat (limited to 'src')
-rw-r--r-- | src/jemalloc.c | 24 | ||||
-rw-r--r-- | src/zone.c | 22 |
2 files changed, 21 insertions, 25 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c index 9eae137..908485a 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -712,26 +712,6 @@ malloc_init_hard(void) /* Copy the pointer to the one arena that was already initialized. */ arenas[0] = init_arenas[0]; -#ifdef JEMALLOC_ZONE - /* Register the custom zone. At this point it won't be the default. */ - malloc_zone_t *jemalloc_zone = create_zone(); - malloc_zone_register(jemalloc_zone); - - /* - * Unregister and reregister the default zone. On OSX >= 10.6, - * unregistering takes the last registered zone and places it at the - * location of the specified zone. Unregistering the default zone thus - * makes the last registered one the default. On OSX < 10.6, - * unregistering shifts all registered zones. The first registered zone - * then becomes the default. - */ - do { - malloc_zone_t *default_zone = malloc_default_zone(); - malloc_zone_unregister(default_zone); - malloc_zone_register(default_zone); - } while (malloc_default_zone() != jemalloc_zone); -#endif - malloc_initialized = true; malloc_mutex_unlock(&init_lock); return (false); @@ -743,8 +723,8 @@ void jemalloc_darwin_init(void) { - if (malloc_init_hard()) - abort(); + if (malloc_init_hard() == false) + register_zone(); } #endif @@ -159,8 +159,8 @@ zone_force_unlock(malloc_zone_t *zone) jemalloc_postfork_parent(); } -malloc_zone_t * -create_zone(void) +void +register_zone(void) { zone.size = (void *)zone_size; @@ -206,5 +206,21 @@ create_zone(void) zone_introspect.enumerate_unavailable_without_blocks = NULL; #endif #endif - return (&zone); + + /* Register the custom zone. At this point it won't be the default. */ + malloc_zone_register(&zone); + + /* + * Unregister and reregister the default zone. On OSX >= 10.6, + * unregistering takes the last registered zone and places it at the + * location of the specified zone. Unregistering the default zone thus + * makes the last registered one the default. On OSX < 10.6, + * unregistering shifts all registered zones. The first registered zone + * then becomes the default. + */ + do { + malloc_zone_t *default_zone = malloc_default_zone(); + malloc_zone_unregister(default_zone); + malloc_zone_register(default_zone); + } while (malloc_default_zone() != &zone); } |