mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-01 11:48:54 +00:00
more concise null termination
This commit is contained in:
@@ -231,10 +231,10 @@ _set_name :: proc(thread: ^Thread) {
|
||||
}
|
||||
|
||||
buf: [_MAX_PTHREAD_NAME_LENGTH]u8
|
||||
copy(buf[:], name)
|
||||
|
||||
// _MAX_PTHREAD_NAME_LENGTH includes terminating null
|
||||
buf[len(buf) - 1] = 0
|
||||
copy(buf[:len(buf) - 1], name)
|
||||
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
pthread_setname_np(raw_data(buf[:]))
|
||||
|
||||
@@ -167,9 +167,13 @@ _get_name :: proc(thread: ^Thread, allocator: runtime.Allocator, loc: runtime.So
|
||||
}
|
||||
|
||||
buf_16: win32.PWSTR
|
||||
win32.GetThreadDescription(t_handle, &buf_16)
|
||||
|
||||
hr := win32.GetThreadDescription(t_handle, buf_16)
|
||||
defer if win32.SUCCEEDED(hr) {
|
||||
win32.LocalFree(rawptr(buf_16))
|
||||
}
|
||||
|
||||
name = win32.wstring_to_utf8(buf_16, -1, allocator) or_return
|
||||
win32.LocalFree(rawptr(buf_16))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user