mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
all: use unsafe.SliceData where appropriate
This commit is contained in:
committed by
Ron Evans
parent
de83d67364
commit
70a0dee8c8
@@ -20,7 +20,7 @@ type reader struct {
|
||||
|
||||
func (r *reader) Read(b []byte) (n int, err error) {
|
||||
if len(b) != 0 {
|
||||
libc_arc4random_buf(unsafe.Pointer(&b[0]), uint(len(b)))
|
||||
libc_arc4random_buf(unsafe.Pointer(unsafe.SliceData(b)), uint(len(b)))
|
||||
}
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func (r *reader) Read(b []byte) (n int, err error) {
|
||||
// See for example: https://github.com/golang/go/issues/33542
|
||||
// For Windows 7 and newer, we might switch to ProcessPrng in the future
|
||||
// (which is a documented function and might be a tiny bit faster).
|
||||
ok := libc_RtlGenRandom(unsafe.Pointer(&b[0]), len(b))
|
||||
ok := libc_RtlGenRandom(unsafe.Pointer(unsafe.SliceData(b)), len(b))
|
||||
if !ok {
|
||||
return 0, errRandom
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user