aboutsummaryrefslogtreecommitdiff
path: root/src/std
diff options
context:
space:
mode:
Diffstat (limited to 'src/std')
-rw-r--r--src/std/buffer.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/std/buffer.c b/src/std/buffer.c
index dca3b26..4ec9c29 100644
--- a/src/std/buffer.c
+++ b/src/std/buffer.c
@@ -33,15 +33,11 @@ static CHECK_RESULT int buffer_ensure_capacity(Buffer *self, usize new_capacity)
return BUFFER_OK;
capacity = self->capacity;
- if(capacity == 0) {
- capacity = new_capacity;
- } else {
- double cap = capacity;
- const double new_cap = new_capacity;
- while(cap < new_cap) {
- cap *= 1.5;
- }
- capacity = cap;
+ if(capacity == 0)
+ capacity = 8;
+
+ while(capacity < new_capacity) {
+ capacity += (capacity >> 1);
}
if(am_realloc(self->data, capacity, &new_mem) != ALLOC_OK)