Re: [capnproto] Can I do better?

2022-02-28 Thread 'Kenton Varda' via Cap'n Proto
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

Re: [capnproto] Can I do better?

2022-02-26 Thread Jitesh Khandelwal
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.

Re: [capnproto] Can I do better?

2022-02-25 Thread 'Kenton Varda' via Cap'n Proto
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

[capnproto] Can I do better?

2022-02-25 Thread Jitesh Khandelwal
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