- Use MessagePack strings for IP addresses and other text fields.
- Mark dynamic event fields as nullable in getters.
- Add overflow checks for event list capacity.
Update event generator to use mem_balloc/mem_delete for byte arrays in
events, ensuring consistency with Tox memory management. Also fix struct
initialization to use compound literals compliant with tokstyle.
Also add a bunch of casts where needed. I've tried to model everything
in such a way that it minimises casts. The casts *should* be safe, but
it's not always obvious. In the obvious cases, we should have a linter
that validates it. In the non-obvious cases, that linter should warn and
require that we add a null check. I've added some null checks in some
cases but not all.
Also, refactored some of the constructor functions to never assign a
maybe-null value to a non-null struct member, instead using a temporary
local variable to check if construction/allocation succeeded.
There will be more object arrays that need to be packed. This function
takes care of NULL (creating an empty array), and putting the correct
array size and calling the per-element callback the right amount of
times.
These are quite expensive, because they go through all events to index
in a typed array that no longer exists. Clients should index in the
union array and find the event they want themselves, or use dispatch.