mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Remove all uses of context stuff in os2
This commit is contained in:
@@ -47,8 +47,16 @@ temp_cstring :: proc(s: string) -> (cstring, runtime.Allocator_Error) {
|
||||
return clone_to_cstring(s, temp_allocator())
|
||||
}
|
||||
|
||||
|
||||
|
||||
string_from_null_terminated_bytes :: proc(b: []byte) -> (res: string) {
|
||||
s := string(b)
|
||||
i := 0
|
||||
for ; i < len(s); i += 1 {
|
||||
if s[i] == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
return s[:i]
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
concatenate_strings_from_buffer :: proc(buf: []byte, strings: ..string) -> string {
|
||||
@@ -61,6 +69,20 @@ concatenate_strings_from_buffer :: proc(buf: []byte, strings: ..string) -> strin
|
||||
return string(buf[:n])
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
concatenate :: proc(strings: []string, allocator: runtime.Allocator) -> (res: string, err: runtime.Allocator_Error) {
|
||||
n := 0
|
||||
for s in strings {
|
||||
n += len(s)
|
||||
}
|
||||
buf := make([]byte, n) or_return
|
||||
n = 0
|
||||
for s in strings {
|
||||
n += copy(buf[n:], s)
|
||||
}
|
||||
return string(buf), nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
@(private="file")
|
||||
|
||||
Reference in New Issue
Block a user