libcbor
libcbor copied to clipboard
API to get data size needed to serialize cbor item
cbor_serialize returns 0 if data size was insufficient.
It would be useful to also get some report of how many more bytes should be supplied to finish serialization.
Or maybe additional function (something like size_t cbor_calculate(const cbor_item *)) should be added that calculates required data size.
cbor_serialize_alloc provides something similar, but it does it in another way. What I want is to alloc only once, and exactly as many bytes as it is required to store serialized data.