aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-05-03 21:00:44 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-05-03 21:00:44 +0300
commitd9d29ab80ddc33e864bf9caf36db524bbd3a0d25 (patch)
tree26c635b7bde4a47bdebb4edb3486b5050c34c549
parent1729beeae70832ef89f8077eff5a225ba51e337b (diff)
downloadastar-d9d29ab80ddc33e864bf9caf36db524bbd3a0d25.tar.xz
Fix return type for ps_push()
-rw-r--r--stack.c3
-rw-r--r--stack.h5
2 files changed, 4 insertions, 4 deletions
diff --git a/stack.c b/stack.c
index d13749e..d1e9b24 100644
--- a/stack.c
+++ b/stack.c
@@ -12,14 +12,13 @@ PositionStack ps_new(void) {
return ps;
}
-int ps_push(PositionStack *ps, Position pos) {
+void ps_push(PositionStack *ps, Position pos) {
if (ps->top >= ps->capacity) {
ps->capacity *= STACK_SIZE_COEFFICIENT;
if ((ps->arr = realloc(ps->arr, sizeof(Position) * ps->capacity)) == NULL) error("Failed to realloc ps->arr\n");
}
ps->arr[ps->top] = pos;
ps->top += 1;
- return 0;
}
Position ps_pop(PositionStack *ps) {
diff --git a/stack.h b/stack.h
index 2105c7c..4fd7747 100644
--- a/stack.h
+++ b/stack.h
@@ -10,12 +10,13 @@
struct PositionStack_s {
Position *arr; /* The array with all the values */
size_t capacity;
- size_t top; /* Shows where the top of the stack is */
+ size_t top; /* Shows where the top of the stack is.
+ * Points to the empty spot after the last element */
};
typedef struct PositionStack_s PositionStack;
PositionStack ps_new(void); /* Returns an empty position stack */
-int ps_push(PositionStack *ps, Position pos); /* Returns -1 if failed to realloc() */
+void ps_push(PositionStack *ps, Position pos); /* Returns -1 if failed to realloc() */
Position ps_pop(PositionStack *ps);
Position ps_peek(PositionStack ps);
void ps_free(PositionStack ps);