intel/tinycbor

cbor_encoder_close_container behavior question

danewalton opened this issue · 1 comments

I'm curious why cbor_encoder_close_container advances the data.ptr of encoder? It seems that doing that, it loses the beginning of the data which was just encoded. Calling _cbor_encoder_get_buffer_pointer or accessing the data.ptr after gives a wrong position.

It needs to make the CborEncoder object point to where the last contained element ended (plus the 0xff break byte, if one was added).

The beginning of the data is not stored.