summaryrefslogtreecommitdiffstats
path: root/jemalloc
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2010-01-13 02:13:39 (GMT)
committerJason Evans <jasone@canonware.com>2010-01-13 02:13:39 (GMT)
commit64bd7661a833f97ec8a5cd0d688c64e8b5a7d5cc (patch)
tree0bde1db910b29f334e512d896c626344aca6da4a /jemalloc
parent79a78691b6c2f4eed37fbd4746076068685317bd (diff)
downloadjemalloc-64bd7661a833f97ec8a5cd0d688c64e8b5a7d5cc.zip
jemalloc-64bd7661a833f97ec8a5cd0d688c64e8b5a7d5cc.tar.gz
jemalloc-64bd7661a833f97ec8a5cd0d688c64e8b5a7d5cc.tar.bz2
Support malloc() even after tcache destruction has occurred, since other tsd
destructors may run after tcache_tsd's.
Diffstat (limited to 'jemalloc')
-rw-r--r--jemalloc/src/jemalloc.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/jemalloc/src/jemalloc.c b/jemalloc/src/jemalloc.c
index 9fe9042..2eb2de1 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));
}