aboutsummaryrefslogtreecommitdiff
path: root/core/bytes/buffer.odin
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-08-21 11:15:22 +0100
committergingerBill <bill@gingerbill.org>2023-08-21 11:15:22 +0100
commit8bc96652cdaa15b0b03ee45c93ed3d41eefb7e31 (patch)
tree0e681a613ca34d713b31e3985077d533de2607cc /core/bytes/buffer.odin
parent1631a2bac16898310e0dc25f03317d1b334cb2c6 (diff)
parent501635ca2630fd6d9be2f501812512faa55530c9 (diff)
Merge branch 'master' of https://github.com/odin-lang/Odin
Diffstat (limited to 'core/bytes/buffer.odin')
-rw-r--r--core/bytes/buffer.odin5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/bytes/buffer.odin b/core/bytes/buffer.odin
index 4375d8195..abfee6f2f 100644
--- a/core/bytes/buffer.odin
+++ b/core/bytes/buffer.odin
@@ -113,8 +113,11 @@ _buffer_grow :: proc(b: ^Buffer, n: int) -> int {
if i, ok := _buffer_try_grow(b, n); ok {
return i
}
+
if b.buf == nil && n <= SMALL_BUFFER_SIZE {
- b.buf = make([dynamic]byte, n, SMALL_BUFFER_SIZE)
+ // Fixes #2756 by preserving allocator if already set on Buffer via init_buffer_allocator
+ reserve(&b.buf, SMALL_BUFFER_SIZE)
+ resize(&b.buf, n)
return 0
}