diff options
Diffstat (limited to 'src/stack.c')
-rw-r--r-- | src/stack.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/stack.c b/src/stack.c index 2438792..ebfa640 100644 --- a/src/stack.c +++ b/src/stack.c @@ -26,7 +26,7 @@ void stack_push(stack_t *s, hash_table_t *h) { } /* fix heap buffer overflow */ hash_table_t *stack_peek(stack_t *s) { - if (s->cur == -1) + if (is_empty(s)) return NULL; return s->stack[s->cur]; } @@ -37,3 +37,9 @@ hash_table_t *stack_pop(stack_t *s) { s->cur--; return h; } + +bool is_empty(stack_t *s) { + if (s->cur == -1) + return true; + return false; +} |