From 3820f27c7c25b3d7cb14d39ab60ba4210b5c1364 Mon Sep 17 00:00:00 2001 From: Tetralux Date: Wed, 26 Aug 2020 08:25:01 +0000 Subject: [PATCH 1/5] Fix os.get_current_directory() allocator This procedure accidentally used the temporary allocator for the returned string. Use context.allocator, and the allocator parameter idiom instead. --- core/os/os_windows.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/os/os_windows.odin b/core/os/os_windows.odin index 72916b1e4..3aedb4e59 100644 --- a/core/os/os_windows.odin +++ b/core/os/os_windows.odin @@ -271,7 +271,7 @@ get_page_size :: proc() -> int { // The current directory is stored as a global variable in the process. @private cwd_gate := false; -get_current_directory :: proc() -> string { +get_current_directory :: proc(allocator := context.allocator) -> string { for intrinsics.atomic_xchg(&cwd_gate, true) {} sz_utf16 := win32.GetCurrentDirectoryW(0, nil); @@ -282,7 +282,7 @@ get_current_directory :: proc() -> string { intrinsics.atomic_store(&cwd_gate, false); - return win32.utf16_to_utf8(dir_buf_wstr); + return win32.utf16_to_utf8(dir_buf_wstr, allocator); } set_current_directory :: proc(path: string) -> (err: Errno) { From 8de70ce73dd3fc9740a0589e6167d950d02f244d Mon Sep 17 00:00:00 2001 From: jockus Date: Wed, 26 Aug 2020 17:32:47 +0100 Subject: [PATCH 2/5] Fix path.name failing to remove extension --- core/path/path.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/path/path.odin b/core/path/path.odin index b2fe1c7df..3826e8032 100644 --- a/core/path/path.odin +++ b/core/path/path.odin @@ -48,8 +48,8 @@ base :: proc(path: string, new := false, allocator := context.allocator) -> stri name :: proc(path: string, new := false, allocator := context.allocator) -> string { if path == "" do return ""; - dot := len(path); - end := dot - 1; + end := len(path) - 1; + dot := end; for i := end; i >= 0; i -= 1 { switch path[i] { From 12895de9ac899879792f8d5b4c4dd41ae98a6ba3 Mon Sep 17 00:00:00 2001 From: Michael Kutowski Date: Sat, 29 Aug 2020 21:49:49 +0200 Subject: [PATCH 3/5] fix hsl math.mod to usual hsl conversion --- core/math/linalg/specific.odin | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/math/linalg/specific.odin b/core/math/linalg/specific.odin index 4eca42000..7aad55a11 100644 --- a/core/math/linalg/specific.odin +++ b/core/math/linalg/specific.odin @@ -120,7 +120,9 @@ vector4_linear_to_srgb :: proc(col: Vector4) -> Vector4 { vector4_hsl_to_rgb :: proc(h, s, l: Float, a: Float = 1) -> Vector4 { hue_to_rgb :: proc(p, q, t0: Float) -> Float { - t := math.mod(t0, 1.0); + t := t; + if t < 0 do t += 1; + if t > 1 do t -= 1; switch { case t < 1.0/6.0: return p + (q - p) * 6.0 * t; case t < 1.0/2.0: return q; From 7b0ba769151faf51d5c6606282cbf90e3cedbdd3 Mon Sep 17 00:00:00 2001 From: Michael Kutowski Date: Sat, 29 Aug 2020 22:33:24 +0200 Subject: [PATCH 4/5] Update specific.odin --- core/math/linalg/specific.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/math/linalg/specific.odin b/core/math/linalg/specific.odin index 7aad55a11..7aee992d0 100644 --- a/core/math/linalg/specific.odin +++ b/core/math/linalg/specific.odin @@ -119,7 +119,7 @@ vector4_linear_to_srgb :: proc(col: Vector4) -> Vector4 { } vector4_hsl_to_rgb :: proc(h, s, l: Float, a: Float = 1) -> Vector4 { - hue_to_rgb :: proc(p, q, t0: Float) -> Float { + hue_to_rgb :: proc(p, q, t: Float) -> Float { t := t; if t < 0 do t += 1; if t > 1 do t -= 1; From 0fe47a2f1b233dc6c6a9904c7601981601cb06ef Mon Sep 17 00:00:00 2001 From: Joshua Mark Manton Date: Wed, 2 Sep 2020 18:42:12 -0700 Subject: [PATCH 5/5] Add allocator parameter to os.read_entire_file() --- core/os/os.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/os/os.odin b/core/os/os.odin index d9bb318c4..a81010942 100644 --- a/core/os/os.odin +++ b/core/os/os.odin @@ -65,7 +65,7 @@ file_size_from_path :: proc(path: string) -> i64 { return length; } -read_entire_file :: proc(name: string) -> (data: []byte, success: bool) { +read_entire_file :: proc(name: string, allocator := context.allocator) -> (data: []byte, success: bool) { fd, err := open(name, O_RDONLY, 0); if err != 0 { return nil, false; @@ -81,7 +81,7 @@ read_entire_file :: proc(name: string) -> (data: []byte, success: bool) { return nil, true; } - data = make([]byte, int(length)); + data = make([]byte, int(length), allocator); if data == nil { return nil, false; }