mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Add runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD where appropriate
This commit is contained in:
@@ -4,6 +4,7 @@ package sysinfo
|
||||
import sys "core:sys/unix"
|
||||
import "core:strconv"
|
||||
import "core:strings"
|
||||
import "core:runtime"
|
||||
|
||||
@(private)
|
||||
version_string_buf: [1024]u8
|
||||
@@ -41,6 +42,8 @@ init_os_version :: proc () {
|
||||
|
||||
major_ok, minor_ok, patch_ok: bool
|
||||
|
||||
tmp := runtime.default_temp_allocator_temp_begin()
|
||||
|
||||
triplet := strings.split(string(cstring(&version_bits[0])), ".", context.temp_allocator)
|
||||
if len(triplet) != 3 {
|
||||
have_kernel_version = false
|
||||
@@ -54,6 +57,8 @@ init_os_version :: proc () {
|
||||
}
|
||||
}
|
||||
|
||||
runtime.default_temp_allocator_temp_end(tmp)
|
||||
|
||||
if !have_kernel_version {
|
||||
// We don't know the kernel version, but we do know the build
|
||||
strings.write_string(&b, "macOS Unknown (build ")
|
||||
|
||||
@@ -4,6 +4,7 @@ package sysinfo
|
||||
import sys "core:sys/unix"
|
||||
import "core:strings"
|
||||
import "core:strconv"
|
||||
import "core:runtime"
|
||||
|
||||
@(private)
|
||||
version_string_buf: [1024]u8
|
||||
@@ -47,6 +48,8 @@ init_os_version :: proc () {
|
||||
return
|
||||
}
|
||||
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
|
||||
// Parse kernel version
|
||||
release := string(cstring(raw_data(kernel_version_buf[:])))
|
||||
version_bits := strings.split_n(release, "-", 2, context.temp_allocator)
|
||||
|
||||
@@ -4,6 +4,7 @@ package sysinfo
|
||||
import "core:c"
|
||||
import sys "core:sys/unix"
|
||||
import "core:intrinsics"
|
||||
import "core:runtime"
|
||||
import "core:os"
|
||||
import "core:strings"
|
||||
import "core:strconv"
|
||||
@@ -69,6 +70,8 @@ init_os_version :: proc () {
|
||||
l := strings.builder_len(b)
|
||||
strings.write_string(&b, string(cstring(&uts.release[0])))
|
||||
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
|
||||
// Parse kernel version, as substrings of the version info in `version_string_buf`
|
||||
version_bits := strings.split_n(strings.to_string(b)[l:], "-", 2, context.temp_allocator)
|
||||
if len(version_bits) > 1 {
|
||||
|
||||
@@ -4,6 +4,7 @@ package sysinfo
|
||||
import sys "core:sys/unix"
|
||||
import "core:strings"
|
||||
import "core:strconv"
|
||||
import "core:runtime"
|
||||
|
||||
@(private)
|
||||
version_string_buf: [1024]u8
|
||||
@@ -32,7 +33,9 @@ init_os_version :: proc () {
|
||||
version := string(cstring(raw_data(kernel_version_buf[:])))
|
||||
strings.write_string(&b, version)
|
||||
|
||||
// // Parse kernel version
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
|
||||
// Parse kernel version
|
||||
triplet := strings.split(version, ".", context.temp_allocator)
|
||||
if len(triplet) == 2 {
|
||||
major, major_ok := strconv.parse_int(triplet[0])
|
||||
|
||||
@@ -7,6 +7,7 @@ import "core:strings"
|
||||
import "core:unicode/utf16"
|
||||
|
||||
import "core:fmt"
|
||||
import "core:runtime"
|
||||
|
||||
@(private)
|
||||
version_string_buf: [1024]u8
|
||||
@@ -314,6 +315,8 @@ read_reg :: proc(hkey: sys.HKEY, subkey, val: string, $T: typeid) -> (res: T, ok
|
||||
return {}, false
|
||||
}
|
||||
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
|
||||
key_name_wide := make([]u16, BUF_SIZE, context.temp_allocator)
|
||||
val_name_wide := make([]u16, BUF_SIZE, context.temp_allocator)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user