diff options
author | Jason Evans <jasone@canonware.com> | 2015-01-31 05:22:54 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2015-02-05 00:50:04 (GMT) |
commit | 8ddc93293cd8370870f221225ef1e013fbff6d65 (patch) | |
tree | 6fd61d02a3d95a837d9ae82ab76963c82a3ed1ae /src | |
parent | f8723572d8b3418f145fc1d5466cca6b8e2530ef (diff) | |
download | jemalloc-8ddc93293cd8370870f221225ef1e013fbff6d65.zip jemalloc-8ddc93293cd8370870f221225ef1e013fbff6d65.tar.gz jemalloc-8ddc93293cd8370870f221225ef1e013fbff6d65.tar.bz2 |
Fix chunk_recycle()'s new_addr functionality.
Fix chunk_recycle()'s new_addr functionality to search by address rather
than just size if new_addr is specified. The functionality added by
a95018ee819abf897562d9d1f3bc31d4dd725a8d (Attempt to expand huge
allocations in-place.) only worked if the two search orders happened to
return the same results (e.g. in simple test cases).
Diffstat (limited to 'src')
-rw-r--r-- | src/chunk.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/chunk.c b/src/chunk.c index 7bfcdb8..a3ae548 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -48,6 +48,8 @@ chunk_recycle(extent_tree_t *chunks_szad, extent_tree_t *chunks_ad, size_t alloc_size, leadsize, trailsize; bool zeroed; + assert(new_addr == NULL || alignment == chunksize); + if (base) { /* * This function may need to call base_node_{,de}alloc(), but @@ -65,13 +67,15 @@ chunk_recycle(extent_tree_t *chunks_szad, extent_tree_t *chunks_ad, key.addr = new_addr; key.size = alloc_size; malloc_mutex_lock(&chunks_mtx); - node = extent_tree_szad_nsearch(chunks_szad, &key); - if (node == NULL || (new_addr && node->addr != new_addr)) { + node = (new_addr != NULL) ? extent_tree_ad_search(chunks_ad, &key) : + extent_tree_szad_nsearch(chunks_szad, &key); + if (node == NULL) { malloc_mutex_unlock(&chunks_mtx); return (NULL); } leadsize = ALIGNMENT_CEILING((uintptr_t)node->addr, alignment) - (uintptr_t)node->addr; + assert(new_addr == NULL || leadsize == 0); assert(node->size >= leadsize + size); trailsize = node->size - leadsize - size; ret = (void *)((uintptr_t)node->addr + leadsize); |