aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lilley <ianlilleyt@gmail.com>2022-08-03 11:49:42 -0400
committerIan Lilley <ianlilleyt@gmail.com>2022-08-03 11:49:42 -0400
commitdbec4b0d0e4395e22e178a3fea91b6bfdcd52c61 (patch)
tree57fba2d36cf575c99f969e20d84fad898eb5cd4d
parent73beed0477936ee5b64b9b02f8fa7e399c623c8b (diff)
fixed memory leak from calling get_env
-rw-r--r--core/os/os2/user.odin20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/os/os2/user.odin b/core/os/os2/user.odin
index 1fb653b85..00cccd2a7 100644
--- a/core/os/os2/user.odin
+++ b/core/os/os2/user.odin
@@ -6,19 +6,19 @@ import "core:runtime"
user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
#partial switch ODIN_OS {
case .Windows:
- dir = get_env("LocalAppData")
+ dir = get_env("LocalAppData", allocator)
if dir != "" {
dir = strings.clone_safe(dir, allocator) or_return
}
case .Darwin:
- dir = get_env("HOME")
+ dir = get_env("HOME", allocator)
if dir != "" {
dir = strings.concatenate_safe({dir, "/Library/Caches"}, allocator) or_return
}
case: // All other UNIX systems
- dir = get_env("XDG_CACHE_HOME")
+ dir = get_env("XDG_CACHE_HOME", allocator)
if dir == "" {
- dir = get_env("HOME")
+ dir = get_env("HOME", allocator)
if dir == "" {
return
}
@@ -34,19 +34,19 @@ user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error
user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
#partial switch ODIN_OS {
case .Windows:
- dir = get_env("AppData")
+ dir = get_env("AppData", allocator)
if dir != "" {
dir = strings.clone_safe(dir, allocator) or_return
}
case .Darwin:
- dir = get_env("HOME")
+ dir = get_env("HOME", allocator)
if dir != "" {
dir = strings.concatenate_safe({dir, "/Library/Application Support"}, allocator) or_return
}
case: // All other UNIX systems
- dir = get_env("XDG_CACHE_HOME")
+ dir = get_env("XDG_CACHE_HOME", allocator)
if dir == "" {
- dir = get_env("HOME")
+ dir = get_env("HOME", allocator)
if dir == "" {
return
}
@@ -59,13 +59,13 @@ user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Erro
return
}
-user_home_dir :: proc() -> (dir: string, err: Error) {
+user_home_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
env := "HOME"
#partial switch ODIN_OS {
case .Windows:
env = "USERPROFILE"
}
- if v := get_env(env); v != "" {
+ if v := get_env(env, allocator); v != "" {
return v, nil
}
return "", .Invalid_Path