mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
cgo: added CBytes implementation
This commit is contained in:
@@ -283,3 +283,10 @@ func cgo_GoBytes(ptr unsafe.Pointer, length uintptr) []byte {
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
func cgo_CBytes(b []byte) unsafe.Pointer {
|
||||
p := malloc(uintptr(len(b)))
|
||||
s := unsafe.Slice((*byte)(p), len(b))
|
||||
copy(s, b)
|
||||
return p
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user