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 <fastf...@gmail.com <javascript:>> > 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 >
That constant doesn't always work. (See https://golang.org/issue/13656#issuecomment-165858089.) If you have a static upper bound on the size of the array, then it's fine to use whatever that bound is, but if you don't then you generally need a more dynamic calculation (like the one in https://golang.org/issue/13656#issuecomment-303216308). -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/10db45f8-840e-4fc4-829b-82a7844e3beb%40googlegroups.com.