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

Function mi_aligned_alloc

3rd/mimalloc-2.0.9/src/alloc-posix.c:85–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85mi_decl_nodiscard mi_decl_restrict void* mi_aligned_alloc(size_t alignment, size_t size) mi_attr_noexcept {
86 // C11 requires the size to be an integral multiple of the alignment, see <https://en.cppreference.com/w/c/memory/aligned_alloc>.
87 // unfortunately, it turns out quite some programs pass a size that is not an integral multiple so skip this check..
88 /* if mi_unlikely((size & (alignment - 1)) != 0) { // C11 requires alignment>0 && integral multiple, see <https://en.cppreference.com/w/c/memory/aligned_alloc>
89 #if MI_DEBUG > 0
90 _mi_error_message(EOVERFLOW, "(mi_)aligned_alloc requires the size to be an integral multiple of the alignment (size %zu, alignment %zu)\n", size, alignment);
91 #endif
92 return NULL;
93 }
94 */
95 // C11 also requires alignment to be a power-of-two (and > 0) which is checked in mi_malloc_aligned
96 void* p = mi_malloc_aligned(size, alignment);
97 mi_assert_internal(((uintptr_t)p % alignment) == 0);
98 return p;
99}
100
101mi_decl_nodiscard void* mi_reallocarray( void* p, size_t count, size_t size ) mi_attr_noexcept { // BSD
102 void* newp = mi_reallocn(p,count,size);

Callers 2

aligned_allocFunction · 0.85
_aligned_mallocFunction · 0.85

Calls 1

mi_malloc_alignedFunction · 0.85

Tested by

no test coverage detected