Clean up allocator stuff into allocators.odin

This commit is contained in:
gingerBill
2024-05-14 17:10:53 +01:00
parent e05315831f
commit ecd7846ec3
8 changed files with 75 additions and 76 deletions
+7 -7
View File
@@ -46,15 +46,15 @@ full_path_from_name :: proc(name: string, allocator: runtime.Allocator) -> (path
if name == "" {
name = "."
}
_TEMP_ALLOCATOR_GUARD()
TEMP_ALLOCATOR_GUARD()
p := win32.utf8_to_utf16(name, _temp_allocator())
p := win32.utf8_to_utf16(name, temp_allocator())
n := win32.GetFullPathNameW(raw_data(p), 0, nil, nil)
if n == 0 {
return "", _get_platform_error()
}
buf := make([]u16, n+1, _temp_allocator())
buf := make([]u16, n+1, temp_allocator())
n = win32.GetFullPathNameW(raw_data(p), u32(len(buf)), raw_data(buf), nil)
if n == 0 {
return "", _get_platform_error()
@@ -131,8 +131,8 @@ _cleanpath_from_handle :: proc(f: ^File, allocator: runtime.Allocator) -> (strin
if n == 0 {
return "", _get_platform_error()
}
_TEMP_ALLOCATOR_GUARD()
buf := make([]u16, max(n, 260)+1, _temp_allocator())
TEMP_ALLOCATOR_GUARD()
buf := make([]u16, max(n, 260)+1, temp_allocator())
n = win32.GetFinalPathNameByHandleW(h, raw_data(buf), u32(len(buf)), 0)
return _cleanpath_from_buf(buf[:n], allocator)
}
@@ -147,8 +147,8 @@ _cleanpath_from_handle_u16 :: proc(f: ^File) -> ([]u16, Error) {
if n == 0 {
return nil, _get_platform_error()
}
_TEMP_ALLOCATOR_GUARD()
buf := make([]u16, max(n, 260)+1, _temp_allocator())
TEMP_ALLOCATOR_GUARD()
buf := make([]u16, max(n, 260)+1, temp_allocator())
n = win32.GetFinalPathNameByHandleW(h, raw_data(buf), u32(len(buf)), 0)
return _cleanpath_strip_prefix(buf[:n]), nil
}