From 1bed3ac57906b26ef05b25c2bc5c1dca424dba4a Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 1 Jan 2022 13:51:51 +0100 Subject: refactor: fix memory leaks & general improvements --- src/position_stack.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/position_stack.h') diff --git a/src/position_stack.h b/src/position_stack.h index 82c1975..83fb98c 100644 --- a/src/position_stack.h +++ b/src/position_stack.h @@ -4,25 +4,27 @@ #define STACK_ERR_OVERFLOW 0xFFF01 #define STACK_ERR_UNDERFLOW 0xFFF02 -struct Position +typedef struct Position { int x; int y; -}; +} Position; -struct PositionStack +typedef struct PositionStack { int capacity; int top; - struct Position *items; -}; + Position *items; +} PositionStack; -struct PositionStack *create_pos_stack(int capacity); +PositionStack *pos_stack_create(int capacity); -void pos_stack_push(struct PositionStack *stack_pt, struct Position pos); +void pos_stack_destroy(PositionStack *pos_stack); -struct Position pos_stack_peek(struct PositionStack *stack_pt); +void pos_stack_push(PositionStack *pos_stack, Position pos); -struct Position pos_stack_pop(struct PositionStack *stack_pt); +Position pos_stack_peek(PositionStack *pos_stack); + +Position pos_stack_pop(PositionStack *pos_stack); #endif -- cgit v1.2.3-18-g5258