diff options
author | Jason Evans <jasone@canonware.com> | 2015-07-23 17:16:32 -0700 |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2015-07-23 17:18:49 -0700 |
commit | 87ccb5554769d915338b9a980d36359a5c6ec3fa (patch) | |
tree | 90bfbf3e148f03a7b6e80597b6e2b7e4b8ff0c8a /src | |
parent | 4becdf21dceeeaaeec37043ce59d654c214363e2 (diff) | |
download | jemalloc-87ccb5554769d915338b9a980d36359a5c6ec3fa.tar.gz |
Fix huge_palloc() to handle size rather than usize input.
huge_ralloc() passes a size that may not be precisely a size class, so
make huge_palloc() handle the more general case of a size input rather
than usize.
This regression appears to have been introduced by the addition of
in-place huge reallocation; as such it was never incorporated into a
release.
Diffstat (limited to 'src')
-rw-r--r-- | src/huge.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -46,15 +46,21 @@ huge_malloc(tsd_t *tsd, arena_t *arena, size_t size, bool zero, } void * -huge_palloc(tsd_t *tsd, arena_t *arena, size_t usize, size_t alignment, +huge_palloc(tsd_t *tsd, arena_t *arena, size_t size, size_t alignment, bool zero, tcache_t *tcache) { void *ret; + size_t usize; extent_node_t *node; bool is_zeroed; /* Allocate one or more contiguous chunks for this request. */ + usize = sa2u(size, alignment); + if (unlikely(usize == 0)) + return (NULL); + assert(usize >= chunksize); + /* Allocate an extent node with which to track the chunk. */ node = ipallocztm(tsd, CACHELINE_CEILING(sizeof(extent_node_t)), CACHELINE, false, tcache, true, arena); @@ -68,15 +74,15 @@ huge_palloc(tsd_t *tsd, arena_t *arena, size_t usize, size_t alignment, is_zeroed = zero; arena = arena_choose(tsd, arena); if (unlikely(arena == NULL) || (ret = arena_chunk_alloc_huge(arena, - usize, alignment, &is_zeroed)) == NULL) { + size, alignment, &is_zeroed)) == NULL) { idalloctm(tsd, node, tcache, true); return (NULL); } - extent_node_init(node, arena, ret, usize, is_zeroed); + extent_node_init(node, arena, ret, size, is_zeroed); if (huge_node_set(ret, node)) { - arena_chunk_dalloc_huge(arena, ret, usize); + arena_chunk_dalloc_huge(arena, ret, size); idalloctm(tsd, node, tcache, true); return (NULL); } @@ -89,9 +95,9 @@ huge_palloc(tsd_t *tsd, arena_t *arena, size_t usize, size_t alignment, if (zero || (config_fill && unlikely(opt_zero))) { if (!is_zeroed) - memset(ret, 0, usize); + memset(ret, 0, size); } else if (config_fill && unlikely(opt_junk_alloc)) - memset(ret, 0xa5, usize); + memset(ret, 0xa5, size); return (ret); } |