Skip to main content

estimate_unused_stack_space

Function estimate_unused_stack_space 

Source
pub fn estimate_unused_stack_space() -> u16
Expand description

Returns the number of stack bytes that have never been written to.

This function can be called at any time.

This function walks the stack from end to beginning and checks if the initialization PATTERN is still there. The number of bytes that still contain the PATTERN is returned.

The returned value is only an estimate. If the program code wrote PATTERN bytes to the stack, then these bytes will falsely be seen as unused. It is assumed that this scenario is unlikely to occur for more than a couple of bytes, and therefore the estimation is expected to be off by no more than a couple of bytes.

This function does not protect against stack overflows. If an actual stack overflow occurred, the behavior is undefined.