On Wed, Aug 31, 2016 at 2:06 PM, Luke Mauldin <lukemaul...@gmail.com> wrote: > I modified my example based on the code example you gave at the bottom for > the pointer arithmetic and that compiled without any go vet errors. I > attempted to use the slice whose backing array is the C array > https://play.golang.org/p/rJoDMu5YAQ but I get a compile error: > main.go:14: cannot convert cArr (type *Tag) to type *[1048576]Tag
Oh, sorry, you need to drop in another conversion to unsafe.Pointer. > Another question, if I update my code to use the slice whose backing array > is the C array, I see the slice type supports 1048576 entries. If I only > need at most 100 entries, is there a memory penalty imposed by declaring the > type to support 1048576 entries? If so, how great is that penalty? There is no penalty. It's just a pointer type conversion. Though if you are seeing that many entries, then I suspect that you left out the operation that slices the pointer back down to arrLength (the [:arrLength:arrLength] at the end of line in the code I sent). Ian -- 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. For more options, visit https://groups.google.com/d/optout.