Cgo add cbytes implementation (rebased version of #3318) (#4470)

cgo: added CBytes implementation
This commit is contained in:
leongross
2024-09-17 07:12:57 -07:00
committed by GitHub
parent d4729f92bd
commit a9bf981d92
10 changed files with 61 additions and 1 deletions
+7
View File
@@ -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
}