Prechádzať zdrojové kódy

Add `buffer_read_ptr` and `buffer_write_ptr`

gingerBill 3 rokov pred
rodič
commit
d3081bd889
1 zmenil súbory, kde vykonal 8 pridanie a 0 odobranie
  1. 8 0
      core/bytes/buffer.odin

+ 8 - 0
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
 	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) {
 buffer_write_string :: proc(b: ^Buffer, s: string) -> (n: int, err: io.Error) {
 	b.last_read = .Invalid
 	b.last_read = .Invalid
 	m, ok := _buffer_try_grow(b, len(s))
 	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
 	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) {
 buffer_read_at :: proc(b: ^Buffer, p: []byte, offset: int) -> (n: int, err: io.Error) {
 	b.last_read = .Invalid
 	b.last_read = .Invalid