Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 847ff22

Browse files
glandiumJason Evans
authored andcommitted
Don't register jemalloc's zone allocator if something else already replaced the system default zone
1 parent e3d1306 commit 847ff22

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/zone.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ void
171171
register_zone(void)
172172
{
173173

174+
/*
175+
* If something else replaced the system default zone allocator, don't
176+
* register jemalloc's.
177+
*/
178+
malloc_zone_t *default_zone = malloc_default_zone();
179+
if (!default_zone->zone_name ||
180+
strcmp(default_zone->zone_name, "DefaultMallocZone") != 0) {
181+
return;
182+
}
183+
174184
zone.size = (void *)zone_size;
175185
zone.malloc = (void *)zone_malloc;
176186
zone.calloc = (void *)zone_calloc;
@@ -241,7 +251,7 @@ register_zone(void)
241251
* then becomes the default.
242252
*/
243253
do {
244-
malloc_zone_t *default_zone = malloc_default_zone();
254+
default_zone = malloc_default_zone();
245255
malloc_zone_unregister(default_zone);
246256
malloc_zone_register(default_zone);
247257
} while (malloc_default_zone() != &zone);

0 commit comments

Comments
 (0)