From d0fa196751879965f6fb3a7426801ee66b434654 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Wed, 25 Mar 2026 14:40:30 +0300 Subject: Handle the stack overflow --- stack.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'stack.c') 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; -- cgit v1.2.3