MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / mi_expand

Function mi_expand

system/lib/mimalloc/src/alloc.c:347–359  ·  view source on GitHub ↗

Expand (or shrink) in place (or fail)

Source from the content-addressed store, hash-verified

345
346// Expand (or shrink) in place (or fail)
347void* mi_expand(void* p, size_t newsize) mi_attr_noexcept {
348 #if MI_PADDING
349 // we do not shrink/expand with padding enabled
350 MI_UNUSED(p); MI_UNUSED(newsize);
351 return NULL;
352 #else
353 if (p == NULL) return NULL;
354 const mi_page_t* const page = mi_validate_ptr_page(p,"mi_expand");
355 const size_t size = _mi_usable_size(p,page);
356 if (newsize > size) return NULL;
357 return p; // it fits
358 #endif
359}
360
361void* _mi_theap_realloc_zero(mi_theap_t* theap, void* p, size_t newsize, bool zero, size_t* usable_pre, size_t* usable_post) mi_attr_noexcept {
362 // if p == NULL then behave as malloc.

Callers 2

mi__expandFunction · 0.85
_expandFunction · 0.85

Calls 2

mi_validate_ptr_pageFunction · 0.85
_mi_usable_sizeFunction · 0.85

Tested by

no test coverage detected