Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cbor_value_ptr_{text,byte}_string #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

petm-dec
Copy link

@petm-dec petm-dec commented Mar 16, 2021

Add functions to directly obtain a pointer to the data
of a text or byte string, without the need to copy.

Otherwise these are analogous to the corresponding copy functions.

Add functions to directly obtain a pointer to the data
of a text or byte string, without the need to copy.

Otherwise these are analogous to the corresponding _copy_ functions.
@petm-dec petm-dec changed the title add cbor_value_ref_{text,byte}_string add cbor_value_ptr_{text,byte}_string Mar 16, 2021
@thiagomacieira
Copy link
Member

Zero-copy API is already implemented in dev...thiagomacieira:dev. I've just never published it because it doesn't work really well for microcontrollers.

Since I haven't got the necessary help from them for that in the last 3 years, I'm simply going to ignore them and publish the API as-is.

@kalcutter
Copy link
Contributor

Is there some way to help getting the new API merged?... What specifically doesn't work well for microcontrollers?

@thiagomacieira
Copy link
Member

The problem is that TinyCBOR requires a single buffer with all of your data in it. On many small OSes (I know Zephyr), memory allocation is preferably done in chunks of a fixed size, so if you want for example 200 bytes, you get two 120-byte chunks and form a linked-list with them.

The parsing API was meant to help fix that, but if you couple that with the string API, it gets messy. Suppose you have that 2x120-byte linked list and your string starts 5 bytes into the first one: how does the API return that information?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants