f17-improvement-consistency-performance #25
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) {
|
if (current_stack->size == current_stack->capacity) {
|
||||||
current_stack->capacity += 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) {
|
if (current_stack->buffer == NULL) {
|
||||||
return FLEDASTY_ERROR_FAILED_ALLOCATION;
|
return FLEDASTY_ERROR_FAILED_ALLOCATION;
|
||||||
|
|
@ -102,10 +102,8 @@ void *fledasty_stack_pop(FledastyStack *current_stack) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *value_address = current_stack->buffer + ((current_stack->size - 1) * current_stack->element_byte_size);
|
|
||||||
current_stack->size -= 1;
|
current_stack->size -= 1;
|
||||||
|
return current_stack->buffer + (current_stack->size * current_stack->element_byte_size);
|
||||||
return value_address;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FledastyError fledasty_stack_clear(FledastyStack *current_stack) {
|
FledastyError fledasty_stack_clear(FledastyStack *current_stack) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue