News for hackers. Stuff that matters.
Re:MessagePack: like JSON, but fast and small by SlowRobotAhead on Tuesday March 10, 2020 @07:29PM (#22541144)
That’s strange because CBOR is almost literally msgpack that got an RFC and has extensions. I cant remember what MsgPack does for online streaming and indefinite lengths.

They’re extremely similar.

Re:MessagePack: like JSON, but fast and small by magicalhippo on Tuesday March 10, 2020 @07:52PM (#22541358)
Looked at it again, seems memory management is a bit of an issue, it supports memory allocation callback but not just handing it a buffer to work with (though I guess allocation should be predictable).

Also I don't know how they got "code sizes appreciably under 1 KiB". On my STM32F1 release mode with -Os it adds about 12kB.

But yeah, maybe I should reevaluate CBOR.

Re:MessagePack: like JSON, but fast and small by SlowRobotAhead on Tuesday March 10, 2020 @11:33PM (#22542728)
For reference, I’m using TimyCBOR because it’s include with Amazon FreeRTOS.

You’re on your own for malloc, which for me is great because FreeRTOS Heap4 management is quite good. So I malloc an object I’m decoding into and parse away.

There are two options parsing arrays and strings/bytestrings and I just chose the option where I specify the pointer to use, vs them using normal malloc then free() later.

I really like this setup. I made a deinit(bad_message) that works anywhere it failed (parse, validate, eval, etc), goes through and looks for pointers that I previously would have malloc’ed.

There is another popular library but I forget what it’s called.