Skip to content

Commit 2a9c5fd

Browse files
authored
Merge pull request #6332 from Faker-09/bufio_remove_mem_depend
Remove core:mem import from core:bufio
2 parents 68cd96b + 2a56a94 commit 2a9c5fd

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

core/bufio/reader.odin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package bufio
22

3+
import "base:runtime"
34
import "core:io"
4-
import "core:mem"
55
import "core:unicode/utf8"
66
import "core:bytes"
77

88
// Reader is a buffered wrapper for an io.Reader
99
Reader :: struct {
1010
buf: []byte,
11-
buf_allocator: mem.Allocator,
11+
buf_allocator: runtime.Allocator,
1212

1313
rd: io.Reader, // reader
1414
r, w: int, // read and write positions for buf

core/bufio/scanner.odin

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package bufio
22

3-
import "core:bytes"
3+
import "base:runtime"
4+
import "base:intrinsics"
45
import "core:io"
5-
import "core:mem"
6+
import "core:bytes"
67
import "core:unicode/utf8"
7-
import "base:intrinsics"
88

99
// Extra errors returns by scanning procedures
1010
Scanner_Extra_Error :: enum i32 {
@@ -60,7 +60,15 @@ scanner_init_with_buffer :: proc(s: ^Scanner, r: io.Reader, buf: []byte) -> ^Sca
6060
s.r = r
6161
s.split = scan_lines
6262
s.max_token_size = DEFAULT_MAX_SCAN_TOKEN_SIZE
63-
s.buf = mem.buffer_from_slice(buf)
63+
s.buf = transmute([dynamic]byte)runtime.Raw_Dynamic_Array{
64+
data = raw_data(buf),
65+
len = 0,
66+
cap = len(buf),
67+
allocator = runtime.Allocator{
68+
procedure = runtime.nil_allocator_proc,
69+
data = nil,
70+
},
71+
}
6472
resize(&s.buf, cap(s.buf))
6573
return s
6674
}

core/bufio/writer.odin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package bufio
22

3+
import "base:runtime"
34
import "core:io"
4-
import "core:mem"
55
import "core:unicode/utf8"
66
// import "core:bytes"
77

88
// Writer is a buffered wrapper for an io.Writer
99
Writer :: struct {
1010
buf: []byte,
11-
buf_allocator: mem.Allocator,
11+
buf_allocator: runtime.Allocator,
1212

1313
wr: io.Writer,
1414
n: int,

0 commit comments

Comments
 (0)