Return 0, nil in all io cases where an empty slice is provided

This commit is contained in:
Feoramund
2024-08-28 19:53:20 +02:00
committed by Laytan
parent ef99373c31
commit f453054aff
6 changed files with 44 additions and 1 deletions
+6
View File
@@ -201,6 +201,9 @@ _read :: proc(f: ^File_Impl, p: []byte) -> (i64, Error) {
}
_read_at :: proc(f: ^File_Impl, p: []byte, offset: i64) -> (i64, Error) {
if len(p) == 0 {
return 0, nil
}
if offset < 0 {
return 0, .Invalid_Offset
}
@@ -226,6 +229,9 @@ _write :: proc(f: ^File_Impl, p: []byte) -> (i64, Error) {
}
_write_at :: proc(f: ^File_Impl, p: []byte, offset: i64) -> (i64, Error) {
if len(p) == 0 {
return 0, nil
}
if offset < 0 {
return 0, .Invalid_Offset
}