Function silc_stack_pop
SYNOPSIS
SilcUInt32 silc_stack_pop(SilcStack stack);
DESCRIPTION
Pop the top of the stack upwards which reveals the previous stack frame
and becomes the top of the stack. After popping, memory allocated in
the old frame is freed. For each silc_stack_push call there must be
silc_stack_pop call to free all memory (in reality any memory is not
freed but within the stack it is). This returns the stack pointer of
old frame after popping and caller may check that it is same as
returned by the silc_stack_push. If it they differ, some routine
has called silc_stack_push but has not called silc_stack_pop, or
silc_stack_pop has been called too many times. Application should
treat this as a fatal error, as it is a bug in the application code.
If `stack' is NULL this call has no effect.
EXAMPLE
This example saves the stack pointer which is checked when popping
the current stack frame. If the stack pointer differs then someone
has pushed the stack frame but forgot to pop it (or has called it
too many times).
sp = silc_stack_push(stack, NULL);
silc_foo_parse_packet(packet, stack);
if (silc_stack_pop(stack) != sp)
fatal("corrupted stack");
|