Files
llgo/x/cbind/buf.go
2024-09-07 09:45:05 +08:00

17 lines
292 B
Go

package cbind
import "unsafe"
type slice struct {
data unsafe.Pointer
len int
}
func GoBytes(buf *int8, n int) []byte {
return *(*[]byte)(unsafe.Pointer(&slice{unsafe.Pointer(buf), n}))
}
func CBuffer(data []byte) (*int8, int) {
return (*int8)(unsafe.Pointer(&data[0])), len(data)
}