mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-07 11:58:41 +03:00
fix alignment issue #700
This commit is contained in:
parent
90f866c5bc
commit
4bf63300b3
4 changed files with 31 additions and 2 deletions
|
@ -316,7 +316,9 @@ static uint8_t* _mi_segment_page_start_from_slice(const mi_segment_t* segment, c
|
|||
ptrdiff_t idx = slice - segment->slices;
|
||||
size_t psize = (size_t)slice->slice_count * MI_SEGMENT_SLICE_SIZE;
|
||||
// make the start not OS page aligned for smaller blocks to avoid page/cache effects
|
||||
size_t start_offset = (xblock_size >= MI_INTPTR_SIZE && xblock_size <= 1024 ? 3*MI_MAX_ALIGN_GUARANTEE : 0);
|
||||
// note: the offset must always be an xblock_size multiple since we assume small allocations
|
||||
// are aligned (see `mi_heap_malloc_aligned`).
|
||||
size_t start_offset = (xblock_size >= MI_INTPTR_SIZE && xblock_size <= 512 ? xblock_size : 0);
|
||||
if (page_size != NULL) { *page_size = psize - start_offset; }
|
||||
return (uint8_t*)segment + ((idx*MI_SEGMENT_SLICE_SIZE) + start_offset);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue