Re: [go-nuts] how to pass c array to golang efficiently

2019-08-08 Thread 'Bryan Mills' via golang-nuts
On Wednesday, August 7, 2019 at 4:21:03 AM UTC-4, Jan Mercl wrote: > > On Wed, Aug 7, 2019 at 3:17 AM hui zhang > > wrote: > > > //export Send > > func Send(confid string, len int, pcm *C.short) { > >//put c.short array to int16 slice/array efficiently , how ? > >// memcopy ? > > }

Re: [go-nuts] how to pass c array to golang efficiently

2019-08-07 Thread hui zhang
Got it, thanks! Jan Mercl <0xj...@gmail.com> 于2019年8月7日周三 下午4:20写道: > On Wed, Aug 7, 2019 at 3:17 AM hui zhang wrote: > > > //export Send > > func Send(confid string, len int, pcm *C.short) { > >//put c.short array to int16 slice/array efficiently , how ? > >// memcopy ? > > } > > s :=

Re: [go-nuts] how to pass c array to golang efficiently

2019-08-07 Thread Jan Mercl
On Wed, Aug 7, 2019 at 3:17 AM hui zhang wrote: > //export Send > func Send(confid string, len int, pcm *C.short) { >//put c.short array to int16 slice/array efficiently , how ? >// memcopy ? > } s := (*[^uint(0) >> 1]int16)(unsafe.Pointer(pcm))[:len] // s is []int16, len(s) = len --

Re: [go-nuts] how to pass c array to golang efficiently

2019-08-06 Thread Jan Mercl
On Tue, Aug 6, 2019 at 11:11 AM hui zhang wrote: Please always send code to the ML as plain, black on white text. And/or use play.golang.org. Thanks. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

[go-nuts] how to pass c array to golang efficiently

2019-08-06 Thread hui zhang
I build go as a so called by c program how implement this Send function to make c short array to be used in go as []int16 *efficiently * of course , I can assign it one by one , but it is not an efficient way package main import "C" import "fmt" //export Summ func Summ(x, y int) int {