fix(stack): fixed reallocation size in push function
This commit is contained in:
parent
b8baffdb39
commit
5f87686633
1 changed files with 2 additions and 4 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue