use context.temp_allocator instead of general allocation + delete()

where clone_to_cstring is used with foreign code, it is prefered to use `context.temp_allocator` instead of using the general allocator and manually delete the memory after use.
This commit is contained in:
Sébastien Marie
2022-02-24 11:28:42 +00:00
parent ea34f321ed
commit 14f1793b3e
4 changed files with 26 additions and 53 deletions
+1 -2
View File
@@ -344,9 +344,8 @@ get_last_error_string :: proc() -> string {
}
open :: proc(path: string, flags: int = O_RDWR, mode: int = 0) -> (Handle, Errno) {
cstr := strings.clone_to_cstring(path)
cstr := strings.clone_to_cstring(path, context.temp_allocator)
handle := _unix_open(cstr, i32(flags), u16(mode))
delete(cstr)
if handle == -1 {
return INVALID_HANDLE, 1
}