mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-17 00:24:05 +00:00
os2: fix wiping results with temp allocator guard
This commit is contained in:
@@ -57,7 +57,6 @@ _read_directory_iterator :: proc(it: ^Read_Directory_Iterator) -> (fi: File_Info
|
||||
return
|
||||
}
|
||||
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
|
||||
for !it.impl.no_more_files {
|
||||
@@ -139,4 +138,4 @@ _read_directory_iterator_destroy :: proc(it: ^Read_Directory_Iterator) {
|
||||
}
|
||||
file_info_delete(it.impl.prev_fi, file_allocator())
|
||||
win32.FindClose(it.impl.find_handle)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@ _lookup_env :: proc(key: string, allocator: runtime.Allocator) -> (value: string
|
||||
return
|
||||
}
|
||||
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
|
||||
ckey := strings.clone_to_cstring(key, temp_allocator())
|
||||
cval := posix.getenv(ckey)
|
||||
|
||||
@@ -8,8 +8,7 @@ _lookup_env :: proc(key: string, allocator: runtime.Allocator) -> (value: string
|
||||
if key == "" {
|
||||
return
|
||||
}
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
wkey, _ := win32_utf8_to_wstring(key, temp_allocator())
|
||||
|
||||
n := win32.GetEnvironmentVariableW(wkey, nil, 0)
|
||||
|
||||
@@ -309,7 +309,7 @@ _read_link_cstr :: proc(name_cstr: cstring, allocator: runtime.Allocator) -> (st
|
||||
}
|
||||
|
||||
_read_link :: proc(name: string, allocator: runtime.Allocator) -> (s: string, e: Error) {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
name_cstr := temp_cstring(name) or_return
|
||||
return _read_link_cstr(name_cstr, allocator)
|
||||
}
|
||||
|
||||
@@ -189,8 +189,7 @@ _symlink :: proc(old_name, new_name: string) -> Error {
|
||||
}
|
||||
|
||||
_read_link :: proc(name: string, allocator: runtime.Allocator) -> (s: string, err: Error) {
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
cname := temp_cstring(name)
|
||||
|
||||
buf: [dynamic]byte
|
||||
|
||||
@@ -609,7 +609,7 @@ _normalize_link_path :: proc(p: []u16, allocator: runtime.Allocator) -> (str: st
|
||||
return "", _get_platform_error()
|
||||
}
|
||||
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
|
||||
buf := make([]u16, n+1, temp_allocator())
|
||||
n = win32.GetFinalPathNameByHandleW(handle, raw_data(buf), u32(len(buf)), win32.VOLUME_NAME_DOS)
|
||||
@@ -635,7 +635,7 @@ _read_link :: proc(name: string, allocator: runtime.Allocator) -> (s: string, er
|
||||
@thread_local
|
||||
rdb_buf: [MAXIMUM_REPARSE_DATA_BUFFER_SIZE]byte
|
||||
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
|
||||
p := _fix_long_path(name, temp_allocator()) or_return
|
||||
handle := _open_sym_link(p) or_return
|
||||
|
||||
@@ -108,7 +108,7 @@ _remove_all :: proc(path: string) -> Error {
|
||||
_get_working_directory :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
win32.AcquireSRWLockExclusive(&cwd_lock)
|
||||
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
|
||||
sz_utf16 := win32.GetCurrentDirectoryW(0, nil)
|
||||
dir_buf_wstr := make([]u16, sz_utf16, temp_allocator()) or_return
|
||||
|
||||
@@ -237,8 +237,7 @@ _process_list :: proc(allocator: runtime.Allocator) -> (list: []int, err: Error)
|
||||
return
|
||||
}
|
||||
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
|
||||
buffer := make([]i32, ret, temp_allocator())
|
||||
ret = darwin.proc_listallpids(raw_data(buffer), ret*size_of(i32))
|
||||
|
||||
@@ -158,7 +158,7 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
|
||||
_ = read_memory_as_struct(ph, process_peb.ProcessParameters, &process_params) or_return
|
||||
|
||||
if selection >= {.Command_Line, .Command_Args} {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
cmdline_w := make([]u16, process_params.CommandLine.Length, temp_allocator()) or_return
|
||||
_ = read_memory_as_slice(ph, process_params.CommandLine.Buffer, cmdline_w) or_return
|
||||
|
||||
@@ -172,7 +172,7 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
|
||||
}
|
||||
}
|
||||
if .Environment in selection {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
env_len := process_params.EnvironmentSize / 2
|
||||
envs_w := make([]u16, env_len, temp_allocator()) or_return
|
||||
_ = read_memory_as_slice(ph, process_params.Environment, envs_w) or_return
|
||||
@@ -181,7 +181,7 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
|
||||
info.fields += {.Environment}
|
||||
}
|
||||
if .Working_Dir in selection {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
cwd_w := make([]u16, process_params.CurrentDirectoryPath.Length, temp_allocator()) or_return
|
||||
_ = read_memory_as_slice(ph, process_params.CurrentDirectoryPath.Buffer, cwd_w) or_return
|
||||
|
||||
@@ -250,7 +250,7 @@ _process_info_by_handle :: proc(process: Process, selection: Process_Info_Fields
|
||||
_ = read_memory_as_struct(ph, process_peb.ProcessParameters, &process_params) or_return
|
||||
|
||||
if selection >= {.Command_Line, .Command_Args} {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
cmdline_w := make([]u16, process_params.CommandLine.Length, temp_allocator()) or_return
|
||||
_ = read_memory_as_slice(ph, process_params.CommandLine.Buffer, cmdline_w) or_return
|
||||
|
||||
@@ -265,7 +265,7 @@ _process_info_by_handle :: proc(process: Process, selection: Process_Info_Fields
|
||||
}
|
||||
|
||||
if .Environment in selection {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
env_len := process_params.EnvironmentSize / 2
|
||||
envs_w := make([]u16, env_len, temp_allocator()) or_return
|
||||
_ = read_memory_as_slice(ph, process_params.Environment, envs_w) or_return
|
||||
@@ -275,7 +275,7 @@ _process_info_by_handle :: proc(process: Process, selection: Process_Info_Fields
|
||||
}
|
||||
|
||||
if .Working_Dir in selection {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
cwd_w := make([]u16, process_params.CurrentDirectoryPath.Length, temp_allocator()) or_return
|
||||
_ = read_memory_as_slice(ph, process_params.CurrentDirectoryPath.Buffer, cwd_w) or_return
|
||||
|
||||
@@ -539,7 +539,7 @@ _process_exe_by_pid :: proc(pid: int, allocator: runtime.Allocator) -> (exe_path
|
||||
}
|
||||
|
||||
_get_process_user :: proc(process_handle: win32.HANDLE, allocator: runtime.Allocator) -> (full_username: string, err: Error) {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
token_handle: win32.HANDLE
|
||||
if !win32.OpenProcessToken(process_handle, win32.TOKEN_QUERY, &token_handle) {
|
||||
err = _get_platform_error()
|
||||
|
||||
@@ -48,8 +48,7 @@ _fstat_internal :: proc(fd: linux.Fd, allocator: runtime.Allocator) -> (fi: File
|
||||
|
||||
// NOTE: _stat and _lstat are using _fstat to avoid a race condition when populating fullpath
|
||||
_stat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err: Error) {
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
name_cstr := temp_cstring(name) or_return
|
||||
|
||||
fd, errno := linux.open(name_cstr, {})
|
||||
@@ -61,8 +60,7 @@ _stat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err
|
||||
}
|
||||
|
||||
_lstat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err: Error) {
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
name_cstr := temp_cstring(name) or_return
|
||||
|
||||
fd, errno := linux.open(name_cstr, {.PATH, .NOFOLLOW})
|
||||
|
||||
@@ -70,8 +70,7 @@ _stat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err
|
||||
return
|
||||
}
|
||||
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
cname := temp_cstring(name) or_return
|
||||
|
||||
rcname := posix.realpath(cname)
|
||||
|
||||
@@ -45,8 +45,7 @@ full_path_from_name :: proc(name: string, allocator: runtime.Allocator) -> (path
|
||||
name = "."
|
||||
}
|
||||
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
|
||||
p := win32_utf8_to_utf16(name, temp_allocator()) or_return
|
||||
|
||||
@@ -66,7 +65,7 @@ internal_stat :: proc(name: string, create_file_attributes: u32, allocator: runt
|
||||
if len(name) == 0 {
|
||||
return {}, .Not_Exist
|
||||
}
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
|
||||
wname := _fix_long_path(name, temp_allocator()) or_return
|
||||
fa: win32.WIN32_FILE_ATTRIBUTE_DATA
|
||||
@@ -130,8 +129,7 @@ _cleanpath_from_handle :: proc(f: ^File, allocator: runtime.Allocator) -> (strin
|
||||
return "", _get_platform_error()
|
||||
}
|
||||
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
|
||||
buf := make([]u16, max(n, 260)+1, temp_allocator())
|
||||
n = win32.GetFinalPathNameByHandleW(h, raw_data(buf), u32(len(buf)), 0)
|
||||
@@ -149,9 +147,6 @@ _cleanpath_from_handle_u16 :: proc(f: ^File) -> ([]u16, Error) {
|
||||
return nil, _get_platform_error()
|
||||
}
|
||||
|
||||
assert(!is_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
|
||||
|
||||
@@ -47,7 +47,7 @@ mkdir_temp :: make_directory_temp
|
||||
// If `dir` is an empty tring, `temp_directory()` will be used.
|
||||
@(require_results)
|
||||
make_directory_temp :: proc(dir, pattern: string, allocator: runtime.Allocator) -> (temp_path: string, err: Error) {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
dir := dir if dir != "" else temp_directory(temp_allocator()) or_return
|
||||
prefix, suffix := _prefix_and_suffix(pattern) or_return
|
||||
prefix = temp_join_path(dir, prefix) or_return
|
||||
|
||||
@@ -4,7 +4,7 @@ package os2
|
||||
import "base:runtime"
|
||||
|
||||
_temp_dir :: proc(allocator: runtime.Allocator) -> (string, runtime.Allocator_Error) {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
tmpdir := get_env("TMPDIR", temp_allocator())
|
||||
if tmpdir == "" {
|
||||
tmpdir = "/tmp"
|
||||
|
||||
@@ -9,7 +9,7 @@ _temp_dir :: proc(allocator: runtime.Allocator) -> (string, runtime.Allocator_Er
|
||||
if n == 0 {
|
||||
return "", nil
|
||||
}
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
TEMP_ALLOCATOR_GUARD(ignore=is_temp(allocator))
|
||||
|
||||
b := make([]u16, max(win32.MAX_PATH, n), temp_allocator())
|
||||
n = win32.GetTempPathW(u32(len(b)), raw_data(b))
|
||||
|
||||
Reference in New Issue
Block a user