From e3690eb85a9456cc1f3ccda751ae7d9fdf2d3b03 Mon Sep 17 00:00:00 2001 From: Hampus Date: Tue, 4 Jan 2022 18:55:51 +0100 Subject: refactor: improve even more --- src/position_stack.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/position_stack.c') diff --git a/src/position_stack.c b/src/position_stack.c index 846d933..597ed5a 100644 --- a/src/position_stack.c +++ b/src/position_stack.c @@ -1,4 +1,5 @@ #include "position_stack.h" +#include "utils.h" #include #include @@ -19,13 +20,13 @@ void stack_error(int err) } // Creates a new stack -PositionStack *pos_stack_create(int capacity) +PositionStack *pos_stack_create(unsigned int capacity) { - PositionStack *pos_stack = malloc(sizeof(PositionStack)); + PositionStack *pos_stack = malloc_s(sizeof(PositionStack)); pos_stack->capacity = capacity; pos_stack->top = -1; - pos_stack->items = malloc(sizeof(Position) * capacity); + pos_stack->items = malloc_s(sizeof(Position) * capacity); return pos_stack; } -- cgit v1.2.3-18-g5258