Macro libyml::STACK_LIMIT

source ·
macro_rules! STACK_LIMIT {
    ($context:expr, $stack:expr) => { ... };
}
Expand description

Checks if the stack has enough memory to push a new element.

This macro checks if the stack has enough memory to push a new element by comparing the distance between the top and start pointers with the maximum allowed distance. If the distance is less than the maximum allowed distance minus one, it means the stack has enough memory and the function returns OK. Otherwise, it sets the error field of the context to YamlMemoryError and returns FAIL.

§Parameters

  • $context: A mutable reference to the context in which the stack is being used.
  • $stack: A mutable reference to the stack being checked.

§Return

  • OK if the stack has enough memory to push a new element.
  • FAIL if the stack does not have enough memory to push a new element.