diff --git a/internal/egl/egl_windows.go b/internal/egl/egl_windows.go index d451d0b4..102e9eb0 100644 --- a/internal/egl/egl_windows.go +++ b/internal/egl/egl_windows.go @@ -11,7 +11,6 @@ import ( syscall "golang.org/x/sys/windows" "gioui.org/internal/gl" - gunsafe "gioui.org/internal/unsafe" ) type ( @@ -154,7 +153,7 @@ func eglTerminate(disp _EGLDisplay) bool { func eglQueryString(disp _EGLDisplay, name _EGLint) string { r, _, _ := _eglQueryString.Call(uintptr(disp), uintptr(name)) - return gunsafe.GoString(gunsafe.SliceOf(r)) + return syscall.BytePtrToString((*byte)(unsafe.Pointer(r))) } // issue34474KeepAlive calls runtime.KeepAlive as a diff --git a/internal/gl/gl_windows.go b/internal/gl/gl_windows.go index 82835c48..099c82b7 100644 --- a/internal/gl/gl_windows.go +++ b/internal/gl/gl_windows.go @@ -9,8 +9,6 @@ import ( "unsafe" "golang.org/x/sys/windows" - - gunsafe "gioui.org/internal/unsafe" ) var ( @@ -324,7 +322,7 @@ func (c *Functions) GetShaderInfoLog(s Shader) string { } func (c *Functions) GetString(pname Enum) string { s, _, _ := syscall.Syscall(_glGetString.Addr(), 1, uintptr(pname), 0, 0) - return gunsafe.GoString(gunsafe.SliceOf(s)) + return windows.BytePtrToString((*byte)(unsafe.Pointer(s))) } func (c *Functions) GetUniformLocation(p Program, name string) Uniform { cname := cString(name) diff --git a/internal/unsafe/unsafe.go b/internal/unsafe/unsafe.go index 4687ca61..1226513b 100644 --- a/internal/unsafe/unsafe.go +++ b/internal/unsafe/unsafe.go @@ -44,14 +44,3 @@ func SliceOf(s uintptr) []byte { h.Len = 1 << 30 return res } - -// GoString convert a NUL-terminated C string -// to a Go string. -func GoString(s []byte) string { - for i, v := range s { - if v == 0 { - return string(s[:i]) - } - } - return string(s) -} diff --git a/internal/unsafe/unsafe_test.go b/internal/unsafe/unsafe_test.go deleted file mode 100644 index 269ed3e1..00000000 --- a/internal/unsafe/unsafe_test.go +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: Unlicense OR MIT - -package unsafe - -import ( - "testing" -) - -func TestGoString(t *testing.T) { - tests := [][2]string{ - {"Hello\x00", "Hello"}, - {"\x00", ""}, - } - for _, test := range tests { - got := GoString([]byte(test[0])) - if exp := test[1]; exp != got { - t.Errorf("expected %q got %q", exp, got) - } - } -}