internal/syscall/windows: use unsafe.Slice instead of unsafeheader package

Follow CL 428777.

Change-Id: I5ce49322e92c5d6539bb08248e3366187c30dcd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/428780
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
Tobias Klauser 2022-09-07 17:23:03 +02:00 committed by Gopher Robot
parent 41089704dd
commit 218294f11e

View file

@ -5,7 +5,6 @@
package windows
import (
"internal/unsafeheader"
"sync"
"syscall"
"unicode/utf16"
@ -26,11 +25,7 @@ func UTF16PtrToString(p *uint16) string {
n++
}
// Turn *uint16 into []uint16.
var s []uint16
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&s))
hdr.Data = unsafe.Pointer(p)
hdr.Cap = n
hdr.Len = n
s := unsafe.Slice((*uint16)(unsafe.Pointer(p)), n)
// Decode []uint16 into string.
return string(utf16.Decode(s))
}