[−][src]Function alloca::with_alloca
pub fn with_alloca<R, F>(size: usize, f: F) -> R where
F: FnOnce(&mut [MaybeUninit<u8>]) -> R,
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_alloca
outside 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.