Fix to DString reserve.

This commit is contained in:
Christoffer Lerno
2023-07-29 22:42:55 +02:00
parent 6808a38c9f
commit b759abc954
2 changed files with 4 additions and 2 deletions

View File

@@ -371,8 +371,10 @@ fn void DString.reserve(&self, usz addition)
}
usz len = data.len + addition;
if (data.capacity >= len) return;
usz new_capacity = data.capacity *= 2;
usz new_capacity = data.capacity * 2;
if (new_capacity < MIN_CAPACITY) new_capacity = MIN_CAPACITY;
while (new_capacity < len) new_capacity *= 2;
data.capacity = new_capacity;
*self = (DString)realloc(data, StringData.sizeof + new_capacity, .using = data.allocator);
}

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.4.587"
#define COMPILER_VERSION "0.4.588"