Remove TEMP_ALLOCATOR_GUARD wrapper

This commit is contained in:
Lucas Perlind
2025-05-08 17:41:03 +10:00
parent 5292a7f4f3
commit 9f2d008a8a
33 changed files with 113 additions and 116 deletions
+12 -12
View File
@@ -69,7 +69,7 @@ _open :: proc(name: string, flags: File_Flags, perm: int) -> (f: ^File, err: Err
if .Trunc in flags { sys_flags += {.TRUNC} }
if .Inheritable in flags { sys_flags -= {.CLOEXEC} }
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cname := clone_to_cstring(name, temp_allocator) or_return
fd := posix.open(cname, sys_flags, transmute(posix.mode_t)posix._mode_t(perm))
@@ -184,7 +184,7 @@ _truncate :: proc(f: ^File, size: i64) -> Error {
}
_remove :: proc(name: string) -> (err: Error) {
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cname := clone_to_cstring(name, temp_allocator) or_return
if posix.remove(cname) != 0 {
return _get_platform_error()
@@ -193,7 +193,7 @@ _remove :: proc(name: string) -> (err: Error) {
}
_rename :: proc(old_path, new_path: string) -> (err: Error) {
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cold := clone_to_cstring(old_path, temp_allocator) or_return
cnew := clone_to_cstring(new_path, temp_allocator) or_return
if posix.rename(cold, cnew) != 0 {
@@ -203,7 +203,7 @@ _rename :: proc(old_path, new_path: string) -> (err: Error) {
}
_link :: proc(old_name, new_name: string) -> (err: Error) {
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cold := clone_to_cstring(old_name, temp_allocator) or_return
cnew := clone_to_cstring(new_name, temp_allocator) or_return
if posix.link(cold, cnew) != .OK {
@@ -213,7 +213,7 @@ _link :: proc(old_name, new_name: string) -> (err: Error) {
}
_symlink :: proc(old_name, new_name: string) -> (err: Error) {
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cold := clone_to_cstring(old_name, temp_allocator) or_return
cnew := clone_to_cstring(new_name, temp_allocator) or_return
if posix.symlink(cold, cnew) != .OK {
@@ -223,7 +223,7 @@ _symlink :: proc(old_name, new_name: string) -> (err: Error) {
}
_read_link :: proc(name: string, allocator: runtime.Allocator) -> (s: string, err: Error) {
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({ allocator }))
temp_allocator := TEMP_ALLOCATOR_GUARD({ allocator })
cname := clone_to_cstring(name, temp_allocator) or_return
buf: [dynamic]byte
@@ -269,7 +269,7 @@ _read_link :: proc(name: string, allocator: runtime.Allocator) -> (s: string, er
}
_chdir :: proc(name: string) -> (err: Error) {
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cname := clone_to_cstring(name, temp_allocator) or_return
if posix.chdir(cname) != .OK {
return _get_platform_error()
@@ -292,7 +292,7 @@ _fchmod :: proc(f: ^File, mode: int) -> Error {
}
_chmod :: proc(name: string, mode: int) -> (err: Error) {
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cname := clone_to_cstring(name, temp_allocator) or_return
if posix.chmod(cname, transmute(posix.mode_t)posix._mode_t(mode)) != .OK {
return _get_platform_error()
@@ -308,7 +308,7 @@ _fchown :: proc(f: ^File, uid, gid: int) -> Error {
}
_chown :: proc(name: string, uid, gid: int) -> (err: Error) {
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cname := clone_to_cstring(name, temp_allocator) or_return
if posix.chown(cname, posix.uid_t(uid), posix.gid_t(gid)) != .OK {
return _get_platform_error()
@@ -317,7 +317,7 @@ _chown :: proc(name: string, uid, gid: int) -> (err: Error) {
}
_lchown :: proc(name: string, uid, gid: int) -> Error {
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cname := clone_to_cstring(name, temp_allocator) or_return
if posix.lchown(cname, posix.uid_t(uid), posix.gid_t(gid)) != .OK {
return _get_platform_error()
@@ -337,7 +337,7 @@ _chtimes :: proc(name: string, atime, mtime: time.Time) -> (err: Error) {
},
}
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cname := clone_to_cstring(name, temp_allocator) or_return
if posix.utimes(cname, &times) != .OK {
@@ -365,7 +365,7 @@ _fchtimes :: proc(f: ^File, atime, mtime: time.Time) -> Error {
}
_exists :: proc(path: string) -> bool {
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({}))
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cpath, err := clone_to_cstring(path, temp_allocator)
if err != nil { return false }
return posix.access(cpath) == .OK