diff options
author | Hampus <hampus@hampusmat.com> | 2022-01-04 18:55:51 +0100 |
---|---|---|
committer | Hampus <hampus@hampusmat.com> | 2022-01-05 20:09:27 +0100 |
commit | e3690eb85a9456cc1f3ccda751ae7d9fdf2d3b03 (patch) | |
tree | 2fdd32726d753495bf562102a0531101eaa1ddfd /src/position_stack.c | |
parent | 1bed3ac57906b26ef05b25c2bc5c1dca424dba4a (diff) |
refactor: improve even more
Diffstat (limited to 'src/position_stack.c')
-rw-r--r-- | src/position_stack.c | 7 |
1 files changed, 4 insertions, 3 deletions
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 <stdio.h> #include <stdlib.h> @@ -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; } |