diff options
| author | gingerBill <bill@gingerbill.org> | 2023-08-21 11:15:22 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-08-21 11:15:22 +0100 |
| commit | 8bc96652cdaa15b0b03ee45c93ed3d41eefb7e31 (patch) | |
| tree | 0e681a613ca34d713b31e3985077d533de2607cc /core/bytes | |
| parent | 1631a2bac16898310e0dc25f03317d1b334cb2c6 (diff) | |
| parent | 501635ca2630fd6d9be2f501812512faa55530c9 (diff) | |
Merge branch 'master' of https://github.com/odin-lang/Odin
Diffstat (limited to 'core/bytes')
| -rw-r--r-- | core/bytes/buffer.odin | 5 |
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 } |