aboutsummaryrefslogtreecommitdiff
path: root/core/bytes
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-05-18 11:26:57 +0100
committergingerBill <bill@gingerbill.org>2023-05-18 11:26:57 +0100
commit49d1f6aca03672469d8fda0dedd27e330e698edc (patch)
treef762ab6c9b9d5ae0d374eda0b31a3c164fc94455 /core/bytes
parente82146bf17908dcc3619c8ec34bb0e902d7c213d (diff)
parent49cd9648b05c6eda252122104cb9b1faa2502602 (diff)
Merge branch 'master' into separate-int-word-sizes
Diffstat (limited to 'core/bytes')
-rw-r--r--core/bytes/buffer.odin5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/bytes/buffer.odin b/core/bytes/buffer.odin
index bba834f7e..b60a8e877 100644
--- a/core/bytes/buffer.odin
+++ b/core/bytes/buffer.odin
@@ -38,6 +38,11 @@ buffer_init_string :: proc(b: ^Buffer, s: string) {
}
buffer_init_allocator :: proc(b: ^Buffer, len, cap: int, allocator := context.allocator) {
+ if b.buf == nil {
+ b.buf = make([dynamic]byte, len, cap, allocator)
+ return
+ }
+
b.buf.allocator = allocator
reserve(&b.buf, cap)
resize(&b.buf, len)