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

Function _mi_prim_alloc

system/lib/mimalloc/src/prim/emscripten/prim.c:77–91  ·  view source on GitHub ↗

Note: the `try_alignment` is just a hint and the returned pointer is not guaranteed to be aligned.

Source from the content-addressed store, hash-verified

75
76// Note: the `try_alignment` is just a hint and the returned pointer is not guaranteed to be aligned.
77int _mi_prim_alloc(void* hint_addr, size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** addr) {
78 MI_UNUSED(allow_large); MI_UNUSED(commit); MI_UNUSED(hint_addr);
79 *is_large = false;
80 // TODO: Track the highest address ever seen; first uses of it are zeroes.
81 // That assumes no one else uses sbrk but us (they could go up,
82 // scribble, and then down), but we could assert on that perhaps.
83 *is_zero = false;
84 // emmalloc has a minimum alignment size.
85 #define MIN_EMMALLOC_ALIGN 8
86 if (try_alignment < MIN_EMMALLOC_ALIGN) {
87 try_alignment = MIN_EMMALLOC_ALIGN;
88 }
89 *addr = emmalloc_memalign(try_alignment, size);
90 return (*addr != NULL ? 0 : ENOMEM);
91}
92
93
94//---------------------------------------------

Callers

nothing calls this directly

Calls 1

emmalloc_memalignFunction · 0.85

Tested by

no test coverage detected