diff options
Diffstat (limited to 'stack.c')
| -rw-r--r-- | stack.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -18,11 +18,13 @@ int ps_push(PositionStack *ps, Position pos) { } Position ps_pop(PositionStack *ps) { + if (ps->top == 0) error("Stack underflow\n"); ps->top -= 1; return ps->arr[ps->top]; } Position ps_peek(PositionStack ps) { + if (ps.top == 0) error("Stack underflow\n"); return ps.arr[ps.top - 1]; } |
