aboutsummaryrefslogtreecommitdiff
path: root/core/bytes/buffer.odin
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-08-27 18:45:13 -0400
committerLaytan <laytanlaats@hotmail.com>2024-08-28 19:53:20 +0200
commitf453054affd7b85f8c751c4f62b21788ae9d8ceb (patch)
tree5e1196be43da94a4e5a329c53d951bf6daad7479 /core/bytes/buffer.odin
parentef99373c31bf515d9e5ab0b2749fb04771311c71 (diff)
Return `0, nil` in all `io` cases where an empty slice is provided
Diffstat (limited to 'core/bytes/buffer.odin')
-rw-r--r--core/bytes/buffer.odin6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/bytes/buffer.odin b/core/bytes/buffer.odin
index a61f8f00d..f4d883353 100644
--- a/core/bytes/buffer.odin
+++ b/core/bytes/buffer.odin
@@ -144,6 +144,9 @@ buffer_grow :: proc(b: ^Buffer, n: int, loc := #caller_location) {
}
buffer_write_at :: proc(b: ^Buffer, p: []byte, offset: int, loc := #caller_location) -> (n: int, err: io.Error) {
+ if len(p) == 0 {
+ return 0, nil
+ }
b.last_read = .Invalid
if offset < 0 {
err = .Invalid_Offset
@@ -246,6 +249,9 @@ buffer_read_ptr :: proc(b: ^Buffer, ptr: rawptr, size: int) -> (n: int, err: io.
}
buffer_read_at :: proc(b: ^Buffer, p: []byte, offset: int) -> (n: int, err: io.Error) {
+ if len(p) == 0 {
+ return 0, nil
+ }
b.last_read = .Invalid
if uint(offset) >= len(b.buf) {