diff options
| author | gingerBill <bill@gingerbill.org> | 2022-07-14 15:26:50 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-07-14 15:26:50 +0100 |
| commit | d3081bd8891e3b018a92064cff41877f6b71ff20 (patch) | |
| tree | 6ad5b87f1c38b264e540b5cf94ea33ee8c4aa4c2 /core/bytes | |
| parent | 2ae5bf4395ce7070b1301f9bee2b60d461dd28fc (diff) | |
Add `buffer_read_ptr` and `buffer_write_ptr`
Diffstat (limited to 'core/bytes')
| -rw-r--r-- | core/bytes/buffer.odin | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/bytes/buffer.odin b/core/bytes/buffer.odin index 7d8ae596d..96f057a9b 100644 --- a/core/bytes/buffer.odin +++ b/core/bytes/buffer.odin @@ -161,6 +161,10 @@ buffer_write :: proc(b: ^Buffer, p: []byte) -> (n: int, err: io.Error) { return copy(b.buf[m:], p), nil } +buffer_write_ptr :: proc(b: ^Buffer, ptr: rawptr, size: int) -> (n: int, err: io.Error) { + return buffer_write(b, ([^]byte)(ptr)[:size]) +} + buffer_write_string :: proc(b: ^Buffer, s: string) -> (n: int, err: io.Error) { b.last_read = .Invalid m, ok := _buffer_try_grow(b, len(s)) @@ -229,6 +233,10 @@ buffer_read :: proc(b: ^Buffer, p: []byte) -> (n: int, err: io.Error) { return } +buffer_read_ptr :: proc(b: ^Buffer, ptr: rawptr, size: int) -> (n: int, err: io.Error) { + return buffer_read(b, ([^]byte)(ptr)[:size]) +} + buffer_read_at :: proc(b: ^Buffer, p: []byte, offset: int) -> (n: int, err: io.Error) { b.last_read = .Invalid |