From 64bd7661a833f97ec8a5cd0d688c64e8b5a7d5cc Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Tue, 12 Jan 2010 18:13:39 -0800 Subject: [PATCH] Support malloc() even after tcache destruction has occurred, since other tsd destructors may run after tcache_tsd's. --- jemalloc/src/jemalloc.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/jemalloc/src/jemalloc.c b/jemalloc/src/jemalloc.c index 9fe90423..2eb2de14 100644 --- a/jemalloc/src/jemalloc.c +++ b/jemalloc/src/jemalloc.c @@ -3426,24 +3426,23 @@ arena_malloc(size_t size, bool zero) #ifdef JEMALLOC_TCACHE if (isthreaded && tcache_nslots) { 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()); if (tcache == NULL) return (NULL); + return (tcache_alloc(tcache, size, zero)); } - return (tcache_alloc(tcache, size, zero)); - } else { -#endif - if (size <= small_maxclass) { - return (arena_malloc_small(choose_arena(), size, - zero)); - } else { - return (arena_malloc_medium(choose_arena(), - size, zero)); - } -#ifdef JEMALLOC_TCACHE } #endif + if (size <= small_maxclass) { + return (arena_malloc_small(choose_arena(), size, + zero)); + } else { + return (arena_malloc_medium(choose_arena(), + size, zero)); + } } else return (arena_malloc_large(choose_arena(), size, zero)); }