diff options
| author | gingerBill <bill@gingerbill.org> | 2022-06-02 13:02:16 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-06-02 13:02:16 +0100 |
| commit | fb49841b1d8e84cb721f5f73200d4c8158cbb4fa (patch) | |
| tree | a89451b5b3195b6e8160a39fc34e3a846cdcded8 /core/strings | |
| parent | 01ea0d6f1e0b32c248d5ddfc0980a350361f9414 (diff) | |
Remove `strings` dependency from `core:sys/windows`
Diffstat (limited to 'core/strings')
| -rw-r--r-- | core/strings/builder.odin | 12 | ||||
| -rw-r--r-- | core/strings/intern.odin | 7 |
2 files changed, 10 insertions, 9 deletions
diff --git a/core/strings/builder.odin b/core/strings/builder.odin index d51e21827..a910b0988 100644 --- a/core/strings/builder.odin +++ b/core/strings/builder.odin @@ -1,6 +1,6 @@ package strings -import "core:mem" +import "core:runtime" import "core:unicode/utf8" import "core:strconv" import "core:io" @@ -129,12 +129,12 @@ reset_builder :: proc(b: ^Builder) { strings.write_byte(&builder, 'b') -> "ab" */ builder_from_bytes :: proc(backing: []byte) -> Builder { - s := transmute(mem.Raw_Slice)backing - d := mem.Raw_Dynamic_Array{ + s := transmute(runtime.Raw_Slice)backing + d := runtime.Raw_Dynamic_Array{ data = s.data, len = 0, cap = s.len, - allocator = mem.nil_allocator(), + allocator = runtime.nil_allocator(), } return Builder{ buf = transmute([dynamic]byte)d, @@ -276,7 +276,7 @@ pop_byte :: proc(b: ^Builder) -> (r: byte) { } r = b.buf[len(b.buf)-1] - d := cast(^mem.Raw_Dynamic_Array)&b.buf + d := cast(^runtime.Raw_Dynamic_Array)&b.buf d.len = max(d.len-1, 0) return } @@ -289,7 +289,7 @@ pop_rune :: proc(b: ^Builder) -> (r: rune, width: int) { } r, width = utf8.decode_last_rune(b.buf[:]) - d := cast(^mem.Raw_Dynamic_Array)&b.buf + d := cast(^runtime.Raw_Dynamic_Array)&b.buf d.len = max(d.len-width, 0) return } diff --git a/core/strings/intern.odin b/core/strings/intern.odin index 27c3db084..1e9577e61 100644 --- a/core/strings/intern.odin +++ b/core/strings/intern.odin @@ -1,6 +1,6 @@ package strings -import "core:mem" +import "core:runtime" // custom string entry struct Intern_Entry :: struct { @@ -11,7 +11,7 @@ Intern_Entry :: struct { // "intern" is a more memory efficient string map // `allocator` is used to allocate the actual `Intern_Entry` strings Intern :: struct { - allocator: mem.Allocator, + allocator: runtime.Allocator, entries: map[string]^Intern_Entry, } @@ -54,7 +54,8 @@ _intern_get_entry :: proc(m: ^Intern, text: string) -> ^Intern_Entry #no_bounds_ } entry_size := int(offset_of(Intern_Entry, str)) + len(text) + 1 - new_entry := (^Intern_Entry)(mem.alloc(entry_size, align_of(Intern_Entry), m.allocator)) + ptr, _ := runtime.mem_alloc(entry_size, align_of(Intern_Entry), m.allocator) + new_entry := (^Intern_Entry)(ptr) new_entry.len = len(text) copy(new_entry.str[:new_entry.len], text) |