mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 19:43:44 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user