diff options
| author | Jason Evans <jasone@canonware.com> | 2015-10-24 14:56:00 (GMT) |
|---|---|---|
| committer | Jason Evans <jasone@canonware.com> | 2015-10-24 14:56:00 (GMT) |
| commit | 91010a9e2ebfc84b1ac1ed7fdde3bfed4f65f180 (patch) | |
| tree | 70f4f340b8e36bed4a1c418bfb312a1671ebf494 /src | |
| parent | e9192eacf8935e29fc62fddc2701f7942b1cc02c (diff) | |
| parent | be4134710669e8b09d6b928f72a4208e5a68187c (diff) | |
| download | jemalloc-4.0.4.zip jemalloc-4.0.4.tar.gz jemalloc-4.0.4.tar.bz2 | |
Merge branch 'dev'4.0.4
Diffstat (limited to 'src')
| -rw-r--r-- | src/arena.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/arena.c b/src/arena.c index 3081519..43733cc 100644 --- a/src/arena.c +++ b/src/arena.c @@ -2683,10 +2683,16 @@ arena_ralloc_large_grow(arena_t *arena, arena_chunk_t *chunk, void *ptr, /* * Zero the trailing bytes of the original allocation's * last page, since they are in an indeterminate state. + * There will always be trailing bytes, because ptr's + * offset from the beginning of the run is a multiple of + * CACHELINE in [0 .. PAGE). */ - assert(PAGE_CEILING(oldsize) == oldsize); - memset((void *)((uintptr_t)ptr + oldsize), 0, - PAGE_CEILING((uintptr_t)ptr) - (uintptr_t)ptr); + void *zbase = (void *)((uintptr_t)ptr + oldsize); + void *zpast = PAGE_ADDR2BASE((void *)((uintptr_t)zbase + + PAGE)); + size_t nzero = (uintptr_t)zpast - (uintptr_t)zbase; + assert(nzero > 0); + memset(zbase, 0, nzero); } size = oldsize + splitsize; |
