builder, cgo, syscall: replace fixed-size array casts with unsafe.Slice

Several places used the (*[1 << N]T)(ptr)[:len:len] pattern to convert
C pointers to Go slices. This has a hardcoded size limit that can panic
if exceeded; RunTool hit this with >1024 linker arguments when many
files are embedded.

Replace all instances with unsafe.Slice, which handles any size.
This commit is contained in:
Jake Bailey
2026-05-10 10:23:48 -07:00
committed by Ayke
parent 1a1506ef79
commit ddbd65beec
3 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -256,7 +256,7 @@ func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, e
if addr == unsafe.Pointer(^uintptr(0)) {
return nil, getErrno()
}
return (*[1 << 30]byte)(addr)[:length:length], nil
return unsafe.Slice((*byte)(addr), length), nil
}
func Munmap(b []byte) (err error) {