Re: [capnproto] capnp::messageToFlatArray to pre-allocated buffer?

2022-12-05 Thread 'Kenton Varda' via Cap'n Proto
Hi Hui, Sorry for the slow reply, I was on leave. messageToFlatArray() is a convenience function for when you don't mind allocation and copying. If you want more control over serialization, you can use MessageBuilder::getSegmentsForOutput() to get direct pointers to the message's underlying

[capnproto] capnp::messageToFlatArray to pre-allocated buffer?

2022-11-05 Thread Hui min
Hi CapnProto Team, I understand the API to obtain a flat buffer of the built message is capnp::messageToFlatArray. However, the current API forces you to save the buffer on a returned kj::Array words object. Is there a way I could pass in a pre-allocated buffer, and let CapnProto to use that