summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-11-04 06:49:21 (GMT)
committerJason Evans <jasone@canonware.com>2016-11-04 06:49:21 (GMT)
commita967fae362f55ee7162fb48776dfac69d4f28d1c (patch)
treebf3de8a61e9cb545c6c8e20a150dbd4896e26d6d /src
parent4a7852137d8b6598fdb90ea8e1fd3bc8a8b94a3a (diff)
downloadjemalloc-a967fae362f55ee7162fb48776dfac69d4f28d1c.zip
jemalloc-a967fae362f55ee7162fb48776dfac69d4f28d1c.tar.gz
jemalloc-a967fae362f55ee7162fb48776dfac69d4f28d1c.tar.bz2
Fix/simplify extent_recycle() allocation size computations.
Do not call s2u() during alloc_size computation, since any necessary ceiling increase is taken care of later by extent_first_best_fit() --> extent_size_quantize_ceil(), and the s2u() call may erroneously cause a higher quantization result. Remove an overly strict overflow check that was added in 4a7852137d8b6598fdb90ea8e1fd3bc8a8b94a3a (Fix extent_recycle()'s cache-oblivious padding support.).
Diffstat (limited to 'src')
-rw-r--r--src/extent.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/extent.c b/src/extent.c
index e190adc..4027e8b 100644
--- a/src/extent.c
+++ b/src/extent.c
@@ -405,6 +405,7 @@ extent_recycle(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
malloc_mutex_assert_owner(tsdn, &arena->extents_mtx);
assert(new_addr == NULL || !slab);
assert(pad == 0 || !slab);
+ assert(alignment > 0);
if (config_debug && new_addr != NULL) {
extent_t *prev;
@@ -427,13 +428,11 @@ extent_recycle(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
assert(prev == NULL || extent_past_get(prev) == new_addr);
}
- alloc_size = ((new_addr != NULL) ? usize : s2u(usize +
- PAGE_CEILING(alignment) - PAGE)) + pad;
- if (alloc_size > LARGE_MAXCLASS + pad || alloc_size < usize) {
- /* Too large, possibly wrapped around. */
- return (NULL);
- }
size = usize + pad;
+ alloc_size = size + PAGE_CEILING(alignment) - PAGE;
+ /* Beware size_t wrap-around. */
+ if (alloc_size < usize)
+ return (NULL);
if (!locked)
malloc_mutex_lock(tsdn, &arena->extents_mtx);
extent_hooks_assure_initialized(arena, r_extent_hooks);