diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-14 21:43:02 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-14 21:43:02 -0400 |
commit | e735ad6710a82604a206ad29f6cbcdd7dc4b024c (patch) | |
tree | 5fe8eebbb7a2bff20bb71bd2368955356979e0a2 /lib/stack.c | |
parent | sync (diff) | |
download | lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.tar.gz lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.tar.bz2 lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.zip |
refactor and add su
Diffstat (limited to 'lib/stack.c')
-rw-r--r-- | lib/stack.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/stack.c b/lib/stack.c index acffc1a..02226d3 100644 --- a/lib/stack.c +++ b/lib/stack.c @@ -1,4 +1,4 @@ -#include "stack.h" +#include "lslib.h" #include <stdint.h> #include <stdio.h> @@ -8,14 +8,14 @@ void stack_init(struct Stack* stack, size_t size) { stack->size = 0; stack->capacity = size; - stack->data = malloc(size); + stack->data = xalloc(size); } void stack_push(struct Stack* stack, void* data, size_t len) { size_t new_size = stack->size + len; if (new_size >= stack->capacity) { stack->capacity = new_size * 2; - stack->data = realloc(stack->data, stack->capacity); + stack->data = xrealloc(stack->data, stack->capacity); } memcpy((uint8_t*)stack->data + stack->size, data, len); stack->size += len; |