Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
rawBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Aug 9, 2022
1 parent 2366f38 commit 7ec9ed6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions z_unistd_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func fromUtf8(buf *int8, size uint64, src []uint16) *int8 {
setErrno(syscall.ERANGE)
return nil
}
psz := (*[1 << 30]byte)(unsafe.Pointer(buf))
psz[copy(psz[:size], s)] = 0
psz := rawBytes(unsafe.Pointer(buf))
psz[copy(psz[:size:size], s)] = 0
return buf
}
4 changes: 3 additions & 1 deletion z_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"unsafe"
)

type rawBytes = *[1 << 30]byte

func toBytes(buf *int8, size uint64) []byte {
return (*[1 << 30]byte)(unsafe.Pointer(buf))[:size:size]
return rawBytes(unsafe.Pointer(buf))[:size:size]
}

func setErrno(err error) {
Expand Down

0 comments on commit 7ec9ed6

Please sign in to comment.