aboutsummaryrefslogtreecommitdiff
path: root/stack.c
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-03-25 14:40:30 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-03-25 14:40:30 +0300
commitd0fa196751879965f6fb3a7426801ee66b434654 (patch)
tree795948c5c7a7d3356f9f78f56f438b330db30f02 /stack.c
parentfcbe22e6bb4b461d9605c35df6705335cc515333 (diff)
downloadastar-d0fa196751879965f6fb3a7426801ee66b434654.tar.xz
Handle the stack overflow
Diffstat (limited to 'stack.c')
-rw-r--r--stack.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/stack.c b/stack.c
index c915afd..1edb5c5 100644
--- a/stack.c
+++ b/stack.c
@@ -1,5 +1,8 @@
#include "stack.h"
#include "structs.h"
+#include "error.h"
+#include "curses.h" /* Required by error.h */
+#include "stdio.h" /* Required by error.h */
PositionStack ps_new(void) {
PositionStack ps;
@@ -8,7 +11,7 @@ PositionStack ps_new(void) {
}
int ps_push(PositionStack *ps, Position pos) {
- /*TODO: check for stack overflow */
+ if (ps->top >= STACK_SIZE) return -1;
ps->arr[ps->top] = pos;
ps->top += 1;
return 0;