aboutsummaryrefslogtreecommitdiff
path: root/map.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 /map.c
parentfcbe22e6bb4b461d9605c35df6705335cc515333 (diff)
downloadastar-d0fa196751879965f6fb3a7426801ee66b434654.tar.xz
Handle the stack overflow
Diffstat (limited to 'map.c')
-rw-r--r--map.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/map.c b/map.c
index 735a00c..2bf3ab0 100644
--- a/map.c
+++ b/map.c
@@ -123,7 +123,7 @@ Map rbt_maze_map(size_t width, size_t height, unsigned int seed) {
memset(visited, 0, sizeof(char) * width * height);
PositionStack ps = ps_new();
- ps_push(&ps, beginning_cell);
+ if (ps_push(&ps, beginning_cell) == -1) error("Is the STACK_SIZE zero?");
visited[beginning_cell.y][beginning_cell.x] = 1;
Position na[4];
@@ -135,7 +135,7 @@ Map rbt_maze_map(size_t width, size_t height, unsigned int seed) {
if (nc > 0) {
Position next = na[rand() % nc];
Position prev = ps_peek(ps);
- ps_push(&ps, next);
+ if (ps_push(&ps, next) == -1) error("Stack overflow in rbt_maze_map(). Recompile with bigger STACK_SIZE or decrease the map size\n");
visited[next.y][next.x] = 1;
map[(next.y * 2 + prev.y * 2) / 2][(next.x * 2 + prev.x * 2) / 2] = EMPTY;
} else {