-
Couldn't load subscription status.
- Fork 90
Closed
Milestone
Description
Currently i'm using the lowlevel reader API to deserialize key-values and make decisions based on that. I have a memory contrained system and reusing kv char buffers (for mpack_type_str). The current limitation of the mpack_read API is there is no mpack_read_cstr function which does prober NULL termination and bound checking. I'm not able to use the expect API because I have already read the tag from the stream. The expect API only works when no tag is current in the reader state.
I think the solution would be to move the read part of the mpack_expect_cstr into mpack reader API.
Here is a snippet:
void di_rpc_deserialize_msg(mpack_reader_t *reader, struct di_rpc_msg *msg)
{
char k[64];
char v[64];
....
/* Loop over all keys */
keys = mpack_expect_map(reader);
for (size_t n = 0; n < keys; n++) {
/* Reset read kv */
k[0] = 0;
v[0] = 0;
/* Key */
mpack_expect_cstr(reader, k, sizeof(k));
/* Value */
t = mpack_read_tag(reader);
if (t.type == mpack_type_str) {
/* It would be much better to have mpack_read_cstr here ... */
mpack_read_bytes(reader, v, sizeof(v));
v[t.v.l] = 0;
Metadata
Metadata
Assignees
Labels
No labels