internal/goglfw: refactoring: use unsafe.Add

This commit is contained in:
Hajime Hoshi 2023-05-10 00:39:06 +09:00
parent 1035b1d182
commit 50b68a0427

View File

@ -602,8 +602,9 @@ func bytePtrToString(p *byte) string {
// Find NUL terminator. // Find NUL terminator.
n := 0 n := 0
for ptr := unsafe.Pointer(p); *(*byte)(ptr) != 0; n++ { for ptr := unsafe.Pointer(p); *(*byte)(ptr) != 0; n++ {
ptr = unsafe.Pointer(uintptr(ptr) + 1) ptr = unsafe.Add(ptr, 1)
} }
// unsafe.String(p, n) is available as of Go 1.20.
return string(unsafe.Slice(p, n)) return string(unsafe.Slice(p, n))
} }