more concise null termination

This commit is contained in:
PePerRoNii
2026-03-23 22:51:16 +07:00
parent 019343bf00
commit c9064cf532
2 changed files with 8 additions and 4 deletions

View File

@@ -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[:]))

View File

@@ -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
}