Reputation: 43862
I'm using the C libYAML library for handling YAML configuration files, and I a little confused about this struct element in its code:
/** The stack of mapping pairs (key, value). */
struct {
/** The beginning of the stack. */
yaml_node_pair_t *start;
/** The end of the stack. */
yaml_node_pair_t *end;
/** The top of the stack. */
yaml_node_pair_t *top;
} pairs;
It uses three pointers, start
, end
, and top
. Both start
and end
seem obvious, they're the beginning and end of the region of data, but what is top
?
(For reference, this code appears at line 741 here.)
Upvotes: 1
Views: 241
Reputation: 11896
Start and end refer to the maximum boundaries of the stack. The top is a dynamic pointer referring to the current position, and changes as you call nested levels of functions.
Upvotes: 3