Skip to content
This repository was archived by the owner on Apr 9, 2020. It is now read-only.

Determine buffer size needed without encoding.#51

Open
sbertin-telular wants to merge 1 commit intocabo:masterfrom
sbertin-telular:null_for_size
Open

Determine buffer size needed without encoding.#51
sbertin-telular wants to merge 1 commit intocabo:masterfrom
sbertin-telular:null_for_size

Conversation

@sbertin-telular
Copy link

If a NULL buffer is passed to cn_cbor_encoder_write, it will determine the necessary size of the buffer without doing the encoding. The buf_size parameter can still set an upper limit on the size.

This should address issue #24.

If a NULL buffer is passed to cn_cbor_encoder_write, it will determine
the necessary size of the buffer without doing the encoding. The
buf_size parameter can still set an upper limit on the size.
ASSERT_NOT_NULL(cb);

enc_sz2 = cn_cbor_encoder_write(NULL, 0, sizeof(encoded), cb);
enc_sz = cn_cbor_encoder_write(encoded, 0, sizeof(encoded), cb);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If #49 is merged, the size passed here could change to enc_sz2 to also test that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant