diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:26:32 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:37:04 +0200 |
commit | b6b3760e19716c574ca9a0ec0bacfe5518b39f77 (patch) | |
tree | 76c2c04069d22d36550a62e4b5bb7878fcefb4fd /src/std | |
parent | 203fbb778e9cfe3aff8b4dee6da9a103a171ca0e (diff) |
load function in progress
Diffstat (limited to 'src/std')
-rw-r--r-- | src/std/buffer.c | 14 |
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) |