Merge pull request #6332 from Faker-09/bufio_remove_mem_depend

Remove core:mem import from core:bufio
This commit is contained in:
Jeroen van Rijn
2026-02-25 16:06:52 +01:00
committed by GitHub
3 changed files with 17 additions and 9 deletions

View File

@@ -1,14 +1,14 @@
package bufio
import "base:runtime"
import "core:io"
import "core:mem"
import "core:unicode/utf8"
import "core:bytes"
// Reader is a buffered wrapper for an io.Reader
Reader :: struct {
buf: []byte,
buf_allocator: mem.Allocator,
buf_allocator: runtime.Allocator,
rd: io.Reader, // reader
r, w: int, // read and write positions for buf

View File

@@ -1,10 +1,10 @@
package bufio
import "core:bytes"
import "core:io"
import "core:mem"
import "core:unicode/utf8"
import "base:runtime"
import "base:intrinsics"
import "core:io"
import "core:bytes"
import "core:unicode/utf8"
// Extra errors returns by scanning procedures
Scanner_Extra_Error :: enum i32 {
@@ -60,7 +60,15 @@ scanner_init_with_buffer :: proc(s: ^Scanner, r: io.Reader, buf: []byte) -> ^Sca
s.r = r
s.split = scan_lines
s.max_token_size = DEFAULT_MAX_SCAN_TOKEN_SIZE
s.buf = mem.buffer_from_slice(buf)
s.buf = transmute([dynamic]byte)runtime.Raw_Dynamic_Array{
data = raw_data(buf),
len = 0,
cap = len(buf),
allocator = runtime.Allocator{
procedure = runtime.nil_allocator_proc,
data = nil,
},
}
resize(&s.buf, cap(s.buf))
return s
}

View File

@@ -1,14 +1,14 @@
package bufio
import "base:runtime"
import "core:io"
import "core:mem"
import "core:unicode/utf8"
// import "core:bytes"
// Writer is a buffered wrapper for an io.Writer
Writer :: struct {
buf: []byte,
buf_allocator: mem.Allocator,
buf_allocator: runtime.Allocator,
wr: io.Writer,
n: int,