pub fn with_alloca<R>(
size: usize,
f: impl FnOnce(&mut [MaybeUninit<u8>]) -> R,
) -> RExpand description
Allocates [u8; size] memory on stack and invokes closure with this slice as argument.
§Safety
This function is safe because c_with_alloca (which is internally used) will always returns non-null
pointer.
§Potential segfaults or UB
When using this function in wrong way your program might get UB or segfault “for free”:
-
Using memory allocated by
with_allocaoutside of it e.g closure is already returned but you somehow managed to store pointer to memory and use it. -
Allocating more memory than thread stack size.
This will trigger segfault on stack overflow.