From 3841b9c4df66bf82c1d71e3bed8e5c63d9661634 Mon Sep 17 00:00:00 2001 From: Ronald1985 Date: Tue, 7 Nov 2023 22:14:23 +0000 Subject: [PATCH] Updated hostname function, also fix previous commit. Broke read_entire_file_from_handle function in previous commit fix that. --- sysinfo.odin | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sysinfo.odin b/sysinfo.odin index 7517f3e..8c371f2 100644 --- a/sysinfo.odin +++ b/sysinfo.odin @@ -52,16 +52,8 @@ __read_entire_file_from_handle :: proc(fd: os.Handle, allocator := context.alloc bytes_total += bytes_read resize(&_data, bytes_total + BLOCK_SIZE) } - return _data[:bytes_total], true -} - -get_hostname :: proc() -> (string, bool) { - data, ok := __read_entire_file_from_filename("/proc/sys/kernel/hostname") - hostname: string - hostname, ok = strings.remove_all(string(data), "\n") - - return hostname, ok + return _data[:bytes_total], true } @(private) @@ -134,6 +126,14 @@ get_ram_usage_perc :: proc() -> (f64, bool) { return 100 * (((total - free) - (buffers + cached)) / total), true } +get_hostname :: proc() -> (string, bool) { + data, ok := __read_entire_file_from_filename("/proc/sys/kernel/hostname") + + hostname: string + hostname, ok = strings.remove_all(string(data), "\n") + + return hostname, ok +} @(private) parse_cpuinfo :: proc(cpuinfo: string) -> (map[string]string, bool) {