Huh? What happens when you try to make a []C.char?
> Understandable. I'd rather not have to
> rely on a set buffer size if I can help it, either, but I don't see
> any way around that. Is there a way to convert the buffer back into a
> C pointer?
&c[0] should be fine. I think it's even the correct type.
--
matt kane's brain
http://hydrogenproject.com
Yeah, you need to do:
cstr := make([]C.char, wotsize)
Are you sure? You're not providing the buffer length, so it's more
likely that there's a known buffer size you have to provide, or
worse.. it will just crash. I'd look further before using this API.
Either way, to your question..
> I'd use make to create the array but make doesn't
> appear to work with C types. Understandable. I'd rather not have to
> rely on a set buffer size if I can help it, either, but I don't see
If you're in the Go side, just use Go types..
b := make([]byte, n)
... unsafe.Pointer(&b[0]) ...
return string(b)
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog
-- I never filed a patent.
> I need to allocate enough space for the buffer to work, otherwise IAre you sure? You're not providing the buffer length, so it's more
> get a runtime error
likely that there's a known buffer size you have to provide, or
worse.. it will just crash. I'd look further before using this API.