aboutsummaryrefslogtreecommitdiff
path: root/core/bytes
diff options
context:
space:
mode:
Diffstat (limited to 'core/bytes')
-rw-r--r--core/bytes/buffer.odin6
-rw-r--r--core/bytes/reader.odin6
2 files changed, 12 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) {
diff --git a/core/bytes/reader.odin b/core/bytes/reader.odin
index d85e4fe13..2e1c5ed42 100644
--- a/core/bytes/reader.odin
+++ b/core/bytes/reader.odin
@@ -34,6 +34,9 @@ reader_size :: proc(r: ^Reader) -> i64 {
}
reader_read :: proc(r: ^Reader, p: []byte) -> (n: int, err: io.Error) {
+ if len(p) == 0 {
+ return 0, nil
+ }
if r.i >= i64(len(r.s)) {
return 0, .EOF
}
@@ -43,6 +46,9 @@ reader_read :: proc(r: ^Reader, p: []byte) -> (n: int, err: io.Error) {
return
}
reader_read_at :: proc(r: ^Reader, p: []byte, off: i64) -> (n: int, err: io.Error) {
+ if len(p) == 0 {
+ return 0, nil
+ }
if off < 0 {
return 0, .Invalid_Offset
}