Hi Jitesh,
Yes, this is possible, but a bit harder.
Instead of using MallocMessageBuilder, you would need to define your own
subclass of capnp::MessageBuilder that returns the buffers you want to use.
You will also need to keep track of framing on your own -- that is, keep
track of the number
Thanks Kenton, this is working well. Now the allocation in
messageToFlatArray is not happening.
Now, is it possible to build the message in the buffer directly ?
Currently, I'm building in arena and then calling writeMessage to write
into the buffer.
Hi Jitesh,
Yes, you can avoid the allocation as follows:
1. Construct a kj::ArrayOutputStream that uses your destination buffer as
the output.
2. Use capnp::writeMessage() to write the message to that stream.
-Kenton
On Fri, Feb 25, 2022 at 12:31 PM Jitesh Khandelwal
wrote:
> I am trying to
I am trying to implement a middle layer which serialises some data from a
data structure into a buffer, which is owned by and whose contents are
written on the wire by an outer layer.
Currently, my code looks as follows