liteserver / binn

Binary Serialization
Apache License 2.0
440 stars 58 forks source link

Setting length of buffer #24

Closed simon-p-r closed 5 years ago

simon-p-r commented 5 years ago

Hi

Firstly thanks for a great module, however I have one problem I need to encode the first 4 bytes with an uint32_t. I have tried setting the first field of object to 0 and then try resetting to correct size after packing however second function call fails. Here is some code of what I am doing.

binn *obj;

obj = binn_object();

binn_object_set_uint32(obj, "length", 0);

// add more fields to object

int size = binn_size(obj);
binn_object_set_uint32(obj, "length", size);

Thanks Simon

kroggen commented 5 years ago

Hi!

I am not understanding very well what are your needs. Your use case is very weird.

But I can inform that we cannot modify any value after it is inserted on the binn buffer. This is the reason why the second call fails.

simon-p-r commented 5 years ago

Ok no problem, I have worked around it now.