MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / mi_segment_calculate_slices

Function mi_segment_calculate_slices

3rd/mimalloc-2.0.9/src/segment.c:335–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333
334
335static size_t mi_segment_calculate_slices(size_t required, size_t* pre_size, size_t* info_slices) {
336 size_t page_size = _mi_os_page_size();
337 size_t isize = _mi_align_up(sizeof(mi_segment_t), page_size);
338 size_t guardsize = 0;
339
340 if (MI_SECURE>0) {
341 // in secure mode, we set up a protected page in between the segment info
342 // and the page data (and one at the end of the segment)
343 guardsize = page_size;
344 if (required > 0) {
345 required = _mi_align_up(required, MI_SEGMENT_SLICE_SIZE) + page_size;
346 }
347 }
348
349 if (pre_size != NULL) *pre_size = isize;
350 isize = _mi_align_up(isize + guardsize, MI_SEGMENT_SLICE_SIZE);
351 if (info_slices != NULL) *info_slices = isize / MI_SEGMENT_SLICE_SIZE;
352 size_t segment_size = (required==0 ? MI_SEGMENT_SIZE : _mi_align_up( required + isize + guardsize, MI_SEGMENT_SLICE_SIZE) );
353 mi_assert_internal(segment_size % MI_SEGMENT_SLICE_SIZE == 0);
354 return (segment_size / MI_SEGMENT_SLICE_SIZE);
355}
356
357
358/* ----------------------------------------------------------------------------

Callers 2

mi_segment_os_allocFunction · 0.85
mi_segment_allocFunction · 0.85

Calls 2

_mi_os_page_sizeFunction · 0.85
_mi_align_upFunction · 0.85

Tested by

no test coverage detected