From 5f876866330d56b055b97358a966a78530b806b6 Mon Sep 17 00:00:00 2001 From: Mineplay Date: Thu, 15 May 2025 12:20:45 -0500 Subject: [PATCH] fix(stack): fixed reallocation size in push function --- Src/Core/Stack.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Src/Core/Stack.c b/Src/Core/Stack.c index 916ff04..bcec7c3 100644 --- a/Src/Core/Stack.c +++ b/Src/Core/Stack.c @@ -76,7 +76,7 @@ FledastyError fledasty_stack_push(FledastyStack *current_stack, void *value) { if (current_stack->size == current_stack->capacity) { current_stack->capacity += current_stack->capacity; - current_stack->buffer = (unsigned char*)hallocy_realloc(current_stack->buffer, current_stack->capacity); + current_stack->buffer = (unsigned char*)hallocy_realloc(current_stack->buffer, current_stack->capacity * current_stack->element_byte_size); if (current_stack->buffer == NULL) { return FLEDASTY_ERROR_FAILED_ALLOCATION; @@ -102,10 +102,8 @@ void *fledasty_stack_pop(FledastyStack *current_stack) { return NULL; } - void *value_address = current_stack->buffer + ((current_stack->size - 1) * current_stack->element_byte_size); current_stack->size -= 1; - - return value_address; + return current_stack->buffer + (current_stack->size * current_stack->element_byte_size); } FledastyError fledasty_stack_clear(FledastyStack *current_stack) {