Support malloc() even after tcache destruction has occurred, since other tsd

destructors may run after tcache_tsd's.
This commit is contained in:
Jason Evans 2010-01-12 18:13:39 -08:00
parent 79a78691b6
commit 64bd7661a8

View File

@ -3426,13 +3426,15 @@ arena_malloc(size_t size, bool zero)
#ifdef JEMALLOC_TCACHE #ifdef JEMALLOC_TCACHE
if (isthreaded && tcache_nslots) { if (isthreaded && tcache_nslots) {
tcache_t *tcache = tcache_tls; tcache_t *tcache = tcache_tls;
if (tcache == NULL) { if ((uintptr_t)tcache > (uintptr_t)1)
return (tcache_alloc(tcache, size, zero));
else if (tcache == NULL) {
tcache = tcache_create(choose_arena()); tcache = tcache_create(choose_arena());
if (tcache == NULL) if (tcache == NULL)
return (NULL); return (NULL);
}
return (tcache_alloc(tcache, size, zero)); return (tcache_alloc(tcache, size, zero));
} else { }
}
#endif #endif
if (size <= small_maxclass) { if (size <= small_maxclass) {
return (arena_malloc_small(choose_arena(), size, return (arena_malloc_small(choose_arena(), size,
@ -3441,9 +3443,6 @@ arena_malloc(size_t size, bool zero)
return (arena_malloc_medium(choose_arena(), return (arena_malloc_medium(choose_arena(),
size, zero)); size, zero));
} }
#ifdef JEMALLOC_TCACHE
}
#endif
} else } else
return (arena_malloc_large(choose_arena(), size, zero)); return (arena_malloc_large(choose_arena(), size, zero));
} }