protobuf-c 1.5.1
Protocol Buffers implementation in C
Packing and unpacking messages

To pack a message, first compute the packed size of the message with protobuf_c_message_get_packed_size(), then allocate a buffer of at least that size, then call protobuf_c_message_pack().

Alternatively, a message can be serialized without calculating the final size first. Use the protobuf_c_message_pack_to_buffer() function and provide a ProtobufCBuffer object which implements an "append" method that consumes data.

To unpack a message, call the protobuf_c_message_unpack() function. The result can be cast to an object of the type that matches the descriptor for the message.

The result of unpacking a message should be freed with protobuf_c_message_free_unpacked().