summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2012-04-02 22:18:24 (GMT)
committerJason Evans <jasone@canonware.com>2012-04-02 22:18:24 (GMT)
commitf0047372673da7f213f733465dab0d8825eb1c9f (patch)
tree67fa9306c2e905569b0a171623f2510fe2fbc74d /src
parent96d4120ac08db3f2d566e8e5c3bc134a24aa0afc (diff)
downloadjemalloc-f0047372673da7f213f733465dab0d8825eb1c9f.zip
jemalloc-f0047372673da7f213f733465dab0d8825eb1c9f.tar.gz
jemalloc-f0047372673da7f213f733465dab0d8825eb1c9f.tar.bz2
Revert "Avoid NULL check in free() and malloc_usable_size()."
This reverts commit 96d4120ac08db3f2d566e8e5c3bc134a24aa0afc. ivsalloc() depends on chunks_rtree being initialized. This can be worked around via a NULL pointer check. However, thread_allocated_tsd_get() also depends on initialization having occurred, and there is no way to guard its call in free() that is cheaper than checking whether ptr is NULL.
Diffstat (limited to 'src')
-rw-r--r--src/jemalloc.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c
index 86ce695..1deabcd 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -1100,18 +1100,22 @@ JEMALLOC_ATTR(visibility("default"))
void
je_free(void *ptr)
{
- size_t usize;
- assert(malloc_initialized || IS_INITIALIZER);
+ if (ptr != NULL) {
+ size_t usize;
- if (config_prof && opt_prof) {
- usize = isalloc(ptr);
- prof_free(ptr, usize);
- } else if (config_stats)
- usize = isalloc(ptr);
- if (config_stats)
- thread_allocated_tsd_get()->deallocated += usize;
- idalloc(ptr);
+ assert(malloc_initialized || IS_INITIALIZER);
+
+ if (config_prof && opt_prof) {
+ usize = isalloc(ptr);
+ prof_free(ptr, usize);
+ } else if (config_stats) {
+ usize = isalloc(ptr);
+ }
+ if (config_stats)
+ thread_allocated_tsd_get()->deallocated += usize;
+ idalloc(ptr);
+ }
}
/*
@@ -1196,7 +1200,7 @@ je_malloc_usable_size(const void *ptr)
if (config_ivsalloc)
ret = ivsalloc(ptr);
else
- ret = isalloc(ptr);
+ ret = (ptr != NULL) ? isalloc(ptr) : 0;
return (ret);
}