os: small cleanup in the FreeBSD branch of os.executable/0: use fixed array for the sysctl params, instead of allocating a dynamic one (#20353)

This commit is contained in:
Delyan Angelov 2024-01-02 19:39:33 +02:00 committed by GitHub
parent d5dba2d4c6
commit 8359df0a01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -716,11 +716,8 @@ pub fn executable() string {
}
$if freebsd {
bufsize := usize(max_path_buffer_size)
mib := [1, // CTL_KERN
14, // KERN_PROC
12, // KERN_PROC_PATHNAME
-1]
unsafe { C.sysctl(mib.data, mib.len, &result[0], &bufsize, 0, 0) }
mib := [C.CTL_KERN, C.KERN_PROC, C.KERN_PROC_PATHNAME, -1]!
unsafe { C.sysctl(&mib[0], mib.len, &result[0], &bufsize, 0, 0) }
res := unsafe { tos_clone(&result[0]) }
return res
}