diff --git a/include/mimalloc-types.h b/include/mimalloc-types.h index 9f97f8f5..957115c8 100644 --- a/include/mimalloc-types.h +++ b/include/mimalloc-types.h @@ -172,13 +172,13 @@ typedef int32_t mi_ssize_t; #endif // Maximum slice offset (15) -#define MI_MAX_SLICE_OFFSET ((MI_ALIGNED_MAX / MI_SEGMENT_SLICE_SIZE) - 1) +#define MI_MAX_SLICE_OFFSET ((MI_ALIGNMENT_MAX / MI_SEGMENT_SLICE_SIZE) - 1) // Used as a special value to encode block sizes in 32 bits. #define MI_HUGE_BLOCK_SIZE ((uint32_t)MI_HUGE_OBJ_SIZE_MAX) // blocks up to this size are always allocated aligned -#define MI_MAX_ALIGN_GUARANTEE (8*MI_MAX_ALIGN_SIZE) +#define MI_MAX_ALIGN_GUARANTEE (8*MI_MAX_ALIGN_SIZE) diff --git a/src/segment.c b/src/segment.c index 7b2fa28e..3001f160 100644 --- a/src/segment.c +++ b/src/segment.c @@ -317,7 +317,7 @@ static uint8_t* _mi_segment_page_start_from_slice(const mi_segment_t* segment, c 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 ? MI_MAX_ALIGN_GUARANTEE : 0); - if (page_size != NULL) *page_size = psize - start_offset; + if (page_size != NULL) { *page_size = psize - start_offset; } return (uint8_t*)segment + ((idx*MI_SEGMENT_SLICE_SIZE) + start_offset); } diff --git a/test/test-api.c b/test/test-api.c index 96817337..f057799a 100644 --- a/test/test-api.c +++ b/test/test-api.c @@ -163,7 +163,7 @@ int main(void) { for (size_t align = 1; align <= MI_ALIGNMENT_MAX && ok; align *= 2) { void* ps[8]; for (int i = 0; i < 8 && ok; i++) { - ps[i] = mi_malloc_aligned(align/2 /*size*/, align); + ps[i] = mi_malloc_aligned(align*13 /*size*/, align); if (ps[i] == NULL || (uintptr_t)(ps[i]) % align != 0) { ok = false; }